summaryrefslogtreecommitdiffhomepage
path: root/src/core.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core.c')
-rw-r--r--src/core.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/core.c b/src/core.c
index 7162f47d..54a788bf 100644
--- a/src/core.c
+++ b/src/core.c
@@ -135,8 +135,9 @@
#include <direct.h> // Required for: _getch(), _chdir()
#define GETCWD _getcwd // NOTE: MSDN recommends not to use getcwd(), chdir()
#define CHDIR _chdir
+ #include <io.h> // Required for _access() [Used in FileExists()]
#else
- #include "unistd.h" // Required for: getch(), chdir() (POSIX)
+ #include "unistd.h" // Required for: getch(), chdir() (POSIX), access()
#define GETCWD getcwd
#define CHDIR chdir
#endif
@@ -1514,6 +1515,21 @@ static const char *strprbrk(const char *s, const char *charset)
return latestMatch;
}
+// Return true if the file exists
+bool FileExists(const char *fileName)
+{
+ bool result = false;
+
+#if defined(_WIN32)
+ if (_access(fileName, 0) != -1)
+#else
+ if (access(fileName, F_OK) != -1)
+#endif
+ result = true;
+
+ return result;
+}
+
// Get pointer to filename for a path string
const char *GetFileName(const char *filePath)
{