feat(util): add SFile::FileExists

This commit is contained in:
fallenoak 2025-10-30 23:04:29 -05:00
parent 9bfe4428e3
commit ea8b7ca0b8
No known key found for this signature in database
GPG Key ID: 7628F8E61AEA070D
2 changed files with 17 additions and 0 deletions

View File

@ -16,6 +16,22 @@ int32_t SFile::Close(SFile* file) {
return 1;
}
// TODO Proper implementation
int32_t SFile::FileExists(const char* filename) {
auto pathLen = SStrLen(filename);
char path[STORM_MAX_PATH];
SStrCopy(path, filename, sizeof(path));
for (int32_t i = 0; i < pathLen; ++i) {
if (path[i] == '\\') {
path[i] = '/';
}
}
std::ifstream f(path);
return f.good();
}
// TODO Proper implementation
size_t SFile::GetFileSize(SFile* file, size_t* filesizeHigh) {
return file->m_size;

View File

@ -14,6 +14,7 @@ class SFile {
public:
// Static functions
static int32_t Close(SFile*);
static int32_t FileExists(const char* filename);
static size_t GetFileSize(SFile*, size_t*);
static int32_t IsStreamingMode();
static int32_t IsStreamingTrial();