diff --git a/src/fileio.cpp b/src/fileio.cpp index dfb79b1..3e533f9 100644 --- a/src/fileio.cpp +++ b/src/fileio.cpp @@ -5,6 +5,7 @@ */ #include "fileio.h" +#include #ifdef __EMSCRIPTEN__ #include #endif @@ -17,6 +18,13 @@ void FILEIO::SetSaveDir(const char* savedir) g_savedir = savedir; } +int FILEIO::StatSavedata(const char* filename, struct stat* buf) +{ + _TCHAR path[_MAX_PATH]; + _stprintf_s(path, _MAX_PATH, _T("%s%s"), g_savedir ? g_savedir : g_root, filename); + return stat(path, buf); +} + FILEIO::FILEIO() { // �‰Šú‰» diff --git a/src/fileio.h b/src/fileio.h index f477cc5..73d9fd4 100644 --- a/src/fileio.h +++ b/src/fileio.h @@ -8,6 +8,7 @@ #define _FILEIO_H_ #include +#include #include "common.h" #define FILEIO_READ_BINARY 1 @@ -28,6 +29,7 @@ public: ~FILEIO(); static void SetSaveDir(const char* savedir); + static int StatSavedata(const char* filename, struct stat* buf); bool Fopen(const _TCHAR *filename, int mode); void Fclose(); uint32 Fseek(long offset, int origin); diff --git a/src/sys/nact_sys3.cpp b/src/sys/nact_sys3.cpp index 63021d0..e32e4d8 100644 --- a/src/sys/nact_sys3.cpp +++ b/src/sys/nact_sys3.cpp @@ -5,7 +5,6 @@ */ #include -#include #include #include "nact.h" #include "ags.h" @@ -13,8 +12,6 @@ #include "crc32.h" #include "../fileio.h" -extern _TCHAR g_root[_MAX_PATH]; - void NACT::cmd_calc() { int index = getd(); @@ -1602,13 +1599,12 @@ void NACT::cmd_y() break; case 239: { - _TCHAR path[_MAX_PATH], file_path[_MAX_PATH]; + _TCHAR path[_MAX_PATH]; _tcscpy_s(path, _MAX_PATH, _T("ASLEEP_A.DAT")); path[7] = _T('A') + param - 1; - _stprintf_s(file_path, _MAX_PATH, _T("%s%s"), g_root, path); struct stat statbuf; - if (stat(file_path, &statbuf) != -1) { + if (FILEIO::StatSavedata(path, &statbuf) != -1) { struct tm *t = localtime(&statbuf.st_mtime); D01 = t->tm_year + 1900; D02 = t->tm_mon + 1;