[vlc-commits] [Git][videolan/vlc][master] 3 commits: macosx: Clean up and clarify contents on media source generateChildNodesForDirectoryNode
Steve Lhomme (@robUx4)
gitlab at videolan.org
Wed Mar 12 05:46:27 UTC 2025
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
4381ac2e by Claudio Cambra at 2025-03-12T05:31:26+00:00
macosx: Clean up and clarify contents on media source generateChildNodesForDirectoryNode
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
bba4be8f by Claudio Cambra at 2025-03-12T05:31:26+00:00
macosx: Sort child urls for directory node
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
3398df33 by Claudio Cambra at 2025-03-12T05:31:26+00:00
macosx: Present directories first in browse view
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
1 changed file:
- modules/gui/macosx/library/media-source/VLCMediaSource.m
Changes:
=====================================
modules/gui/macosx/library/media-source/VLCMediaSource.m
=====================================
@@ -411,9 +411,10 @@ static const char *const myFoldersDescription = "My Folders";
});
}
-- (void)generateChildNodesForDirectoryNode:(input_item_node_t*)directoryNode withUrl:(NSURL*)directoryUrl
+- (void)generateChildNodesForDirectoryNode:(input_item_node_t *)directoryNode
+ withUrl:(NSURL *)directoryUrl
{
- if(directoryNode == NULL || directoryUrl == nil) {
+ if (directoryNode == NULL || directoryUrl == nil) {
return;
}
@@ -425,16 +426,37 @@ static const char *const myFoldersDescription = "My Folders";
}
NSError *error;
- NSArray<NSURL *> *subDirectories = [[NSFileManager defaultManager] contentsOfDirectoryAtURL:directoryUrl
- includingPropertiesForKeys:@[NSURLIsDirectoryKey]
- options:NSDirectoryEnumerationSkipsHiddenFiles | NSDirectoryEnumerationSkipsSubdirectoryDescendants
- error:&error];
- if (subDirectories == nil || subDirectories.count == 0 || error) {
+ const NSDirectoryEnumerationOptions options =
+ NSDirectoryEnumerationSkipsHiddenFiles | NSDirectoryEnumerationSkipsSubdirectoryDescendants;
+ NSArray<NSURLResourceKey> * const keys = @[NSURLIsDirectoryKey];
+ NSArray<NSURL *> *children =
+ [NSFileManager.defaultManager contentsOfDirectoryAtURL:directoryUrl
+ includingPropertiesForKeys:keys
+ options:options
+ error:&error];
+
+ if (children == nil || children.count == 0 || error) {
NSLog(@"Failed to get directories: %@.", error);
return;
}
- for (NSURL * const url in subDirectories) {
+ children = [children sortedArrayUsingComparator:^NSComparisonResult(NSURL *url1, NSURL *url2) {
+ NSNumber *isDirectory1 = nil;
+ NSNumber *isDirectory2 = nil;
+ [url1 getResourceValue:&isDirectory1 forKey:NSURLIsDirectoryKey error:NULL];
+ [url2 getResourceValue:&isDirectory2 forKey:NSURLIsDirectoryKey error:NULL];
+
+ if (isDirectory1.boolValue && !isDirectory2.boolValue) {
+ return NSOrderedAscending;
+ } else if (!isDirectory1.boolValue && isDirectory2.boolValue) {
+ return NSOrderedDescending;
+ }
+
+ return [url1.lastPathComponent compare:url2.lastPathComponent
+ options:NSCaseInsensitiveSearch];
+ }];
+
+ for (NSURL * const url in children) {
NSNumber *isDirectory;
NSNumber *isVolume;
NSNumber *isEjectable;
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/d1409377c3ec442dac183c5e6ca5aafc25491315...3398df334706453a2428824cf5907d330d094cc4
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/d1409377c3ec442dac183c5e6ca5aafc25491315...3398df334706453a2428824cf5907d330d094cc4
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list