Skip to content

Commit

Permalink
Report success for deleting files that don't exist! (save game regres…
Browse files Browse the repository at this point in the history
…sion).
  • Loading branch information
stephenjsweeney committed Dec 2, 2019
1 parent 13c8c9c commit 1a684a9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion common.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
VERSION = 1.2
REVISION = 1
REVISION = 2
LOCALE_MO = $(patsubst %.po,%.mo,$(wildcard locale/*.po))

OUT = bin
Expand Down
24 changes: 18 additions & 6 deletions src/system/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ char *readFile(const char *filename)
{
char *buffer = 0;
unsigned long length;
FILE *file = fopen(getFileLocation(filename), "rb");
FILE *file;

file = fopen(getFileLocation(filename), "rb");

if (file)
{
Expand All @@ -88,8 +90,9 @@ char *readCompressedFile(const char *filename)
unsigned char *buffer, *cBuffer;
uint32_t l1, l2;
unsigned long length, cLength;
FILE *file = fopen(getFileLocation(filename), "rb");
FILE *file;

file = fopen(getFileLocation(filename), "rb");
buffer = 0;
cBuffer = 0;

Expand Down Expand Up @@ -128,13 +131,17 @@ char *readCompressedFile(const char *filename)

int writeFile(const char *filename, const char *data)
{
FILE *file = fopen(filename, "wb");
FILE *file;
int result;

file = fopen(filename, "wb");

if (file)
{
fprintf(file, "%s\n", data);
result = fprintf(file, "%s\n", data);
fclose(file);
return 1;

return result == strlen(data) + 1;
}

return 0;
Expand Down Expand Up @@ -197,7 +204,12 @@ char **getFileList(const char *dir, int *count)

int deleteFile(char *path)
{
return unlink(path) == 0;
if (fileExists(path))
{
return unlink(path) == 0;
}

return 1;
}

int renameFile(char *src, char *dest)
Expand Down

0 comments on commit 1a684a9

Please sign in to comment.