Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
35533eb2
Commit
35533eb2
authored
18 years ago
by
rswindell
Browse files
Options
Downloads
Patches
Plain Diff
Introduces getdisksize() which reports the total number of bytes (or units,
e.g. kilobytes) of the disk (not just the "free space").
parent
b4024bf4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/xpdev/dirwrap.c
+40
-13
40 additions, 13 deletions
src/xpdev/dirwrap.c
src/xpdev/dirwrap.h
+1
-0
1 addition, 0 deletions
src/xpdev/dirwrap.h
with
41 additions
and
13 deletions
src/xpdev/dirwrap.c
+
40
−
13
View file @
35533eb2
...
...
@@ -680,8 +680,8 @@ static int bit_num(ulong val)
}
#endif
/* Unit should be a power-of-2 (e.g. 1024 to report kilobytes) */
ulong
DLLCALL
getfree
diskspace
(
const
char
*
path
,
ulong
unit
)
/* Unit should be a power-of-2 (e.g. 1024 to report kilobytes)
or 1 (to report bytes)
*/
static
ulong
get
diskspace
(
const
char
*
path
,
ulong
unit
,
BOOL
freespace
)
{
#if defined(_WIN32)
char
root
[
16
];
...
...
@@ -707,20 +707,23 @@ ulong DLLCALL getfreediskspace(const char* path, ulong unit)
NULL
))
/* receives the free bytes on disk */
return
(
0
);
if
(
freespace
)
size
=
avail
;
if
(
unit
>
1
)
avail
.
QuadPart
=
Int64ShrlMod32
(
avail
.
QuadPart
,
bit_num
(
unit
));
size
.
QuadPart
=
Int64ShrlMod32
(
size
.
QuadPart
,
bit_num
(
unit
));
#if defined(_ANONYMOUS_STRUCT)
if
(
avail
.
HighPart
)
if
(
size
.
HighPart
)
#else
if
(
avail
.
u
.
HighPart
)
if
(
size
.
u
.
HighPart
)
#endif
return
(
0xffffffff
);
/* 4GB max */
#if defined(_ANONYMOUS_STRUCT)
return
(
avail
.
LowPart
);
return
(
size
.
LowPart
);
#else
return
(
avail
.
u
.
LowPart
);
return
(
size
.
u
.
LowPart
);
#endif
}
...
...
@@ -735,33 +738,47 @@ ulong DLLCALL getfreediskspace(const char* path, ulong unit)
))
return
(
0
);
if
(
freespace
)
TotalNumberOfClusters
=
NumberOfFreeClusters
;
if
(
unit
>
1
)
NumberOf
Free
Clusters
/=
unit
;
return
(
NumberOf
Free
Clusters
*
SectorsPerCluster
*
BytesPerSector
);
Total
NumberOfClusters
/=
unit
;
return
(
Total
NumberOfClusters
*
SectorsPerCluster
*
BytesPerSector
);
#elif defined(__solaris__) || (defined(__NetBSD_Version__) && (__NetBSD_Version__ >= 300000000
/* NetBSD 3.0 */
))
struct
statvfs
fs
;
unsigned
long
blocks
;
if
(
statvfs
(
path
,
&
fs
)
<
0
)
return
0
;
if
(
freespace
)
blocks
=
fs
.
f_bavail
;
else
blocks
=
fs
.
f_blocks
;
if
(
unit
>
1
)
fs
.
f_bavail
/=
unit
;
return
fs
.
f_bsize
*
fs
.
f_bavail
;
blocks
/=
unit
;
return
fs
.
f_bsize
*
blocks
;
/* statfs is also used under FreeBSD (Though it *supports* statvfs() now too) */
#elif defined(__GLIBC__) || defined(BSD)
struct
statfs
fs
;
unsigned
long
blocks
;
if
(
statfs
(
path
,
&
fs
)
<
0
)
return
0
;
if
(
freespace
)
blocks
=
fs
.
f_bavail
;
else
blocks
=
fs
.
f_blocks
;
if
(
unit
>
1
)
fs
.
f_bavail
/=
unit
;
return
fs
.
f_bsize
*
fs
.
f_bavail
;
blocks
/=
unit
;
return
fs
.
f_bsize
*
blocks
;
#else
...
...
@@ -771,6 +788,16 @@ ulong DLLCALL getfreediskspace(const char* path, ulong unit)
#endif
}
ulong
DLLCALL
getfreediskspace
(
const
char
*
path
,
ulong
unit
)
{
return
getdiskspace
(
path
,
unit
,
/* freespace? */
TRUE
);
}
ulong
DLLCALL
getdisksize
(
const
char
*
path
,
ulong
unit
)
{
return
getdiskspace
(
path
,
unit
,
/* freespace? */
FALSE
);
}
/****************************************************************************/
/* Resolves //, /./, and /../ in a path. Should work indetically to Windows */
/****************************************************************************/
...
...
This diff is collapsed.
Click to expand it.
src/xpdev/dirwrap.h
+
1
−
0
View file @
35533eb2
...
...
@@ -227,6 +227,7 @@ DLLEXPORT BOOL DLLCALL isfullpath(const char* filename);
DLLEXPORT
char
*
DLLCALL
getfname
(
const
char
*
path
);
DLLEXPORT
char
*
DLLCALL
getfext
(
const
char
*
path
);
DLLEXPORT
int
DLLCALL
getfattr
(
const
char
*
filename
);
DLLEXPORT
ulong
DLLCALL
getdisksize
(
const
char
*
path
,
ulong
unit
);
DLLEXPORT
ulong
DLLCALL
getfreediskspace
(
const
char
*
path
,
ulong
unit
);
DLLEXPORT
ulong
DLLCALL
delfiles
(
char
*
inpath
,
char
*
spec
);
DLLEXPORT
char
*
DLLCALL
backslash
(
char
*
path
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment