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-win.c | |
parent | bf00aba72e89d4005c8a3b405bffa4c0a11d9c96 (diff) |
don't truncate log on startup
Diffstat (limited to 'os-win.c')
-rw-r--r-- | os-win.c | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -36,6 +36,23 @@ bool fs_file_exists(const char *path) { return fs_path_type(path) == FS_FILE; } +int64_t fs_file_size(const char *path) { + WCHAR wide_path[4100]; + if (MultiByteToWideChar(CP_UTF8, 0, path, -1, wide_path, arr_count(wide_path)) == 0) + return -1; + HANDLE file = CreateFileW(wide_path, GENERIC_READ, + FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (file == INVALID_HANDLE_VALUE) + return -1; + int64_t size = -1; + LARGE_INTEGER large = {0}; + if (GetFileSizeEx(file, &large)) { + size = large.QuadPart; + } + CloseHandle(file); +} + FsDirectoryEntry **fs_list_directory(const char *dirname) { char file_pattern[4100]; FsDirectoryEntry **files = NULL; |