From 075c25a23b42b04e4ccc0ce9f744ec84885be97b Mon Sep 17 00:00:00 2001 From: guy Date: Mon, 4 May 1998 07:50:46 +0000 Subject: [PATCH] Aggiunta funzione os_get_disk_size() git-svn-id: svn://10.65.10.50/trunk@6585 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- include/os_dep.h | 1 + include/os_win16.cpp | 17 +++++++++++++++++ include/os_win32.cpp | 12 ++++++++++++ 3 files changed, 30 insertions(+) diff --git a/include/os_dep.h b/include/os_dep.h index 3a52b829b..cb990de0d 100755 --- a/include/os_dep.h +++ b/include/os_dep.h @@ -20,6 +20,7 @@ bool os_is_removable_drive(const char* path); bool os_is_network_drive(const char* path); bool os_is_local_drive(const char* path); bool os_test_disk_free_space(const char* path, unsigned long filesize); +unsigned long os_get_disk_size(const char* path); COLOR os_choose_color(COLOR col, WINDOW win); void os_exec_help_command(MENU_TAG tag, const char* key); diff --git a/include/os_win16.cpp b/include/os_win16.cpp index 8ba0f8fc7..5151260c0 100755 --- a/include/os_win16.cpp +++ b/include/os_win16.cpp @@ -371,6 +371,23 @@ bool os_test_disk_free_space(const char* path, unsigned long filesize) return space_ok; } +unsigned long os_get_disk_size(const char* path) +{ + int disk = 0; + if (path && *path && path[1] == ':') + { + const char letter = toupper(path[0]); + disk = 'A' - letter + 1; + } + struct _diskfree_t drive; + _dos_getdiskfree(disk, &drive); + + unsigned long bytes = drive.total_clusters; + bytes *= drive.sectors_per_cluster; + bytes *= drive.bytes_per_sector; + return bytes; +} + void os_exec_help_command(MENU_TAG tag, const char* key) { TFilename hlp("prassi.hlp"); diff --git a/include/os_win32.cpp b/include/os_win32.cpp index 1fb7520b2..d22d36352 100755 --- a/include/os_win32.cpp +++ b/include/os_win32.cpp @@ -190,6 +190,18 @@ bool os_test_disk_free_space(const char* path, unsigned long filesize) return nFree > filesize; } +unsigned long os_get_disk_size(const char* path) +{ + DWORD nSecPerClust, nBytePerSec, nFreeClust, nTotalClust; + GetDiskFreeSpace(path, &nSecPerClust, &nBytePerSec, &nFreeClust, &nTotalClust); + __int64 nFree = nTotalClust; + nFree *= nSecPerClust; + nFree *= nBytePerSec; + unsigned long nVal = nFree > INT_MAX ? (unsigned long)INT_MAX + : (unsigned long)nFree; + return nVal; +} + void os_exec_help_command(MENU_TAG tag, const char* key) { TFilename hlp("prassi.hlp");