-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrb-filesystem.cpp
More file actions
executable file
·37 lines (31 loc) · 1.01 KB
/
rb-filesystem.cpp
File metadata and controls
executable file
·37 lines (31 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "rb-filesystem.hpp"
#include <sys/stat.h>
namespace rainbowfish {
namespace fs {
// Taken from http://stackoverflow.com/questions/12774207/fastest-way-to-check-if-a-file-exist-using-standard-c-c11-c
bool FileExists(const char *path) {
struct stat fileStat;
if ( stat(path, &fileStat) ) {
return false;
}
if ( !S_ISREG(fileStat.st_mode) ) {
return false;
}
return true;
}
// Taken from http://stackoverflow.com/questions/12774207/fastest-way-to-check-if-a-file-exist-using-standard-c-c11-c
bool DirExists(const char *path) {
struct stat fileStat;
if ( stat(path, &fileStat) ) {
return false;
}
if ( !S_ISDIR(fileStat.st_mode) ) {
return false;
}
return true;
}
void MakeDir(const char* path) {
mkdir(path, ACCESSPERMS);
}
}
}