Compare commits
3 Commits
d04aac567f
...
bf56984482
| Author | SHA1 | Date | |
|---|---|---|---|
| bf56984482 | |||
| 8eeaff4245 | |||
| a097d5aff9 |
@@ -85,3 +85,10 @@ typedef struct Result_ {
|
|||||||
Error_printAndExit(_rname(N).error);\
|
Error_printAndExit(_rname(N).error);\
|
||||||
};\
|
};\
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
|
#define try_stderrcode(CALL) do {\
|
||||||
|
int r = CALL;\
|
||||||
|
if(r != 0){\
|
||||||
|
Return RESULT_ERROR(strerror(r), false);\
|
||||||
|
}\
|
||||||
|
} while(0)
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
#include "tlibc/filesystem.h"
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
bool dir_exists(cstr path){
|
bool dir_exists(cstr path){
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
#include "tlibc/filesystem.h"
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
bool file_exists(cstr path){
|
bool file_exists(cstr path){
|
||||||
@@ -46,6 +45,8 @@ Result(FILE*) file_openOrCreateReadWrite(cstr file_name){
|
|||||||
return RESULT_VALUE(p, f);
|
return RESULT_VALUE(p, f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Result(i64) file_getSize(FILE* f){
|
Result(i64) file_getSize(FILE* f){
|
||||||
i64 r = IFWIN(_ftelli64, ftello64)(f);
|
i64 r = IFWIN(_ftelli64, ftello64)(f);
|
||||||
if(r < 0){
|
if(r < 0){
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#define _LARGEFILE64_SOURCE 1
|
||||||
#include "tlibc/filesystem.h"
|
#include "tlibc/filesystem.h"
|
||||||
#if TLIBC_FS_USE_WINDOWS_H
|
#if TLIBC_FS_USE_WINDOWS_H
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|||||||
@@ -14,12 +14,14 @@ str str_copy(str src){
|
|||||||
bool str_equals(str s0, str s1){
|
bool str_equals(str s0, str s1){
|
||||||
if(s0.size != s1.size)
|
if(s0.size != s1.size)
|
||||||
return false;
|
return false;
|
||||||
|
/*
|
||||||
for(u32 i = 0; i < s0.size; i++)
|
BENCHMARK:
|
||||||
if(s0.data[i] != s1.data[i])
|
str_equals64: 2.967s
|
||||||
return false;
|
strcmp: 4.143s
|
||||||
|
strncmp: 1.611s
|
||||||
return true;
|
memcmp: 0.710s
|
||||||
|
*/
|
||||||
|
return memcmp(s0.data, s1.data, s0.size) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
str str_reverse(str s){
|
str str_reverse(str s){
|
||||||
|
|||||||
Reference in New Issue
Block a user