Aggiunta funzione os_get_disk_size()
git-svn-id: svn://10.65.10.50/trunk@6585 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
c343fc34b6
commit
075c25a23b
@ -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);
|
||||
|
@ -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");
|
||||
|
@ -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");
|
||||
|
Loading…
x
Reference in New Issue
Block a user