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
dfef8a98
Commit
dfef8a98
authored
3 months ago
by
Rob Swindell
Browse files
Options
Downloads
Patches
Plain Diff
Remove pre-WinXP support from getdiskspace()
No need to use LoadLibrary and GetProcessAddress here any more either
parent
bc44e1cb
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/xpdev/dirwrap.c
+8
-40
8 additions, 40 deletions
src/xpdev/dirwrap.c
with
8 additions
and
40 deletions
src/xpdev/dirwrap.c
+
8
−
40
View file @
dfef8a98
...
...
@@ -921,53 +921,21 @@ typedef BOOL (WINAPI * GetDiskFreeSpaceEx_t)
static
uint64_t
getdiskspace
(
const
char
*
path
,
uint64_t
unit
,
bool
freespace
)
{
#if defined(_WIN32)
char
root
[
16
];
DWORD
TotalNumberOfClusters
;
DWORD
NumberOfFreeClusters
;
DWORD
BytesPerSector
;
DWORD
SectorsPerCluster
;
uint64_t
total
;
ULARGE_INTEGER
avail
;
ULARGE_INTEGER
size
;
static
HINSTANCE
hK32
=
NULL
;
GetDiskFreeSpaceEx_t
GDFSE
=
NULL
;
if
(
hK32
==
NULL
)
hK32
=
LoadLibraryA
(
"KERNEL32"
);
if
(
hK32
!=
NULL
)
GDFSE
=
(
GetDiskFreeSpaceEx_t
)
GetProcAddress
(
hK32
,
"GetDiskFreeSpaceExA"
);
if
(
GDFSE
!=
NULL
)
{
/* Windows 95-OSR2 or later */
if
(
!
GDFSE
(
path
,
/* pointer to the directory name */
&
avail
,
/* receives the number of bytes on disk avail to the caller */
&
size
,
/* receives the number of bytes on disk */
NULL
))
/* receives the free bytes on disk */
return
0
;
total
=
freespace
?
avail
.
QuadPart
:
size
.
QuadPart
;
if
(
unit
>
1
)
total
/=
unit
;
return
total
;
}
/* Windows 95 (old way), limited to 2GB */
sprintf
(
root
,
"%.3s"
,
path
);
if
(
!
GetDiskFreeSpaceA
(
root
,
/* pointer to root path */
(
PDWORD
)
&
SectorsPerCluster
,
/* pointer to sectors per cluster */
(
PDWORD
)
&
BytesPerSector
,
/* pointer to bytes per sector */
(
PDWORD
)
&
NumberOfFreeClusters
,
/* pointer to number of free clusters */
(
PDWORD
)
&
TotalNumberOfClusters
/* pointer to total number of clusters */
))
if
(
!
GetDiskFreeSpaceExA
(
path
,
/* pointer to the directory name */
&
avail
,
/* receives the number of bytes on disk avail to the caller */
&
size
,
/* receives the number of bytes on disk */
NULL
))
/* receives the free bytes on disk */
return
0
;
if
(
freespace
)
TotalNumberOfClusters
=
NumberOfFreeClusters
;
total
=
freespace
?
avail
.
QuadPart
:
size
.
QuadPart
;
if
(
unit
>
1
)
TotalNumberOfClusters
/=
(
DWORD
)
unit
;
return
TotalNumberOfClusters
*
SectorsPerCluster
*
BytesPerSector
;
total
/=
unit
;
return
total
;
#elif defined(__solaris__) || (defined(__NetBSD_Version__) && (__NetBSD_Version__ >= 300000000
/* NetBSD 3.0 */
))
...
...
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