aboutsummaryrefslogtreecommitdiff
path: root/CPP/Windows/FileSystem.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--CPP/Windows/FileSystem.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/CPP/Windows/FileSystem.cpp b/CPP/Windows/FileSystem.cpp
index 6259453..6a262d9 100644
--- a/CPP/Windows/FileSystem.cpp
+++ b/CPP/Windows/FileSystem.cpp
@@ -71,14 +71,14 @@ UINT MyGetDriveType(CFSTR pathName)
71 } 71 }
72} 72}
73 73
74typedef BOOL (WINAPI * GetDiskFreeSpaceExA_Pointer)( 74typedef BOOL (WINAPI * Func_GetDiskFreeSpaceExA)(
75 LPCSTR lpDirectoryName, // directory name 75 LPCSTR lpDirectoryName, // directory name
76 PULARGE_INTEGER lpFreeBytesAvailable, // bytes available to caller 76 PULARGE_INTEGER lpFreeBytesAvailable, // bytes available to caller
77 PULARGE_INTEGER lpTotalNumberOfBytes, // bytes on disk 77 PULARGE_INTEGER lpTotalNumberOfBytes, // bytes on disk
78 PULARGE_INTEGER lpTotalNumberOfFreeBytes // free bytes on disk 78 PULARGE_INTEGER lpTotalNumberOfFreeBytes // free bytes on disk
79); 79);
80 80
81typedef BOOL (WINAPI * GetDiskFreeSpaceExW_Pointer)( 81typedef BOOL (WINAPI * Func_GetDiskFreeSpaceExW)(
82 LPCWSTR lpDirectoryName, // directory name 82 LPCWSTR lpDirectoryName, // directory name
83 PULARGE_INTEGER lpFreeBytesAvailable, // bytes available to caller 83 PULARGE_INTEGER lpFreeBytesAvailable, // bytes available to caller
84 PULARGE_INTEGER lpTotalNumberOfBytes, // bytes on disk 84 PULARGE_INTEGER lpTotalNumberOfBytes, // bytes on disk
@@ -92,12 +92,14 @@ bool MyGetDiskFreeSpace(CFSTR rootPath, UInt64 &clusterSize, UInt64 &totalSize,
92 #ifndef _UNICODE 92 #ifndef _UNICODE
93 if (!g_IsNT) 93 if (!g_IsNT)
94 { 94 {
95 GetDiskFreeSpaceExA_Pointer pGetDiskFreeSpaceEx = (GetDiskFreeSpaceExA_Pointer)(void *)GetProcAddress( 95 const
96 GetModuleHandle(TEXT("kernel32.dll")), "GetDiskFreeSpaceExA"); 96 Func_GetDiskFreeSpaceExA f = Z7_GET_PROC_ADDRESS(
97 if (pGetDiskFreeSpaceEx) 97 Func_GetDiskFreeSpaceExA, GetModuleHandle(TEXT("kernel32.dll")),
98 "GetDiskFreeSpaceExA");
99 if (f)
98 { 100 {
99 ULARGE_INTEGER freeBytesToCaller2, totalSize2, freeSize2; 101 ULARGE_INTEGER freeBytesToCaller2, totalSize2, freeSize2;
100 sizeIsDetected = BOOLToBool(pGetDiskFreeSpaceEx(fs2fas(rootPath), &freeBytesToCaller2, &totalSize2, &freeSize2)); 102 sizeIsDetected = BOOLToBool(f(fs2fas(rootPath), &freeBytesToCaller2, &totalSize2, &freeSize2));
101 totalSize = totalSize2.QuadPart; 103 totalSize = totalSize2.QuadPart;
102 freeSize = freeSize2.QuadPart; 104 freeSize = freeSize2.QuadPart;
103 } 105 }
@@ -107,12 +109,14 @@ bool MyGetDiskFreeSpace(CFSTR rootPath, UInt64 &clusterSize, UInt64 &totalSize,
107 else 109 else
108 #endif 110 #endif
109 { 111 {
110 GetDiskFreeSpaceExW_Pointer pGetDiskFreeSpaceEx = (GetDiskFreeSpaceExW_Pointer)(void *)GetProcAddress( 112 const
111 GetModuleHandle(TEXT("kernel32.dll")), "GetDiskFreeSpaceExW"); 113 Func_GetDiskFreeSpaceExW f = Z7_GET_PROC_ADDRESS(
112 if (pGetDiskFreeSpaceEx) 114 Func_GetDiskFreeSpaceExW, GetModuleHandle(TEXT("kernel32.dll")),
115 "GetDiskFreeSpaceExW");
116 if (f)
113 { 117 {
114 ULARGE_INTEGER freeBytesToCaller2, totalSize2, freeSize2; 118 ULARGE_INTEGER freeBytesToCaller2, totalSize2, freeSize2;
115 sizeIsDetected = BOOLToBool(pGetDiskFreeSpaceEx(fs2us(rootPath), &freeBytesToCaller2, &totalSize2, &freeSize2)); 119 sizeIsDetected = BOOLToBool(f(fs2us(rootPath), &freeBytesToCaller2, &totalSize2, &freeSize2));
116 totalSize = totalSize2.QuadPart; 120 totalSize = totalSize2.QuadPart;
117 freeSize = freeSize2.QuadPart; 121 freeSize = freeSize2.QuadPart;
118 } 122 }