Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
filesystem: add File_DirExists function
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed May 1, 2024
1 parent 82c545b commit 945ba57
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/libtrx/filesystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ typedef enum {

typedef struct MYFILE MYFILE;

bool File_DirExists(const char *path);

bool File_IsAbsolute(const char *path);

bool File_IsRelative(const char *path);
Expand Down
12 changes: 12 additions & 0 deletions src/filesystem.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,18 @@ const char *File_GetGameDirectory(void)
return m_GameDir;
}

bool File_DirExists(const char *path)
{
char *full_path = File_GetFullPath(path);
DIR *dir = opendir(path);
Memory_FreePointer(&full_path);
if (dir != NULL) {
closedir(dir);
return true;
}
return false;
}

bool File_Exists(const char *path)
{
char *full_path = File_GetFullPath(path);
Expand Down

0 comments on commit 945ba57

Please sign in to comment.