summaryrefslogtreecommitdiff
path: root/os2.c
diff options
context:
space:
mode:
authordarkvater <darkvater@openttd.org>2005-03-28 13:30:51 +0000
committerdarkvater <darkvater@openttd.org>2005-03-28 13:30:51 +0000
commit6bca4c041a243de1750f660aec7b386bdfce335e (patch)
tree6cffe0e6190cbdddbfde21540b0a10de2eadcef2 /os2.c
parent4573a9f872ca0f384d9db513687fcf35f664863f (diff)
downloadopenttd-6bca4c041a243de1750f660aec7b386bdfce335e.tar.xz
(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)
Diffstat (limited to 'os2.c')
-rw-r--r--os2.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/os2.c b/os2.c
index 284757e40..edc0afb84 100644
--- a/os2.c
+++ b/os2.c
@@ -375,21 +375,28 @@ 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)
{
struct diskfree_t free;
+ StringID sid;
char drive;
*path = _fios_path;
drive = *path[0] - 'A' + 1;
- _getdiskfree(drive, &free);
+ if (tot != NULL && _getdiskfree(drive, &free) == 0) {
+ *tot = free.avail_clusters * free.sectors_per_cluster * free.bytes_per_sector;
+ return STR_4005_BYTES_FREE;
+ }
- SetDParam(0, free.avail_clusters * free.sectors_per_cluster * free.bytes_per_sector);
- return STR_4005_BYTES_FREE;
+ return STR_4006_UNABLE_TO_READ_DRIVE;
}
void FiosMakeSavegameName(char *buf, const char *name)