- client, Windows: when making calls to get free disk space

(e.g. pGetDiskFreeSpaceEx())
		pass the path of the current directory instead of NULL.
		Otherwise, if we're running as an unprivileted user
		with no access to the root dir,
		the call fails and reports zero free space.

	lib/
		filesys.C

svn path=/trunk/boinc/; revision=12744
This commit is contained in:
David Anderson 2007-05-24 17:04:54 +00:00
parent b751d2924d
commit d4266226ab
2 changed files with 15 additions and 2 deletions

View File

@ -5327,3 +5327,14 @@ David 24 May 2007
main.C
sched_config.C,h
server_types.C
David 24 May 2007
- client, Windows: when making calls to get free disk space
(e.g. pGetDiskFreeSpaceEx())
pass the path of the current directory instead of NULL.
Otherwise, if we're running as an unprivileted user
with no access to the root dir,
the call fails and reports zero free space.
lib/
filesys.C

View File

@ -656,6 +656,8 @@ void relative_to_absolute(const char* relname, char* path) {
//
int get_filesystem_info(double &total_space, double &free_space) {
#ifdef _WIN32
char buf[256];
boinc_getcwd(buf);
FreeFn pGetDiskFreeSpaceEx;
pGetDiskFreeSpaceEx = (FreeFn)GetProcAddress(GetModuleHandle("kernel32.dll"),
"GetDiskFreeSpaceExA");
@ -663,7 +665,7 @@ int get_filesystem_info(double &total_space, double &free_space) {
ULARGE_INTEGER TotalNumberOfFreeBytes;
ULARGE_INTEGER TotalNumberOfBytes;
ULARGE_INTEGER TotalNumberOfBytesFreeToCaller;
pGetDiskFreeSpaceEx(NULL, &TotalNumberOfBytesFreeToCaller, &TotalNumberOfBytes, &TotalNumberOfFreeBytes);
pGetDiskFreeSpaceEx(buf, &TotalNumberOfBytesFreeToCaller, &TotalNumberOfBytes, &TotalNumberOfFreeBytes);
signed __int64 uMB;
uMB = TotalNumberOfFreeBytes.QuadPart / (1024 * 1024);
free_space = uMB * 1024.0 * 1024.0;
@ -674,7 +676,7 @@ int get_filesystem_info(double &total_space, double &free_space) {
DWORD dwBytesPerSect;
DWORD dwFreeClusters;
DWORD dwTotalClusters;
GetDiskFreeSpace(NULL, &dwSectPerClust, &dwBytesPerSect, &dwFreeClusters, &dwTotalClusters);
GetDiskFreeSpace(buf, &dwSectPerClust, &dwBytesPerSect, &dwFreeClusters, &dwTotalClusters);
free_space = (double)dwFreeClusters * dwSectPerClust * dwBytesPerSect;
total_space = (double)dwTotalClusters * dwSectPerClust * dwBytesPerSect;
}