move Windows cases around

also don't make dir_create pretend it succeeds
This commit is contained in:
dzaima 2023-01-06 06:00:57 +02:00
parent 815de4fd97
commit b03bf80198
6 changed files with 12 additions and 26 deletions

1
.gitignore vendored
View File

@ -5,6 +5,7 @@
*.wasm *.wasm
*.cwasm *.cwasm
libcbqn.so libcbqn.so
libcbqn.dylib
*.exe *.exe
*.dll *.dll

View File

@ -323,7 +323,7 @@ void mmap_init() { }
bool dir_create(B path) { bool dir_create(B path) {
char* p = toCStr(path); char* p = toCStr(path);
#if defined(_WIN32) || defined(_WIN64) #if defined(_WIN32) || defined(_WIN64)
bool r = 1; bool r = 0;
#else #else
bool r = mkdir(p, S_IRWXU) == 0; bool r = mkdir(p, S_IRWXU) == 0;
#endif #endif
@ -366,11 +366,13 @@ char path_type(B path) {
i64 mode = s.st_mode; i64 mode = s.st_mode;
if (S_ISREG (mode)) return 'f'; if (S_ISREG (mode)) return 'f';
if (S_ISDIR (mode)) return 'd'; if (S_ISDIR (mode)) return 'd';
if (S_ISLNK (mode)) return 'l';
if (S_ISFIFO(mode)) return 'p'; if (S_ISFIFO(mode)) return 'p';
if (S_ISSOCK(mode)) return 's';
if (S_ISBLK (mode)) return 'b'; if (S_ISBLK (mode)) return 'b';
if (S_ISCHR (mode)) return 'c'; if (S_ISCHR (mode)) return 'c';
#if !defined(_WIN32) && !defined(_WIN64)
if (S_ISLNK (mode)) return 'l';
if (S_ISSOCK(mode)) return 's';
#endif
thrM("Unexpected file type"); thrM("Unexpected file type");
} }

View File

@ -6,10 +6,6 @@
#include "utils/interrupt.h" #include "utils/interrupt.h"
#include <unistd.h> #include <unistd.h>
#if defined(_WIN32) || defined(_WIN64)
#include "windows/sysconf.c"
#endif
#ifndef UNWIND_COMPILER // whether to hide stackframes of the compiler in compiling errors #ifndef UNWIND_COMPILER // whether to hide stackframes of the compiler in compiling errors
#define UNWIND_COMPILER 1 #define UNWIND_COMPILER 1
#endif #endif
@ -1134,8 +1130,12 @@ B block_decompose(B x) { return m_hVec2(m_i32(1), x); }
static usz pageSizeV; static usz pageSizeV;
usz getPageSize() { usz getPageSize() {
#if defined(_WIN32) || defined(_WIN64)
err("getPageSize unimplemented on Windows");
#else
if (pageSizeV==0) pageSizeV = sysconf(_SC_PAGESIZE); if (pageSizeV==0) pageSizeV = sysconf(_SC_PAGESIZE);
return pageSizeV; return pageSizeV;
#endif
} }
static void allocStack(void** curr, void** start, void** end, i32 elSize, i32 count) { static void allocStack(void** curr, void** start, void** end, i32 elSize, i32 count) {
usz ps = getPageSize(); usz ps = getPageSize();

View File

@ -1,9 +1,6 @@
#ifndef REALPATH_H #ifndef REALPATH_H
#define REALPATH_H #define REALPATH_H
#define S_ISLNK(m) (0)
#define S_ISSOCK(m) (0)
char* realpath (const char *__restrict path, char *__restrict resolved_path); char* realpath (const char *__restrict path, char *__restrict resolved_path);
#endif /* REALPATH_H */ #endif /* REALPATH_H */

View File

@ -1,6 +0,0 @@
#include "sysconf.h"
long int sysconf (int in) {
return 1L;
}

View File

@ -1,8 +0,0 @@
#ifndef SYSCONF_H
#define SYSCONF_H
#define _SC_PAGESIZE 8
long int sysconf (int in);
#endif /* SYSCONF_H */