diff options
| author | Eli Zaretskii | 2013-12-07 18:01:55 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2013-12-07 18:01:55 +0200 |
| commit | 577c8624d0f51de542c584570917b96aa155b04f (patch) | |
| tree | f590e4347b5b99cc13cdf7815afcc98c4d05f722 /src | |
| parent | 857fd372ee7908cca436e7662f1462815b6ad099 (diff) | |
| download | emacs-577c8624d0f51de542c584570917b96aa155b04f.tar.gz emacs-577c8624d0f51de542c584570917b96aa155b04f.zip | |
Converted file-name-info.
Diffstat (limited to 'src')
| -rw-r--r-- | src/w32fns.c | 55 |
1 files changed, 42 insertions, 13 deletions
diff --git a/src/w32fns.c b/src/w32fns.c index 71ea908374d..a4f9e320fc4 100644 --- a/src/w32fns.c +++ b/src/w32fns.c | |||
| @@ -7346,14 +7346,23 @@ If the underlying system call fails, value is nil. */) | |||
| 7346 | added rather late on. */ | 7346 | added rather late on. */ |
| 7347 | { | 7347 | { |
| 7348 | HMODULE hKernel = GetModuleHandle ("kernel32"); | 7348 | HMODULE hKernel = GetModuleHandle ("kernel32"); |
| 7349 | BOOL (*pfn_GetDiskFreeSpaceEx) | 7349 | BOOL (*pfn_GetDiskFreeSpaceExW) |
| 7350 | (wchar_t *, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER) | ||
| 7351 | = (void *) GetProcAddress (hKernel, "GetDiskFreeSpaceExW"); | ||
| 7352 | BOOL (*pfn_GetDiskFreeSpaceExA) | ||
| 7350 | (char *, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER) | 7353 | (char *, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER) |
| 7351 | = (void *) GetProcAddress (hKernel, "GetDiskFreeSpaceEx"); | 7354 | = (void *) GetProcAddress (hKernel, "GetDiskFreeSpaceExA"); |
| 7355 | bool have_pfn_GetDiskFreeSpaceEx = | ||
| 7356 | (w32_unicode_filenames && pfn_GetDiskFreeSpaceExW | ||
| 7357 | || !w32_unicode_filenames && pfn_GetDiskFreeSpaceExA); | ||
| 7352 | 7358 | ||
| 7353 | /* On Windows, we may need to specify the root directory of the | 7359 | /* On Windows, we may need to specify the root directory of the |
| 7354 | volume holding FILENAME. */ | 7360 | volume holding FILENAME. */ |
| 7355 | char rootname[MAX_PATH]; | 7361 | char rootname[MAX_UTF8_PATH]; |
| 7362 | wchar_t rootname_w[MAX_PATH]; | ||
| 7363 | char rootname_a[MAX_PATH]; | ||
| 7356 | char *name = SDATA (encoded); | 7364 | char *name = SDATA (encoded); |
| 7365 | BOOL result; | ||
| 7357 | 7366 | ||
| 7358 | /* find the root name of the volume if given */ | 7367 | /* find the root name of the volume if given */ |
| 7359 | if (isalpha (name[0]) && name[1] == ':') | 7368 | if (isalpha (name[0]) && name[1] == ':') |
| @@ -7379,7 +7388,12 @@ If the underlying system call fails, value is nil. */) | |||
| 7379 | *str = 0; | 7388 | *str = 0; |
| 7380 | } | 7389 | } |
| 7381 | 7390 | ||
| 7382 | if (pfn_GetDiskFreeSpaceEx) | 7391 | if (w32_unicode_filenames) |
| 7392 | filename_to_utf16 (rootname, rootname_w); | ||
| 7393 | else | ||
| 7394 | filename_to_ansi (rootname, rootname_a); | ||
| 7395 | |||
| 7396 | if (have_pfn_GetDiskFreeSpaceEx) | ||
| 7383 | { | 7397 | { |
| 7384 | /* Unsigned large integers cannot be cast to double, so | 7398 | /* Unsigned large integers cannot be cast to double, so |
| 7385 | use signed ones instead. */ | 7399 | use signed ones instead. */ |
| @@ -7387,10 +7401,17 @@ If the underlying system call fails, value is nil. */) | |||
| 7387 | LARGE_INTEGER freebytes; | 7401 | LARGE_INTEGER freebytes; |
| 7388 | LARGE_INTEGER totalbytes; | 7402 | LARGE_INTEGER totalbytes; |
| 7389 | 7403 | ||
| 7390 | if (pfn_GetDiskFreeSpaceEx (rootname, | 7404 | if (w32_unicode_filenames) |
| 7391 | (ULARGE_INTEGER *)&availbytes, | 7405 | result = pfn_GetDiskFreeSpaceExW (rootname_w, |
| 7392 | (ULARGE_INTEGER *)&totalbytes, | 7406 | (ULARGE_INTEGER *)&availbytes, |
| 7393 | (ULARGE_INTEGER *)&freebytes)) | 7407 | (ULARGE_INTEGER *)&totalbytes, |
| 7408 | (ULARGE_INTEGER *)&freebytes); | ||
| 7409 | else | ||
| 7410 | result = pfn_GetDiskFreeSpaceExA (rootname_a, | ||
| 7411 | (ULARGE_INTEGER *)&availbytes, | ||
| 7412 | (ULARGE_INTEGER *)&totalbytes, | ||
| 7413 | (ULARGE_INTEGER *)&freebytes); | ||
| 7414 | if (result) | ||
| 7394 | value = list3 (make_float ((double) totalbytes.QuadPart), | 7415 | value = list3 (make_float ((double) totalbytes.QuadPart), |
| 7395 | make_float ((double) freebytes.QuadPart), | 7416 | make_float ((double) freebytes.QuadPart), |
| 7396 | make_float ((double) availbytes.QuadPart)); | 7417 | make_float ((double) availbytes.QuadPart)); |
| @@ -7402,11 +7423,19 @@ If the underlying system call fails, value is nil. */) | |||
| 7402 | DWORD free_clusters; | 7423 | DWORD free_clusters; |
| 7403 | DWORD total_clusters; | 7424 | DWORD total_clusters; |
| 7404 | 7425 | ||
| 7405 | if (GetDiskFreeSpace (rootname, | 7426 | if (w32_unicode_filenames) |
| 7406 | §ors_per_cluster, | 7427 | result = GetDiskFreeSpaceW (rootname_w, |
| 7407 | &bytes_per_sector, | 7428 | §ors_per_cluster, |
| 7408 | &free_clusters, | 7429 | &bytes_per_sector, |
| 7409 | &total_clusters)) | 7430 | &free_clusters, |
| 7431 | &total_clusters); | ||
| 7432 | else | ||
| 7433 | result = GetDiskFreeSpaceA (rootname_a, | ||
| 7434 | §ors_per_cluster, | ||
| 7435 | &bytes_per_sector, | ||
| 7436 | &free_clusters, | ||
| 7437 | &total_clusters); | ||
| 7438 | if (result) | ||
| 7410 | value = list3 (make_float ((double) total_clusters | 7439 | value = list3 (make_float ((double) total_clusters |
| 7411 | * sectors_per_cluster * bytes_per_sector), | 7440 | * sectors_per_cluster * bytes_per_sector), |
| 7412 | make_float ((double) free_clusters | 7441 | make_float ((double) free_clusters |