Skip to content

Commit 4a1dec7

Browse files
committed
2 parents b84878b + 44c6a28 commit 4a1dec7

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

TheForceEngine/TFE_DarkForces/agent.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,7 @@ namespace TFE_DarkForces
510510
// Also, later, the TFE based save format will likely change - so importing will be necessary anyway.
511511
JBool openDarkPilotConfig(FileStream* file)
512512
{
513+
bool triedonce = false;
513514
assert(file);
514515

515516
// TFE uses its own local copy of the save game data to avoid corrupting existing data.
@@ -542,13 +543,15 @@ namespace TFE_DarkForces
542543
{
543544
// Finally generate a new one.
544545
TFE_System::logWrite(LOG_WARNING, "DarkForcesMain", "Cannot find 'DARKPILO.CFG' at '%s'. Creating a new file for save data.", sourcePath);
546+
newpilo:
545547
createDarkPilotConfig(documentsPath);
546548
}
547549
}
548550
}
549551
// Then try opening the file.
550552
if (!file->open(documentsPath, Stream::MODE_READWRITE))
551553
{
554+
TFE_System::logWrite(LOG_ERROR, "DarkForcesMain", "cannot open DARKPILO.CFG");
552555
return JFALSE;
553556
}
554557
// Then verify the file.
@@ -560,6 +563,12 @@ namespace TFE_DarkForces
560563
}
561564
// If it is not correct, then close the file and return false.
562565
file->close();
566+
if (!triedonce)
567+
{
568+
TFE_System::logWrite(LOG_ERROR, "DarkForcesMain", "DARKPILO.CFG corrupted; creating new");
569+
triedonce = true;
570+
goto newpilo;
571+
}
563572
return JFALSE;
564573
}
565-
} // namespace TFE_DarkForces
574+
} // namespace TFE_DarkForces

TheForceEngine/TFE_FileSystem/fileutil-posix.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,16 @@ namespace FileUtil
192192
void copyFile(const char *src, const char *dst)
193193
{
194194
ssize_t rd, wr;
195-
char buf[1024];
195+
char buf[1024], *fnd;
196196
int s, d;
197197

198-
s = open(src, O_RDONLY);
198+
// assume the source is case-insensitive
199+
fnd = findFileObjectNoCase(src, false);
200+
if (!fnd)
201+
return;
202+
203+
s = open(fnd, O_RDONLY);
204+
free(fnd);
199205
if (!s)
200206
return;
201207
d = open(dst, O_WRONLY | O_CREAT, 00644);

0 commit comments

Comments
 (0)