diff options
author | Harley Acheson <harley.acheson@gmail.com> | 2019-09-11 01:12:42 +0300 |
---|---|---|
committer | Harley Acheson <harley.acheson@gmail.com> | 2019-09-11 01:12:42 +0300 |
commit | 4ce3fbd52ae8bd054cfbac06ef3a1aea7568386b (patch) | |
tree | 6f6f3c94503e2f1d4ad63548424fd51b719ad2a3 /source/blender/editors/space_file | |
parent | fa12428ede9acc51b3ca1f2fbefb4cfb32d4d089 (diff) |
UI: File Browser Friendly Volume Descriptions
File Browser Volumes list gets nicer friendly drive names with volume label or device description.
Differential Revision: https://developer.blender.org/D5747
Reviewed by Brecht Van Lommel
Diffstat (limited to 'source/blender/editors/space_file')
-rw-r--r-- | source/blender/editors/space_file/fsmenu.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index c7a139a8b24..7faa2b883f2 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -492,20 +492,17 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) /* Flee from horrible win querying hover floppy drives! */ if (i > 1) { - /* Try to get volume label as well... */ + /* Try to get a friendly drive description. */ + SHFILEINFOW shFile = {0}; BLI_strncpy_wchar_from_utf8(wline, tmps, 4); - if (GetVolumeInformationW( - wline, wline + 4, FILE_MAXDIR - 4, NULL, NULL, NULL, NULL, 0)) { - size_t label_len; - - BLI_strncpy_wchar_as_utf8(line, wline + 4, FILE_MAXDIR - 4); - - label_len = MIN2(strlen(line), FILE_MAXDIR - 6); - BLI_snprintf(line + label_len, 6, " (%.2s)", tmps); - + if (SHGetFileInfoW(wline, 0, &shFile, sizeof(SHFILEINFOW), SHGFI_DISPLAYNAME)) { + BLI_strncpy_wchar_as_utf8(line, shFile.szDisplayName, FILE_MAXDIR); name = line; } } + if (name == NULL) { + name = tmps; + } fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, tmps, name, FS_INSERT_SORTED); } |