Skip to content

Commit fedbffd

Browse files
add missing impl for sanity
1 parent b24440a commit fedbffd

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

code/logic/sanity.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,21 @@ int fossil_sanity_sys_file_exists(const char* filename) {
8585
return (stat(filename, &buffer) == 0); // On Unix-like systems, use the stat function to check if the file exists.
8686
#endif
8787
}
88+
89+
int fossil_sanity_sys_create_dir(const char* dirname) {
90+
#ifdef _WIN32
91+
return CreateDirectoryA(dirname, NULL) ? 0 : -1; // On Windows, use the CreateDirectoryA function to create the directory.
92+
#else
93+
return mkdir(dirname, 0755); // On Unix-like systems, use the mkdir function to create the directory.
94+
#endif
95+
}
96+
97+
int fossil_sanity_sys_dir_exists(const char* dirname) {
98+
#ifdef _WIN32
99+
struct _stat buffer;
100+
return (_stat(dirname, &buffer) == 0 && (buffer.st_mode & _S_IFDIR)); // On Windows, use the _stat function to check if the directory exists.
101+
#else
102+
struct stat buffer;
103+
return (stat(dirname, &buffer) == 0 && S_ISDIR(buffer.st_mode)); // On Unix-like systems, use the stat function to check if the directory exists.
104+
#endif
105+
}

0 commit comments

Comments
 (0)