Skip to content

Commit

Permalink
Common: Use stat instead of std::filesystem
Browse files Browse the repository at this point in the history
  • Loading branch information
julianxhokaxhiu committed Oct 25, 2024
1 parent 5c26b0d commit 188a467
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 64,7 @@
#include "achievement.h"
#include "game_cfg.h"
#include "exe_data.h"
#include "utils.h"

#include "ff7/defs.h"
#include "ff7/widescreen.h"
Expand Down Expand Up @@ -3443,7 3444,7 @@ __declspec(dllexport) HRESULT __stdcall EAXDirectSoundCreate(LPGUID guid, LPLPDI
typedef HRESULT(FAR PASCAL* LPEAXDIRECTSOUNDCREATE)(LPGUID, LPLPDIRECTSOUND, IUnknown FAR*);
char eax_dll[MAX_PATH] = {};

if (std::filesystem::exists("creative_eax.dll")) {
if (fileExists("creative_eax.dll")) {
// For portable installation, this name can be used to load the official Creative EAX 2.0 DLL along with FFNx
snprintf(eax_dll, sizeof(eax_dll), R"(%s\creative_eax.dll)", basedir);
} else {
Expand Down
14 changes: 5 additions & 9 deletions src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 27,16 @@

bool fileExists(const char *filename)
{
if (ff8)
{
// Fastest way
return std::filesystem::exists(filename);
}

struct stat dummy;

// Use stat to keep compatibility with 7th Heaven
return stat(filename, &dummy) == 0;
}

bool dirExists(const char *filename)
bool dirExists(const char *dirname)
{
// Fastest way
return std::filesystem::is_directory(filename);
struct stat dummy;

// Use stat to keep compatibility with 7th Heaven
return stat(dirname, &dummy) == 0;
}
2 changes: 1 addition & 1 deletion src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 138,4 @@ inline long double elapsedMicroseconds(std::chrono::time_point<std::chrono::high
}

bool fileExists(const char *filename);
bool dirExists(const char *filename);
bool dirExists(const char *dirname);

0 comments on commit 188a467

Please sign in to comment.