diff options
author | Aaron Ball <nullspoon@oper.io> | 2023-05-25 10:56:00 -0600 |
---|---|---|
committer | Aaron Ball <nullspoon@oper.io> | 2023-05-25 10:56:00 -0600 |
commit | 3eddfa96781565ffe7b2b969a6ebbad9e53ad92e (patch) | |
tree | bc19259eea4c2083989a152ce0a18fd26e48be7e | |
parent | 8f5cfc8166773295b733fa6370ccabfbaf1b688d (diff) | |
parent | 722b646c0eccdbe2398c822583f6271c6066a6cb (diff) | |
download | oper.io-3eddfa96781565ffe7b2b969a6ebbad9e53ad92e.tar.gz oper.io-3eddfa96781565ffe7b2b969a6ebbad9e53ad92e.tar.xz |
Merge branch 'remove-file_exists'
-rw-r--r-- | src/common.c | 10 | ||||
-rw-r--r-- | src/common.h | 2 | ||||
-rw-r--r-- | src/main.c | 2 |
3 files changed, 1 insertions, 13 deletions
diff --git a/src/common.c b/src/common.c index 15d1eae..b103cfe 100644 --- a/src/common.c +++ b/src/common.c @@ -32,16 +32,6 @@ int catfile(char* path) { } -int file_exists(char* path) { - FILE* fd; - fd = fopen(path, "r"); - if(!fd) - return 2; - fclose(fd); - return 1; -} - - int html_read_title(char* path, char* out) { char buf[TITLE_MAX]; int start = 0; diff --git a/src/common.h b/src/common.h index 03529dd..aef4d87 100644 --- a/src/common.h +++ b/src/common.h @@ -26,8 +26,6 @@ int catfile(char*); -int file_exists(char*); - int html_read_title(char*, char*); char* runsh(char*); @@ -67,7 +67,7 @@ int main(int argc, char* argv[], char* envp[]) { // If the file does not exist, set status to 404 and set the page to be // printed to the 404 page. - if(file_exists(path) == 2) { + if(access(path, F_OK) != 0) { status = 404; sprintf(path, "%s/%s.html", posts, "404"); strcpy(title, ": 404"); |