SLUDGE: Implement fileExists built-in function
This commit is contained in:
parent
c9e3747114
commit
cff1308ed1
1 changed files with 14 additions and 20 deletions
|
@ -283,32 +283,26 @@ builtIn(fileExists) {
|
||||||
trimStack(fun->stack);
|
trimStack(fun->stack);
|
||||||
Common::String aaaaa = encodeFilename(g_sludge->loadNow);
|
Common::String aaaaa = encodeFilename(g_sludge->loadNow);
|
||||||
g_sludge->loadNow.clear();
|
g_sludge->loadNow.clear();
|
||||||
|
|
||||||
if (failSecurityCheck(aaaaa))
|
if (failSecurityCheck(aaaaa))
|
||||||
return BR_ERROR;
|
return BR_ERROR;
|
||||||
#if 0
|
|
||||||
FILE *fp = fopen(aaaaa, "rb");
|
|
||||||
if (!fp) {
|
|
||||||
char currentDir[1000];
|
|
||||||
if (!getcwd(currentDir, 998)) {
|
|
||||||
debugOut("Can't get current directory.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (chdir(gamePath)) {
|
bool exist = false;
|
||||||
debugOut("Error: Failed changing to directory %s\n", gamePath);
|
|
||||||
}
|
Common::File fd;
|
||||||
fp = fopen(aaaaa, "rb");
|
if (fd.open(aaaaa)) {
|
||||||
if (chdir(currentDir)) {
|
exist = true;
|
||||||
debugOut("Error: Failed changing to directory %s\n", currentDir);
|
fd.close();
|
||||||
|
} else {
|
||||||
|
Common::InSaveFile *fp = g_system->getSavefileManager()->openForLoading(aaaaa);
|
||||||
|
if (fp) {
|
||||||
|
exist = true;
|
||||||
|
delete fp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
// Return value
|
// Return value
|
||||||
setVariable(fun->reg, SVT_INT, 0/*(fp != NULL)*/); //TODO:false value
|
setVariable(fun->reg, SVT_INT, exist);
|
||||||
#if 0
|
|
||||||
if (fp) fclose(fp);
|
|
||||||
delete[] aaaaa;
|
|
||||||
loadNow = NULL;
|
|
||||||
#endif
|
|
||||||
return BR_CONTINUE;
|
return BR_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue