From 0d25d01e4109acbd0220216fcdc98bdc8fa92c90 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Sat, 2 Jan 2016 10:39:14 -1000 Subject: [PATCH] Relocate Win32 volume path hack --- hecl/include/HECL/HECL.hpp | 7 +++++ hecl/lib/HECL.cpp | 59 ++++---------------------------------- 2 files changed, 12 insertions(+), 54 deletions(-) diff --git a/hecl/include/HECL/HECL.hpp b/hecl/include/HECL/HECL.hpp index 48690f834..04f1ee747 100644 --- a/hecl/include/HECL/HECL.hpp +++ b/hecl/include/HECL/HECL.hpp @@ -303,6 +303,13 @@ static inline FILE* Fopen(const SystemChar* path, const SystemChar* mode, FileLo static inline int Stat(const SystemChar* path, Sstat* statOut) { #if HECL_UCS2 + size_t pos; + for (pos=0 ; pos<3 && path[pos] != L'\0' ; ++pos) {} + if (pos == 2 && path[1] == L':') + { + SystemChar fixPath[4] = {path[0], L':', L'/', L'\0'}; + return _wstat(fixPath, statOut); + } return _wstat(path, statOut); #else return stat(path, statOut); diff --git a/hecl/lib/HECL.cpp b/hecl/lib/HECL.cpp index 643314150..762cb8b9c 100644 --- a/hecl/lib/HECL.cpp +++ b/hecl/lib/HECL.cpp @@ -137,13 +137,6 @@ HECL::DirectoryEnumerator::DirectoryEnumerator(const HECL::SystemChar* path, Mod bool sizeSort, bool reverse, bool noHidden) { HECL::Sstat theStat; -#if _WIN32 - if (wcslen(path) == 2 && path[1] == L':') - { - if (HECL::Stat((std::wstring(path) + L'/').c_str(), &theStat)) - return; - } else -#endif if (HECL::Stat(path, &theStat) || !S_ISDIR(theStat.st_mode)) return; @@ -482,61 +475,19 @@ std::vector> GetSystemLocations() CFURLEnumeratorResult result = kCFURLEnumeratorSuccess; CFURLEnumeratorRef volEnum = CFURLEnumeratorCreateForMountedVolumes(NULL, kCFURLEnumeratorSkipInvisibles, NULL); - while (result != kCFURLEnumeratorEnd) { - unsigned char defPath[FILE_MAX]; + while (result != kCFURLEnumeratorEnd) + { + char defPath[MAXPATHLEN]; result = CFURLEnumeratorGetNextURL(volEnum, &cfURL, NULL); if (result != kCFURLEnumeratorSuccess) continue; - CFURLGetFileSystemRepresentation(cfURL, false, (UInt8 *)defPath, FILE_MAX); - fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, (char *)defPath, NULL, FS_INSERT_SORTED); + CFURLGetFileSystemRepresentation(cfURL, false, (UInt8 *)defPath, MAXPATHLEN); + ret.push_back(NameFromPath(defPath)); } CFRelease(volEnum); - - /* Finally get user favorite places */ - if (read_bookmarks) { - UInt32 seed; - OSErr err = noErr; - CFArrayRef pathesArray; - LSSharedFileListRef list; - LSSharedFileListItemRef itemRef; - CFIndex i, pathesCount; - CFURLRef cfURL = NULL; - CFStringRef pathString = NULL; - list = LSSharedFileListCreate(NULL, kLSSharedFileListFavoriteItems, NULL); - pathesArray = LSSharedFileListCopySnapshot(list, &seed); - pathesCount = CFArrayGetCount(pathesArray); - - for (i = 0; i < pathesCount; i++) { - itemRef = (LSSharedFileListItemRef)CFArrayGetValueAtIndex(pathesArray, i); - - err = LSSharedFileListItemResolve(itemRef, - kLSSharedFileListNoUserInteraction | - kLSSharedFileListDoNotMountVolumes, - &cfURL, NULL); - if (err != noErr) - continue; - - pathString = CFURLCopyFileSystemPath(cfURL, kCFURLPOSIXPathStyle); - - if (pathString == NULL || !CFStringGetCString(pathString, line, sizeof(line), kCFStringEncodingUTF8)) - continue; - - /* Exclude "all my files" as it makes no sense in blender fileselector */ - /* Exclude "airdrop" if wlan not active as it would show "" ) */ - if (!strstr(line, "myDocuments.cannedSearch") && (*line != '\0')) { - fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, NULL, FS_INSERT_LAST); - } - - CFRelease(pathString); - CFRelease(cfURL); - } - - CFRelease(pathesArray); - CFRelease(list); - } } #else /* unix */