From cdf94949a4a12b0f99d855dcfb113905ac8a90f4 Mon Sep 17 00:00:00 2001 From: pommicket Date: Sun, 24 Sep 2023 10:16:17 -0400 Subject: don't truncate log on startup --- os-win.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'os-win.c') diff --git a/os-win.c b/os-win.c index 6a50122..1ee6fd6 100644 --- a/os-win.c +++ b/os-win.c @@ -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; -- cgit v1.2.3