Handle file paths in a clean way

Belated birthday present for @mewmew

Functions for gettings paths have sensible names
It's using snprintf for safe? string concat
Paths don't use \ as path reporator, or magic marker
Drop code for copying pre 1.09 save games from the windows folder
This commit is contained in:
Anders Jenbo 2019-09-26 06:26:37 +02:00
commit 06bcd3c3f9
11 changed files with 67 additions and 242 deletions

View file

@ -1,28 +1,24 @@
#include "diablo.h"
#include "../3rdParty/Storm/Source/storm.h"
DEVILUTION_BEGIN_NAMESPACE
BOOL ReadOnlyTest()
{
char *c;
FILE *f;
char Filename[MAX_PATH];
BOOL ret = FALSE;
char path[MAX_PATH], Filename[MAX_PATH];
if (GetModuleFileName(ghInst, Filename, sizeof(Filename))) {
c = strrchr(Filename, '\\');
if (c) {
strcpy(c + 1, "Diablo1ReadOnlyTest.foo");
f = fopen(Filename, "wt");
if (f) {
fclose(f);
remove(Filename);
} else {
ret = TRUE;
}
}
GetPrefPath(path, MAX_PATH);
snprintf(Filename, DVL_MAX_PATH, "%sDiablo1ReadOnlyTest.foo", path);
f = fopen(Filename, "wt");
if (f) {
fclose(f);
remove(Filename);
return FALSE;
}
return ret;
return TRUE;
}
DEVILUTION_END_NAMESPACE