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

filesystem: add File_DirExists function #6

Merged
merged 1 commit into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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