add binary mode flag to fopen calls

This commit is contained in:
dzaima 2023-04-13 15:54:34 +03:00
parent 1db746ea77
commit 6239e2f2dd
2 changed files with 6 additions and 6 deletions

View File

@ -528,7 +528,7 @@ static void onJIT(Body* body, u8* binEx, u64 sz) {
#if USE_PERF
if (!perf_map) {
B s = m_c8vec_0("/tmp/perf-"); AFMT("%l.map", getpid());
perf_map = file_open(s, "open", "wa");
perf_map = file_open(s, "open", "wab");
printsB(s); printf(": map\n");
dec(s);
}
@ -609,7 +609,7 @@ Nvm_res m_nvm(Body* body) {
u32* origBC = body->bc;
u32 bodyOff = origBC - (u32*)body->bl->bc;
#if STORE_JIT_MAP
if (!jit_map) jit_map = fopen("cbqn-jit.bqn", "wa");
if (!jit_map) jit_map = fopen("cbqn-jit.bqn", "wab");
fprintf(jit_map, "{\n");
print_jit_line(body, NULL, body->bl->map[bodyOff]);
#endif

View File

@ -61,7 +61,7 @@ I8Arr* stream_bytes(FILE* f) {
}
I8Arr* path_bytes(B path) { // consumes
FILE* f = file_open(path, "read", "r");
FILE* f = file_open(path, "read", "rb");
int seekRes = fseek(f, 0, SEEK_END);
I8Arr* src;
if (seekRes==-1) {
@ -217,7 +217,7 @@ void free_chars(CharBuf b) {
}
void path_wChars(B path, B x) { // consumes path
FILE* f = file_open(path, "write to", "w");
FILE* f = file_open(path, "write to", "wb");
u64 len = utf8lenB(x);
TALLOC(char, val, len);
@ -241,7 +241,7 @@ void file_wBytes(FILE* f, B name, B x) {
free_chars(buf);
}
void path_wBytes(B path, B x) { // consumes path
FILE* f = file_open(path, "write to", "w");
FILE* f = file_open(path, "write to", "wb");
file_wBytes(f, path, x);
fclose(f);
dec(path);
@ -433,7 +433,7 @@ static u8 types_val[] = {
void cbqn_heapDump(char* name0) {
char* name = name0==NULL? "CBQNHeapDump" : name0;
FILE* f = fopen(name, "w");
FILE* f = fopen(name, "wb");
if (f==NULL) {
fprintf(stderr, "Failed to dump heap - could not open file for writing\n");
return;