remove duplicated definitions
This commit is contained in:
+1
-64
@@ -33,26 +33,8 @@ fn void osSleepMicroseconds(u32 t) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Files
|
// Files
|
||||||
fn bool osFileExists(String filename) {
|
|
||||||
bool result = access((str)filename.bytes, F_OK) == 0;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn String osFileRead(Arena* arena, ptr filepath) {
|
|
||||||
struct stat st;
|
|
||||||
stat(filepath, &st);
|
|
||||||
String result = { st.st_size, st.st_size, 0 };
|
|
||||||
result.bytes = arenaAlloc(arena, st.st_size);
|
|
||||||
|
|
||||||
size_t handle = open(filepath, O_RDWR, S_IRUSR | S_IRGRP | S_IROTH);
|
|
||||||
read(handle, result.bytes, st.st_size);
|
|
||||||
close(handle);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn bool osFileCreate(String filename) {
|
|
||||||
/*
|
/*
|
||||||
|
fn bool osFileCreate(String filename) {
|
||||||
M_Scratch scratch = scratch_get();
|
M_Scratch scratch = scratch_get();
|
||||||
string nt = str_copy(&scratch.arena, filename);
|
string nt = str_copy(&scratch.arena, filename);
|
||||||
bool result = true;
|
bool result = true;
|
||||||
@@ -63,7 +45,6 @@ fn bool osFileCreate(String filename) {
|
|||||||
scratch_return(&scratch);
|
scratch_return(&scratch);
|
||||||
close(handle);
|
close(handle);
|
||||||
return true;
|
return true;
|
||||||
*/
|
|
||||||
bool result = true;
|
bool result = true;
|
||||||
size_t handle = open((str)filename.bytes, O_RDWR | O_CREAT, S_IRUSR | S_IRGRP | S_IROTH);
|
size_t handle = open((str)filename.bytes, O_RDWR | O_CREAT, S_IRUSR | S_IRGRP | S_IROTH);
|
||||||
if (handle == -1) {
|
if (handle == -1) {
|
||||||
@@ -74,51 +55,7 @@ fn bool osFileCreate(String filename) {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bool osFileCreateWrite(String filename, String data) {
|
|
||||||
/*
|
|
||||||
M_Scratch scratch = scratch_get();
|
|
||||||
string nt = str_copy(&scratch.arena, filename);
|
|
||||||
b32 result = true;
|
|
||||||
size_t handle =
|
|
||||||
open((const char*) nt.str, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IRGRP | S_IROTH);
|
|
||||||
if (handle == -1) result = false;
|
|
||||||
write(handle, data.str, data.size);
|
|
||||||
close(handle);
|
|
||||||
scratch_return(&scratch);
|
|
||||||
return result;
|
|
||||||
*/
|
*/
|
||||||
bool result = true;
|
|
||||||
size_t handle = open(
|
|
||||||
(str)filename.bytes,
|
|
||||||
O_RDWR | O_CREAT | O_TRUNC,
|
|
||||||
S_IRUSR | S_IRGRP | S_IROTH
|
|
||||||
);
|
|
||||||
if (handle == -1) result = false;
|
|
||||||
write(handle, data.bytes, data.length);
|
|
||||||
close(handle);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn bool osFileWrite(String filename, String data) {
|
|
||||||
/*
|
|
||||||
M_Scratch scratch = scratch_get();
|
|
||||||
string nt = str_copy(&scratch.arena, filename);
|
|
||||||
b32 result = true;
|
|
||||||
size_t handle =
|
|
||||||
open((const char*) nt.str, O_RDWR | O_TRUNC, S_IRUSR | S_IRGRP | S_IROTH);
|
|
||||||
if (handle == -1) result = false;
|
|
||||||
write(handle, data.str, data.size);
|
|
||||||
close(handle);
|
|
||||||
*/
|
|
||||||
bool result = true;
|
|
||||||
size_t handle = open((str) filename.bytes, O_RDWR | O_TRUNC, S_IRUSR | S_IRGRP | S_IROTH);
|
|
||||||
if (handle == -1) result = false;
|
|
||||||
write(handle, data.bytes, data.length);
|
|
||||||
close(handle);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Misc
|
// Misc
|
||||||
fn void osDebugPrint(bool debug_mode, const char * format, ... ) {
|
fn void osDebugPrint(bool debug_mode, const char * format, ... ) {
|
||||||
|
|||||||
Reference in New Issue
Block a user