diff options
author | pommicket <pommicket@gmail.com> | 2023-09-24 10:16:17 -0400 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2023-09-24 10:16:17 -0400 |
commit | cdf94949a4a12b0f99d855dcfb113905ac8a90f4 (patch) | |
tree | 4e31091de296fd901c9b317cb4ac259f604270ee /os-posix.c | |
parent | bf00aba72e89d4005c8a3b405bffa4c0a11d9c96 (diff) |
don't truncate log on startup
Diffstat (limited to 'os-posix.c')
-rw-r--r-- | os-posix.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -41,6 +41,14 @@ bool fs_file_exists(const char *path) { return fs_path_type(path) == FS_FILE; } +int64_t fs_file_size(const char *path) { + struct stat statbuf = {0}; + if (stat(path, &statbuf) == 0) + return statbuf.st_size; + else + return -1; +} + FsDirectoryEntry **fs_list_directory(const char *dirname) { FsDirectoryEntry **entries = NULL; DIR *dir = opendir(dirname); @@ -51,7 +59,7 @@ FsDirectoryEntry **fs_list_directory(const char *dirname) { if (fd != -1) { while (readdir(dir)) ++nentries; rewinddir(dir); - entries = (FsDirectoryEntry **)calloc(nentries+1, sizeof *entries); + entries = (FsDirectoryEntry **)calloc(nentries+1, sizeof (FsDirectoryEntry *)); if (entries) { size_t idx = 0; while ((ent = readdir(dir))) { |