summaryrefslogtreecommitdiff
path: root/os-posix.c
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2023-09-24 10:16:17 -0400
committerpommicket <pommicket@gmail.com>2023-09-24 10:16:17 -0400
commitcdf94949a4a12b0f99d855dcfb113905ac8a90f4 (patch)
tree4e31091de296fd901c9b317cb4ac259f604270ee /os-posix.c
parentbf00aba72e89d4005c8a3b405bffa4c0a11d9c96 (diff)
don't truncate log on startup
Diffstat (limited to 'os-posix.c')
-rw-r--r--os-posix.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/os-posix.c b/os-posix.c
index 6b274fb..fa14584 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -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))) {