summaryrefslogtreecommitdiff
path: root/os-win.c
diff options
context:
space:
mode:
Diffstat (limited to 'os-win.c')
-rw-r--r--os-win.c17
1 files changed, 17 insertions, 0 deletions
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;