Merge pull request #87 from vylsaz/develop

Implement some system values for Windows
This commit is contained in:
dzaima 2023-07-11 12:16:19 +03:00 committed by GitHub
commit 5b7330906a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 1 deletions

View File

@ -9,6 +9,7 @@
#include <unistd.h>
#if defined(_WIN32) || defined(_WIN64)
#include <windows.h>
#include "../windows/getline.c"
#endif
#include <errno.h>
@ -1151,6 +1152,26 @@ B tCharN_c1(B t, B x) {
fcntl(0, F_SETFL, 0);
return n>=0? m_c32(n) : m_f64(0);
}
#elif defined(_WIN32) || defined(_WIN64)
#include <conio.h>
B tRawMode_c1(B t, B x) {
HANDLE hIn = GetStdHandle(STD_INPUT_HANDLE);
DWORD dwMode;
GetConsoleMode(hIn, &dwMode);
if (o2b(x)) dwMode&= ~(ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT);
else dwMode|= ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT;
SetConsoleMode(hIn, dwMode);
return x;
}
B tCharN_c1(B t, B x) {
dec(x);
if (_kbhit()) {
int n = _getch();
return n>=0? m_c32(n) : m_f64(0);
} else {
return m_f64(0);
}
}
#else
B tRawMode_c1(B t, B x) { thrM("•term.RawMode not available"); }
B tCharN_c1(B t, B x) { thrM("•term.CharN not available"); }

View File

@ -7,6 +7,7 @@
#include <errno.h>
#if defined(_WIN32) || defined(_WIN64)
#include <direct.h>
#include "../windows/realpath.c"
#endif
@ -338,7 +339,7 @@ void mmap_init() { }
bool dir_create(B path) {
char* p = toCStr(path);
#if defined(_WIN32) || defined(_WIN64)
bool r = 0;
bool r = _mkdir(p) == 0;
#else
bool r = mkdir(p, S_IRWXU) == 0;
#endif