aboutsummaryrefslogtreecommitdiff
path: root/src/common.cpp
diff options
context:
space:
mode:
authorGinger Bill <bill@gingerbill.org>2017-09-07 20:55:59 +0100
committerGinger Bill <bill@gingerbill.org>2017-09-07 20:55:59 +0100
commit8e3b77aba81a6bd71c7e8b23f09fc76474f401d7 (patch)
tree812e5e8fe937a8c3d7c8b3e5b931f9c7f8984c7d /src/common.cpp
parent36e3a02f67997131507c1d6b389317324e04a0b6 (diff)
Library collections
Diffstat (limited to 'src/common.cpp')
-rw-r--r--src/common.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/common.cpp b/src/common.cpp
index 06cb674dd..173ef4210 100644
--- a/src/common.cpp
+++ b/src/common.cpp
@@ -463,3 +463,31 @@ wchar_t **command_line_to_wargv(wchar_t *cmd_line, int *_argc) {
}
#endif
+
+
+#if defined(GB_SYSTEM_WINDOWS)
+ bool path_is_directory(String path) {
+ gbAllocator a = heap_allocator();
+ String16 wstr = string_to_string16(a, path);
+ defer (gb_free(a, wstr.text));
+
+ i32 attribs = GetFileAttributesW(wstr.text);
+ if (attribs < 0) return false;
+
+ return (attribs & FILE_ATTRIBUTE_DIRECTORY) != 0;
+ }
+
+#else
+ bool path_is_directory(String path) {
+ gbAllocator a = heap_allocator();
+ String copy = copy_string(a, path);
+ defer (gb_free(a, copy.text));
+
+ struct stat s;
+ if (stat(copy.text, &s) == 0) {
+ return (s.st_mode & S_IFDIR) != 0;
+ }
+ return false;
+ }
+#endif
+