64 NSFileManager *file_manager = [NSFileManager defaultManager];
66 NSArray *resource_keys =
67 @[ NSURLVolumeLocalizedNameKey, NSURLVolumeIsLocalKey, NSURLVolumeIsRemovableKey ];
69 NSArray *mounted_volume_urls = [file_manager
70 mountedVolumeURLsIncludingResourceValuesForKeys:resource_keys
71 options:NSVolumeEnumerationSkipHiddenVolumes];
73 for (NSURL *volume_url
in mounted_volume_urls) {
75 NSDictionary *resources_values = [volume_url resourceValuesForKeys:resource_keys error:&error];
78 NSString *volume_name = resources_values[NSURLVolumeLocalizedNameKey];
79 NSNumber *volume_is_local = resources_values[NSURLVolumeIsLocalKey];
80 NSNumber *volume_is_ejectable = resources_values[NSURLVolumeIsRemovableKey];
83 int icon = ICON_DISK_DRIVE;
84 if (!volume_is_local.boolValue) {
85 icon = ICON_NETWORK_DRIVE;
87 else if (volume_is_ejectable.boolValue) {
88 icon = ICON_EXTERNAL_DRIVE;
93 volume_url.path.UTF8String,
94 volume_name.UTF8String,
104 "%s/Library/Mobile Documents/com~apple~CloudDocs/",
114 if (read_bookmarks) {
115#pragma GCC diagnostic push
116#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
117 LSSharedFileListRef shared_list = LSSharedFileListCreate(
118 nullptr, kLSSharedFileListFavoriteItems,
nullptr);
121 NSArray *paths_array = (__bridge NSArray *)LSSharedFileListCopySnapshot(shared_list, &seed);
123 for (
id item
in paths_array) {
124 LSSharedFileListItemRef item_ref = (__bridge LSSharedFileListItemRef)item;
126 CFURLRef cf_url =
nullptr;
127 OSErr err = LSSharedFileListItemResolve(item_ref,
128 kLSSharedFileListNoUserInteraction |
129 kLSSharedFileListDoNotMountVolumes,
132 if (err != noErr || !cf_url) {
136 NSURL *url = (__bridge NSURL *)cf_url;
137 NSString *path = [url path];
145 if (![path containsString:
@"myDocuments.cannedSearch"] && [path
length] > 0) {
157 [paths_array release];
158 CFRelease(shared_list);
159#pragma GCC diagnostic pop
void fsmenu_macos_insert_entry(FSMenu *fsmenu, const char *name, const char *default_path, const int icon, const char *home, const FSMenuCategory category=FS_CATEGORY_OTHER, const FSMenuInsert insert_flag=FS_INSERT_LAST)
void fsmenu_insert_entry(FSMenu *fsmenu, FSMenuCategory category, const char *path, const char *name, int icon, FSMenuInsert flag)