Blender V5.0
fsmenu_system.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cstdio>
10#include <cstdlib>
11#include <cstring>
12
13#include "MEM_guardedalloc.h"
14
15#include "BLI_fileops.h"
16#include "BLI_ghash.h"
17#include "BLI_listbase.h"
18#include "BLI_path_utils.hh"
19#include "BLI_string.h"
20#include "BLI_utildefines.h"
21
22#include "DNA_userdef_types.h"
23
24#include "BLT_translation.hh"
25
26#include "ED_fileselect.hh"
27
28#ifdef WIN32
29# include "utfconv.hh"
30
31/* Need to include windows.h so _WIN32_IE is defined. */
32# include <windows.h>
33/* For SHGetSpecialFolderPath, has to be done before BLI_winstuff
34 * because 'near' is disabled through BLI_windstuff. */
35# include "BLI_winstuff.h"
36# include <comdef.h>
37# include <comutil.h>
38# include <shlobj.h>
39# include <shlwapi.h>
40# include <wrl.h>
41#endif
42
43#include "UI_resources.hh"
44
45#ifdef __APPLE__
46# include <Carbon/Carbon.h>
47#endif /* __APPLE__ */
48
49#ifdef __linux__
50# include "BLI_fileops_types.h"
51# include <mntent.h>
52#endif
53
54#include "fsmenu.h"
55
56#ifdef __linux__
57# include "CLG_log.h"
58static CLG_LogRef LOG = {"system.path"};
59#endif
60
61struct FSMenu;
62
63/* -------------------------------------------------------------------- */
68
73static GHash *fsmenu_xdg_user_dirs_parse(const char *home)
74{
75 /* Add to the default for variable, equals & quotes. */
76 char l[128 + FILE_MAXDIR];
77 FILE *fp;
78
79 /* Check if the config file exists. */
80 {
81 char filepath[FILE_MAX];
82 const char *xdg_config_home = getenv("XDG_CONFIG_HOME");
83 if (xdg_config_home != nullptr) {
84 BLI_path_join(filepath, sizeof(filepath), xdg_config_home, "user-dirs.dirs");
85 }
86 else {
87 BLI_path_join(filepath, sizeof(filepath), home, ".config", "user-dirs.dirs");
88 }
89 fp = BLI_fopen(filepath, "r");
90 if (!fp) {
91 return nullptr;
92 }
93 }
94 /* By default there are 8 paths. */
95 GHash *xdg_map = BLI_ghash_str_new_ex(__func__, 8);
96 while (fgets(l, sizeof(l), fp) != nullptr) { /* read a line */
97
98 /* Avoid inserting invalid values. */
99 if (STRPREFIX(l, "XDG_")) {
100 char *l_value = strchr(l, '=');
101 if (l_value != nullptr) {
102 *l_value = '\0';
103 l_value++;
104
105 BLI_str_rstrip(l_value);
106 const uint l_value_len = strlen(l_value);
107 if ((l_value[0] == '"') && (l_value_len > 0) && (l_value[l_value_len - 1] == '"')) {
108 l_value[l_value_len - 1] = '\0';
109 l_value++;
110
111 char l_value_expanded[FILE_MAX];
112 char *l_value_final = l_value;
113
114 /* This is currently the only variable used.
115 * Based on the 'user-dirs.dirs' man page,
116 * there is no need to resolve arbitrary environment variables. */
117 if (STRPREFIX(l_value, "$HOME" SEP_STR)) {
118 BLI_path_join(l_value_expanded, sizeof(l_value_expanded), home, l_value + 6);
119 l_value_final = l_value_expanded;
120 }
121
122 BLI_ghash_insert(xdg_map, BLI_strdup(l), BLI_strdup(l_value_final));
123 }
124 }
125 }
126 }
127 fclose(fp);
128
129 return xdg_map;
130}
131
132static void fsmenu_xdg_user_dirs_free(GHash *xdg_map)
133{
134 if (xdg_map != nullptr) {
136 }
137}
138
147static void fsmenu_xdg_insert_entry(GHash *xdg_map,
148 FSMenu *fsmenu,
149 const char *key,
150 const char *default_path,
151 int icon,
152 const char *home)
153{
154 char xdg_path_buf[FILE_MAXDIR];
155 const char *xdg_path = (const char *)(xdg_map ? BLI_ghash_lookup(xdg_map, key) : nullptr);
156 if (xdg_path == nullptr) {
157 BLI_path_join(xdg_path_buf, sizeof(xdg_path_buf), home, default_path);
158 xdg_path = xdg_path_buf;
159 }
161 fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, xdg_path, N_(default_path), icon, FS_INSERT_LAST);
162}
163
165
166#ifdef WIN32
167/* Add Windows Quick Access items to the System list. */
168static void fsmenu_add_windows_quick_access(FSMenu *fsmenu,
169 FSMenuCategory category,
171{
172 Microsoft::WRL::ComPtr<IShellDispatch> shell;
173 if (CoCreateInstance(CLSID_Shell, nullptr, CLSCTX_ALL, IID_PPV_ARGS(shell.GetAddressOf())) !=
174 S_OK)
175 {
176 return;
177 }
178
179 /* Open Quick Access folder. */
180 Microsoft::WRL::ComPtr<Folder> dir;
181 if (shell->NameSpace(_variant_t(L"shell:::{679f85cb-0220-4080-b29b-5540cc05aab6}"),
182 dir.GetAddressOf()) != S_OK)
183 {
184 return;
185 }
186
187 /* Get FolderItems. */
188 Microsoft::WRL::ComPtr<FolderItems> items;
189 if (dir->Items(items.GetAddressOf()) != S_OK) {
190 return;
191 }
192
193 long count = 0;
194 if (items->get_Count(&count) != S_OK) {
195 return;
196 }
197
198 /* Iterate through the folder. */
199 for (long i = 0; i < count; i++) {
200 Microsoft::WRL::ComPtr<FolderItem> item;
201
202 if (items->Item(_variant_t(i), item.GetAddressOf()) != S_OK) {
203 continue;
204 }
205
206 VARIANT_BOOL isFolder;
207 /* Skip if it's not a folder. */
208 if (item->get_IsFolder(&isFolder) != S_OK || isFolder == VARIANT_FALSE) {
209 continue;
210 }
211
212 _bstr_t path;
213 if (item->get_Path(path.GetAddress()) != S_OK) {
214 continue;
215 }
216
217 char utf_path[FILE_MAXDIR];
218 conv_utf_16_to_8(path, utf_path, FILE_MAXDIR);
219
220 /* Despite the above IsFolder check, Windows considers libraries and archives to be folders.
221 * However, as Blender does not support opening them, they must be filtered out. #138863. */
222 const char *ext_folderlike[] = {
223 ".library-ms",
224 ".zip",
225 ".rar",
226 ".7z",
227 ".tar",
228 ".gz",
229 ".bz2",
230 ".zst",
231 ".xz",
232 ".cab",
233 ".iso",
234 nullptr,
235 };
236 if (!BLI_path_extension_check_array(utf_path, ext_folderlike)) {
237 /* Add folder to the fsmenu. */
238 fsmenu_insert_entry(fsmenu, category, utf_path, NULL, ICON_FILE_FOLDER, flag);
239 }
240 }
241}
242
243/* Add a Windows known folder path to the System list. */
244static void fsmenu_add_windows_folder(FSMenu *fsmenu,
245 FSMenuCategory category,
246 REFKNOWNFOLDERID rfid,
247 const char *name,
248 const int icon,
250{
251 LPWSTR pPath;
252 char line[FILE_MAXDIR];
253 if (SHGetKnownFolderPath(rfid, 0, nullptr, &pPath) == S_OK) {
254 conv_utf_16_to_8(pPath, line, FILE_MAXDIR);
255 fsmenu_insert_entry(fsmenu, category, line, name, icon, flag);
256 }
257 CoTaskMemFree(pPath);
258}
259#endif
260
261void fsmenu_read_system(FSMenu *fsmenu, int read_bookmarks)
262{
263 char line[FILE_MAXDIR];
264#ifdef WIN32
265 /* Add the drive names to the listing */
266 {
267 wchar_t wline[FILE_MAXDIR];
268 __int64 tmp;
269 char tmps[4], *name;
270
271 tmp = GetLogicalDrives();
272
273 for (int i = 0; i < 26; i++) {
274 if ((tmp >> i) & 1) {
275 tmps[0] = 'A' + i;
276 tmps[1] = ':';
277 tmps[2] = '\\';
278 tmps[3] = '\0';
279 name = nullptr;
280
281 /* Skip over floppy disks A & B. */
282 if (i > 1) {
283 /* Friendly volume descriptions without using SHGetFileInfoW (#85689). */
284 conv_utf_8_to_16(tmps, wline, 4);
285 IShellFolder *desktop;
286 if (SHGetDesktopFolder(&desktop) == S_OK) {
287 PIDLIST_RELATIVE volume;
288 if (desktop->ParseDisplayName(nullptr, nullptr, wline, nullptr, &volume, nullptr) ==
289 S_OK)
290 {
291 STRRET volume_name;
292 volume_name.uType = STRRET_WSTR;
293 if (desktop->GetDisplayNameOf(volume, SHGDN_FORADDRESSBAR, &volume_name) == S_OK) {
294 wchar_t *volume_name_wchar;
295 if (StrRetToStrW(&volume_name, volume, &volume_name_wchar) == S_OK) {
296 conv_utf_16_to_8(volume_name_wchar, line, FILE_MAXDIR);
297 name = line;
298 CoTaskMemFree(volume_name_wchar);
299 }
300 }
301 CoTaskMemFree(volume);
302 }
303 desktop->Release();
304 }
305 }
306 if (name == nullptr) {
307 name = tmps;
308 }
309
310 int icon = ICON_DISK_DRIVE;
311 switch (GetDriveType(tmps)) {
312 case DRIVE_REMOVABLE:
313 icon = ICON_EXTERNAL_DRIVE;
314 break;
315 case DRIVE_CDROM:
316 icon = ICON_DISC;
317 break;
318 case DRIVE_FIXED:
319 case DRIVE_RAMDISK:
320 icon = ICON_DISK_DRIVE;
321 break;
322 case DRIVE_REMOTE:
323 icon = ICON_NETWORK_DRIVE;
324 break;
325 }
326
329 }
330 }
331
332 /* Get Special Folder Locations. */
333 if (read_bookmarks) {
334
335 /* These items are shown in System List. */
336 fsmenu_add_windows_folder(fsmenu,
338 FOLDERID_Profile,
339 N_("Home"),
340 ICON_HOME,
342 fsmenu_add_windows_folder(fsmenu,
344 FOLDERID_Desktop,
345 N_("Desktop"),
346 ICON_DESKTOP,
348 fsmenu_add_windows_folder(fsmenu,
350 FOLDERID_Documents,
351 N_("Documents"),
352 ICON_DOCUMENTS,
354 fsmenu_add_windows_folder(fsmenu,
356 FOLDERID_Downloads,
357 N_("Downloads"),
358 ICON_IMPORT,
360 fsmenu_add_windows_folder(fsmenu,
362 FOLDERID_Music,
363 N_("Music"),
364 ICON_FILE_SOUND,
366 fsmenu_add_windows_folder(fsmenu,
368 FOLDERID_Pictures,
369 N_("Pictures"),
370 ICON_FILE_IMAGE,
372 fsmenu_add_windows_folder(fsmenu,
374 FOLDERID_Videos,
375 N_("Videos"),
376 ICON_FILE_MOVIE,
378 fsmenu_add_windows_folder(fsmenu,
380 FOLDERID_Fonts,
381 N_("Fonts"),
382 ICON_FILE_FONT,
384 fsmenu_add_windows_folder(fsmenu,
386 FOLDERID_SkyDrive,
387 N_("OneDrive"),
388 ICON_INTERNET,
390
391 /* These items are just put in path cache for thumbnail views and if bookmarked. */
392 fsmenu_add_windows_folder(fsmenu,
394 FOLDERID_UserProfiles,
395 nullptr,
396 ICON_COMMUNITY,
398
399 /* Last add Quick Access items to avoid duplicates and use icons if available. */
400 fsmenu_add_windows_quick_access(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, FS_INSERT_LAST);
401 }
402 }
403#elif defined(__APPLE__)
404 {
405 /* We store some known macOS system paths and corresponding icons
406 * and names in the FS_CATEGORY_OTHER (not displayed directly) category. */
408 fsmenu, FS_CATEGORY_OTHER, "/Library/Fonts/", N_("Fonts"), ICON_FILE_FONT, FS_INSERT_LAST);
409 fsmenu_insert_entry(fsmenu,
411 "/Applications/",
412 N_("Applications"),
413 ICON_FILE_FOLDER,
415
416 const char *home = BLI_dir_home();
417 if (home) {
418# define FS_MACOS_PATH(path, name, icon) \
419\
420 SNPRINTF(line, path, home); \
421\
422 fsmenu_insert_entry(fsmenu, FS_CATEGORY_OTHER, line, name, icon, FS_INSERT_LAST);
423
424 FS_MACOS_PATH("%s/", nullptr, ICON_HOME)
425 FS_MACOS_PATH("%s/Desktop/", N_("Desktop"), ICON_DESKTOP)
426 FS_MACOS_PATH("%s/Documents/", N_("Documents"), ICON_DOCUMENTS)
427 FS_MACOS_PATH("%s/Downloads/", N_("Downloads"), ICON_IMPORT)
428 FS_MACOS_PATH("%s/Movies/", N_("Movies"), ICON_FILE_MOVIE)
429 FS_MACOS_PATH("%s/Music/", N_("Music"), ICON_FILE_SOUND)
430 FS_MACOS_PATH("%s/Pictures/", N_("Pictures"), ICON_FILE_IMAGE)
431 FS_MACOS_PATH("%s/Library/Fonts/", N_("Fonts"), ICON_FILE_FONT)
432
433# undef FS_MACOS_PATH
434 }
435
436 /* Get mounted volumes better method OSX 10.6 and higher, see:
437 * https://developer.apple.com/library/mac/#documentation/CoreFoundation/Reference/CFURLRef/Reference/reference.html
438 */
439
440 /* We get all volumes sorted including network and do not relay
441 * on user-defined finder visibility, less confusing. */
442
443 CFURLRef cfURL = nullptr;
444 CFURLEnumeratorResult result = kCFURLEnumeratorSuccess;
445 CFURLEnumeratorRef volEnum = CFURLEnumeratorCreateForMountedVolumes(
446 nullptr, kCFURLEnumeratorSkipInvisibles, nullptr);
447
448 while (result != kCFURLEnumeratorEnd) {
449 char defPath[FILE_MAX];
450
451 result = CFURLEnumeratorGetNextURL(volEnum, &cfURL, nullptr);
452 if (result != kCFURLEnumeratorSuccess) {
453 continue;
454 }
455
456 CFURLGetFileSystemRepresentation(cfURL, false, (UInt8 *)defPath, FILE_MAX);
457
458 /* Get name of the volume. */
459 char display_name[FILE_MAXFILE] = "";
460 CFStringRef nameString = nullptr;
461 CFURLCopyResourcePropertyForKey(cfURL, kCFURLVolumeLocalizedNameKey, &nameString, nullptr);
462 if (nameString != nullptr) {
463 CFStringGetCString(nameString, display_name, sizeof(display_name), kCFStringEncodingUTF8);
464 CFRelease(nameString);
465 }
466
467 /* Set icon for regular, removable or network drive. */
468 int icon = ICON_DISK_DRIVE;
469 CFBooleanRef localKey = nullptr;
470 CFURLCopyResourcePropertyForKey(cfURL, kCFURLVolumeIsLocalKey, &localKey, nullptr);
471 if (localKey != nullptr) {
472 if (!CFBooleanGetValue(localKey)) {
473 icon = ICON_NETWORK_DRIVE;
474 }
475 else {
476 CFBooleanRef ejectableKey = nullptr;
477 CFURLCopyResourcePropertyForKey(
478 cfURL, kCFURLVolumeIsEjectableKey, &ejectableKey, nullptr);
479 if (ejectableKey != nullptr) {
480 if (CFBooleanGetValue(ejectableKey)) {
481 icon = ICON_EXTERNAL_DRIVE;
482 }
483 CFRelease(ejectableKey);
484 }
485 }
486 CFRelease(localKey);
487 }
488
489 fsmenu_insert_entry(fsmenu,
491 defPath,
492 display_name[0] ? display_name : nullptr,
493 icon,
495 }
496
497 CFRelease(volEnum);
498
499/* kLSSharedFileListFavoriteItems is deprecated, but available till macOS 10.15.
500 * Will have to find a new method to sync the Finder Favorites with File Browser. */
501# pragma GCC diagnostic push
502# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
503 /* Finally get user favorite places */
504 if (read_bookmarks) {
505 UInt32 seed;
506 LSSharedFileListRef list = LSSharedFileListCreate(
507 nullptr, kLSSharedFileListFavoriteItems, nullptr);
508 CFArrayRef pathesArray = LSSharedFileListCopySnapshot(list, &seed);
509 CFIndex pathesCount = CFArrayGetCount(pathesArray);
510
511 for (CFIndex i = 0; i < pathesCount; i++) {
512 LSSharedFileListItemRef itemRef = (LSSharedFileListItemRef)CFArrayGetValueAtIndex(
513 pathesArray, i);
514
515 CFURLRef cfURL = nullptr;
516 OSErr err = LSSharedFileListItemResolve(itemRef,
517 kLSSharedFileListNoUserInteraction |
518 kLSSharedFileListDoNotMountVolumes,
519 &cfURL,
520 nullptr);
521 if (err != noErr || !cfURL) {
522 continue;
523 }
524
525 CFStringRef pathString = CFURLCopyFileSystemPath(cfURL, kCFURLPOSIXPathStyle);
526
527 if (pathString == nullptr ||
528 !CFStringGetCString(pathString, line, sizeof(line), kCFStringEncodingUTF8))
529 {
530 continue;
531 }
532
533 /* Exclude "all my files" as it makes no sense in blender file-selector. */
534 /* Exclude "airdrop" if WLAN not active as it would show "". */
535 if (!strstr(line, "myDocuments.cannedSearch") && (*line != '\0')) {
536 fsmenu_insert_entry(fsmenu,
538 line,
539 nullptr,
540 ICON_FILE_FOLDER,
542 }
543
544 CFRelease(pathString);
545 CFRelease(cfURL);
546 }
547
548 CFRelease(pathesArray);
549 CFRelease(list);
550 }
551# pragma GCC diagnostic pop
552 }
553#else /* `!defined(WIN32) && !defined(__APPLE__)` */
554 /* Generic Unix. */
555 {
556 const char *home = BLI_dir_home();
557
558 if (read_bookmarks && home) {
559
561 fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, home, N_("Home"), ICON_HOME, FS_INSERT_LAST);
562
563 /* Follow the XDG spec, check if these are available. */
564 GHash *xdg_map = fsmenu_xdg_user_dirs_parse(home);
565
566 struct {
567 const char *key;
568 const char *default_path;
569 BIFIconID icon;
570 } xdg_items[] = {
571 {"XDG_DESKTOP_DIR", "Desktop", ICON_DESKTOP},
572 {"XDG_DOCUMENTS_DIR", "Documents", ICON_DOCUMENTS},
573 {"XDG_DOWNLOAD_DIR", "Downloads", ICON_IMPORT},
574 {"XDG_VIDEOS_DIR", "Videos", ICON_FILE_MOVIE},
575 {"XDG_PICTURES_DIR", "Pictures", ICON_FILE_IMAGE},
576 {"XDG_MUSIC_DIR", "Music", ICON_FILE_SOUND},
577 };
578
579 for (int i = 0; i < ARRAY_SIZE(xdg_items); i++) {
581 xdg_map, fsmenu, xdg_items[i].key, xdg_items[i].default_path, xdg_items[i].icon, home);
582 }
583
585 }
586
587 {
588 bool found = false;
589# ifdef __linux__
590 /* loop over mount points */
591 mntent *mnt;
592 FILE *fp;
593
594 fp = setmntent(MOUNTED, "r");
595 if (fp == nullptr) {
596 CLOG_WARN(&LOG, "Could not get a list of mounted file-systems");
597 }
598 else {
599
600 /* Similar to `STRPREFIX`,
601 * but ensures the prefix precedes a directory separator or null terminator.
602 * Define locally since it's fairly specific to this particular use case. */
603 auto strncmp_dir_delimit = [](const char *a, const char *b, size_t b_len) -> int {
604 const int result = strncmp(a, b, b_len);
605 return (result == 0 && !ELEM(a[b_len], '\0', '/')) ? 1 : result;
606 };
607# define STRPREFIX_DIR_DELIMIT(a, b) (strncmp_dir_delimit((a), (b), strlen(b)) == 0)
608
609 while ((mnt = getmntent(fp))) {
610 if (STRPREFIX_DIR_DELIMIT(mnt->mnt_dir, "/boot") ||
611 /* According to: https://wiki.archlinux.org/title/EFI_system_partition (2025),
612 * this is a common path to mount the EFI partition. */
613 STRPREFIX_DIR_DELIMIT(mnt->mnt_dir, "/efi"))
614 {
615 /* Hide share not usable to the user. */
616 continue;
617 }
618 if (!STRPREFIX_DIR_DELIMIT(mnt->mnt_fsname, "/dev")) {
619 continue;
620 }
621 /* Use non-delimited prefix since a slash isn't expected after loop. */
622 if (STRPREFIX(mnt->mnt_fsname, "/dev/loop")) {
623 /* The `/dev/loop*` entries are SNAPS used by desktop environment
624 * (GNOME) no need for them to show up in the list. */
625 continue;
626 }
627
628 fsmenu_insert_entry(fsmenu,
630 mnt->mnt_dir,
631 nullptr,
632 ICON_DISK_DRIVE,
634
635 found = true;
636 }
637# undef STRPREFIX_DIR_DELIMIT
638
639 if (endmntent(fp) == 0) {
640 CLOG_WARN(&LOG, "Could not close the list of mounted file-systems");
641 }
642 }
643 /* Check `gvfs` shares. */
644 const char *const xdg_runtime_dir = BLI_getenv("XDG_RUNTIME_DIR");
645 if (xdg_runtime_dir != nullptr) {
646 direntry *dirs;
647 char filepath[FILE_MAX];
648 BLI_path_join(filepath, sizeof(filepath), xdg_runtime_dir, "gvfs/");
649 /* Avoid error message if the directory doesn't exist as this isn't a requirement. */
650 if (BLI_is_dir(filepath)) {
651 const uint dirs_num = BLI_filelist_dir_contents(filepath, &dirs);
652 for (uint i = 0; i < dirs_num; i++) {
653 if ((dirs[i].type & S_IFDIR) == 0) {
654 continue;
655 }
656 const char *dirname = dirs[i].relname;
657 if (dirname[0] == '.') {
658 continue;
659 }
660
661 /* Directory names contain a lot of unwanted text.
662 * Assuming every entry ends with the share name. */
663 const char *label = strstr(dirname, "share=");
664 if (label != nullptr) {
665 /* Move pointer so `share=` is trimmed off or use full `dirname` as label. */
666 const char *label_test = label + 6;
667 label = *label_test ? label_test : dirname;
668 }
669 SNPRINTF(line, "%s%s", filepath, dirname);
671 fsmenu, FS_CATEGORY_SYSTEM, line, label, ICON_NETWORK_DRIVE, FS_INSERT_SORTED);
672 found = true;
673 }
674 BLI_filelist_free(dirs, dirs_num);
675 }
676 }
677# endif /* __linux__ */
678
679 /* fallback */
680 if (!found) {
682 fsmenu, FS_CATEGORY_SYSTEM, "/", nullptr, ICON_DISK_DRIVE, FS_INSERT_SORTED);
683 }
684 }
685 }
686#endif
687
688#if defined(__APPLE__)
689 /* Quiet warnings. */
691#endif
692
693/* For all platforms, we add some directories from User Preferences to
694 * the FS_CATEGORY_OTHER category so that these directories
695 * have the appropriate icons when they are added to the Bookmarks.
696 *
697 * NOTE: of the preferences support as `//` prefix.
698 * Skip them since they depend on the current loaded blend file. */
699#define FS_UDIR_PATH(dir, icon) \
700 if (dir[0] && !BLI_path_is_rel(dir)) { \
701 fsmenu_insert_entry(fsmenu, FS_CATEGORY_OTHER, dir, nullptr, icon, FS_INSERT_LAST); \
702 }
703
704 FS_UDIR_PATH(U.fontdir, ICON_FILE_FONT)
705 FS_UDIR_PATH(U.textudir, ICON_FILE_IMAGE)
706 LISTBASE_FOREACH (bUserScriptDirectory *, script_dir, &U.script_directories) {
707 if (UNLIKELY(script_dir->dir_path[0] == '\0')) {
708 continue;
709 }
710 fsmenu_insert_entry(fsmenu,
712 script_dir->dir_path,
713 script_dir->name,
714 ICON_FILE_SCRIPT,
716 }
717 FS_UDIR_PATH(U.sounddir, ICON_FILE_SOUND)
718 FS_UDIR_PATH(U.tempdir, ICON_TEMP)
719
720#undef FS_UDIR_PATH
721}
File and directory operations.
FILE * BLI_fopen(const char *filepath, const char *mode) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
unsigned int BLI_filelist_dir_contents(const char *dirname, struct direntry **r_filelist)
bool BLI_is_dir(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition storage.cc:443
void BLI_filelist_free(struct direntry *filelist, unsigned int nrentries)
const char * BLI_dir_home(void)
Definition storage.cc:97
Some types for dealing with directories.
GHash * BLI_ghash_str_new_ex(const char *info, unsigned int nentries_reserve) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
void * BLI_ghash_lookup(const GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
Definition BLI_ghash.cc:731
void BLI_ghash_insert(GHash *gh, void *key, void *val)
Definition BLI_ghash.cc:707
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
Definition BLI_ghash.cc:860
#define LISTBASE_FOREACH(type, var, list)
#define FILE_MAXFILE
bool BLI_path_extension_check_array(const char *path, const char **ext_array) ATTR_NONNULL(1
#define FILE_MAX
#define BLI_path_join(...)
const char * BLI_getenv(const char *env) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
#define FILE_MAXDIR
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
Definition string.cc:41
void BLI_str_rstrip(char *str) ATTR_NONNULL(1)
Definition string.cc:980
#define SNPRINTF(dst, format,...)
Definition BLI_string.h:604
unsigned int uint
#define STRPREFIX(a, b)
#define ARRAY_SIZE(arr)
#define UNUSED_VARS(...)
#define UNLIKELY(x)
#define ELEM(...)
Compatibility-like things for windows.
const char * dirname(char *path)
#define CLOG_WARN(clg_ref,...)
Definition CLG_log.h:189
int BIFIconID
Definition ED_asset.hh:28
FSMenuCategory
@ FS_CATEGORY_SYSTEM_BOOKMARKS
@ FS_CATEGORY_OTHER
@ FS_CATEGORY_SYSTEM
FSMenuInsert
@ FS_INSERT_SORTED
@ FS_INSERT_LAST
Read Guarded memory(de)allocation.
#define U
ATTR_WARN_UNUSED_RESULT const BMLoop * l
static unsigned long seed
Definition btSoftBody.h:39
void fsmenu_insert_entry(FSMenu *fsmenu, FSMenuCategory category, const char *path, const char *name, int icon, FSMenuInsert flag)
Definition fsmenu.cc:227
static void fsmenu_xdg_insert_entry(GHash *xdg_map, FSMenu *fsmenu, const char *key, const char *default_path, int icon, const char *home)
void fsmenu_read_system(FSMenu *fsmenu, int read_bookmarks)
static void fsmenu_xdg_user_dirs_free(GHash *xdg_map)
#define FS_UDIR_PATH(dir, icon)
static GHash * fsmenu_xdg_user_dirs_parse(const char *home)
int count
#define LOG(level)
Definition log.h:97
void MEM_freeN(void *vmemh)
Definition mallocn.cc:113
#define L
const char * name
const char * relname
i
Definition text_draw.cc:230
#define SEP_STR
Definition unit.cc:39
int conv_utf_8_to_16(const char *in8, wchar_t *out16, size_t size16)
Definition utfconv.cc:182
int conv_utf_16_to_8(const wchar_t *in16, char *out8, size_t size8)
Definition utfconv.cc:116
#define N_(msgid)
uint8_t flag
Definition wm_window.cc:145