summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortron <tron@openttd.org>2005-08-01 00:14:22 +0000
committertron <tron@openttd.org>2005-08-01 00:14:22 +0000
commitfc5e2d4861dd10e751e7bc069fad77a1b0ee1513 (patch)
treebfb1d0b9f54310693b5e429b53d23b1c07727553
parentfcf5ace08fa0cdbb3c5a7d8f9457dcdb61741481 (diff)
downloadopenttd-fc5e2d4861dd10e751e7bc069fad77a1b0ee1513.tar.xz
(svn r2775) Deleting a file can fail, display an error message when it happens
-rw-r--r--hal.h2
-rw-r--r--misc_gui.c4
-rw-r--r--os2.c4
-rw-r--r--unix.c4
-rw-r--r--win32.c4
5 files changed, 10 insertions, 8 deletions
diff --git a/hal.h b/hal.h
index 4a3d9cb7d..665ae386d 100644
--- a/hal.h
+++ b/hal.h
@@ -87,7 +87,7 @@ char *FiosBrowseTo(const FiosItem *item);
// Return path, free space and stringID
StringID FiosGetDescText(const char **path, uint32 *tot);
// Delete a name
-void FiosDelete(const char *name);
+bool FiosDelete(const char *name);
// Make a filename from a name
void FiosMakeSavegameName(char *buf, const char *name);
diff --git a/misc_gui.c b/misc_gui.c
index 3f679a5d4..a289c0cfd 100644
--- a/misc_gui.c
+++ b/misc_gui.c
@@ -1328,7 +1328,9 @@ static void SaveLoadDlgWndProc(Window *w, WindowEvent *e)
break;
case WE_TIMEOUT:
if (HASBIT(w->click_state, 10)) { /* Delete button clicked */
- FiosDelete(WP(w,querystr_d).text.buf);
+ if (!FiosDelete(WP(w,querystr_d).text.buf)) {
+ ShowErrorMessage(INVALID_STRING_ID, STR_4008_UNABLE_TO_DELETE_FILE, 0, 0);
+ }
SetWindowDirty(w);
BuildFileList();
if (_saveload_mode == SLD_SAVE_GAME) {
diff --git a/os2.c b/os2.c
index c942672f4..4d3a42676 100644
--- a/os2.c
+++ b/os2.c
@@ -415,12 +415,12 @@ void FiosMakeSavegameName(char *buf, const char *name)
sprintf(buf, "%s\\%s%s", _fios_path, name, extension);
}
-void FiosDelete(const char *name)
+bool FiosDelete(const char *name)
{
char path[512];
snprintf(path, lengthof(path), "%s\\%s", _fios_path, name);
- unlink(path);
+ return unlink(path) == 0;
}
bool FileExists(const char *filename)
diff --git a/unix.c b/unix.c
index 414e0baf2..c6a50b727 100644
--- a/unix.c
+++ b/unix.c
@@ -353,12 +353,12 @@ void FiosMakeSavegameName(char *buf, const char *name)
sprintf(buf, "%s/%s%s", _fios_path, name, extension);
}
-void FiosDelete(const char *name)
+bool FiosDelete(const char *name)
{
char path[512];
snprintf(path, lengthof(path), "%s/%s", _fios_path, name);
- unlink(path);
+ return unlink(path) == 0;
}
bool FileExists(const char *filename)
diff --git a/win32.c b/win32.c
index 422b1f159..ffd1754c0 100644
--- a/win32.c
+++ b/win32.c
@@ -911,12 +911,12 @@ void FiosMakeSavegameName(char *buf, const char *name)
sprintf(buf, "%s\\%s%s", _fios_path, name, extension);
}
-void FiosDelete(const char *name)
+bool FiosDelete(const char *name)
{
char path[512];
snprintf(path, lengthof(path), "%s\\%s", _fios_path, name);
- DeleteFile(path);
+ return DeleteFile(path) != 0;
}
bool FileExists(const char *filename)