Library collections

This commit is contained in:
Ginger Bill
2017-09-07 20:55:59 +01:00
parent 36e3a02f67
commit 8e3b77aba8
25 changed files with 303 additions and 129 deletions

View File

@@ -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