Skip to content

Commit c580e89

Browse files
add new functions for syscall
1 parent 6c3a333 commit c580e89

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

code/logic/syscall.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
#define PATH_SEP '\\'
2626
#else
2727
#include <unistd.h>
28-
#include <sys/stat.h>
2928
#include <sys/types.h>
29+
#include <sys/stat.h>
3030
#include <dirent.h>
3131
#include <limits.h>
3232
#include <sys/wait.h>
@@ -300,14 +300,24 @@ int fossil_sys_call_list_directory(const char *dirname, char ***out_list, size_t
300300
// ----------------------------------------------------
301301
int fossil_sys_call_is_directory(const char *path) {
302302
if (!path) return 0;
303+
#if defined(_WIN32)
304+
DWORD attrs = GetFileAttributesA(path);
305+
return (attrs != INVALID_FILE_ATTRIBUTES && (attrs & FILE_ATTRIBUTE_DIRECTORY));
306+
#else
303307
struct stat st;
304308
return (stat(path, &st) == 0 && S_ISDIR(st.st_mode));
309+
#endif
305310
}
306311

307312
int fossil_sys_call_is_file(const char *path) {
308313
if (!path) return 0;
314+
#if defined(_WIN32)
315+
DWORD attrs = GetFileAttributesA(path);
316+
return (attrs != INVALID_FILE_ATTRIBUTES && !(attrs & FILE_ATTRIBUTE_DIRECTORY));
317+
#else
309318
struct stat st;
310319
return (stat(path, &st) == 0 && S_ISREG(st.st_mode));
320+
#endif
311321
}
312322

313323
// ----------------------------------------------------

0 commit comments

Comments
 (0)