forked from mirror/OpenTTD
(svn r2100) - Fix: [1024703]: Infinite access for A:\ (win32). Patch [1171208]. Only requery drive(s) if the user changes a directory, also surpress the OS error box that pops up on some windows machines. Tron + glx (and me)
This commit is contained in:
40
win32.c
40
win32.c
@@ -1546,13 +1546,17 @@ static FiosItem *FiosAlloc(void)
|
||||
return &_fios_items[_fios_count++];
|
||||
}
|
||||
|
||||
static HANDLE MyFindFirstFile(const char *path, const char *file,
|
||||
WIN32_FIND_DATA *fd)
|
||||
static HANDLE MyFindFirstFile(const char *path, const char *file, WIN32_FIND_DATA *fd)
|
||||
{
|
||||
UINT sem = SetErrorMode(SEM_FAILCRITICALERRORS); // disable 'no-disk' message box
|
||||
HANDLE h;
|
||||
char paths[MAX_PATH];
|
||||
|
||||
sprintf(paths, "%s\\%s", path, file);
|
||||
return FindFirstFile(paths, fd);
|
||||
h = FindFirstFile(paths, fd);
|
||||
|
||||
SetErrorMode(sem); // restore previous setting
|
||||
return h;
|
||||
}
|
||||
|
||||
int CDECL compare_FiosItems(const void *a, const void *b)
|
||||
@@ -1834,23 +1838,31 @@ char *FiosBrowseTo(const FiosItem *item)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Get descriptive texts.
|
||||
// Returns a path as well as a
|
||||
// string describing the path.
|
||||
StringID FiosGetDescText(const char **path)
|
||||
/**
|
||||
* Get descriptive texts. Returns the path and free space
|
||||
* left on the device
|
||||
* @param path string describing the path
|
||||
* @param tfs total free space in megabytes, optional (can be NULL)
|
||||
* @return StringID describing the path (free space or failure)
|
||||
*/
|
||||
StringID FiosGetDescText(const char **path, uint32 *tot)
|
||||
{
|
||||
UINT sem = SetErrorMode(SEM_FAILCRITICALERRORS); // disable 'no-disk' message box
|
||||
char root[4];
|
||||
DWORD spc, bps, nfc, tnc;
|
||||
StringID sid;
|
||||
|
||||
*path = _fios_path;
|
||||
|
||||
sprintf(root, "%c:\\", _fios_path[0]);
|
||||
if (GetDiskFreeSpace(root, &spc, &bps, &nfc, &tnc)) {
|
||||
uint32 tot = ((spc * bps) * (uint64)nfc) >> 20;
|
||||
SetDParam(0, tot);
|
||||
return STR_4005_BYTES_FREE;
|
||||
} else {
|
||||
return STR_4006_UNABLE_TO_READ_DRIVE;
|
||||
}
|
||||
if (tot != NULL && GetDiskFreeSpace(root, &spc, &bps, &nfc, &tnc)) {
|
||||
*tot = ((spc * bps) * (uint64)nfc) >> 20;
|
||||
sid = STR_4005_BYTES_FREE;
|
||||
} else
|
||||
sid = STR_4006_UNABLE_TO_READ_DRIVE;
|
||||
|
||||
SetErrorMode(sem); // reset previous setting
|
||||
return sid;
|
||||
}
|
||||
|
||||
void FiosMakeSavegameName(char *buf, const char *name)
|
||||
|
Reference in New Issue
Block a user