summaryrefslogtreecommitdiff
path: root/filesystem.c
blob: f68fe72515dd04ae6e49b0ed3ffd532507775ca7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <sys/types.h>
#include <sys/stat.h>
#if __unix__
#include <unistd.h>
#endif

static bool fs_file_exists(char const *path) {
#if _WIN32
	struct _stat statbuf = {0};
	if (_stat(path, &statbuf) != 0)
		return false;
	return statbuf.st_mode == _S_IFREG;
#else
	struct stat statbuf = {0};
	if (stat(path, &statbuf) != 0)
		return false;
	return S_ISREG(statbuf.st_mode);
#endif
}