Commit ef6c3bbb authored by David Fuhrmann's avatar David Fuhrmann

macosx: simplify revealInFinder action

parent 8afbec28
...@@ -487,32 +487,24 @@ ...@@ -487,32 +487,24 @@
- (IBAction)revealItemInFinder:(id)sender - (IBAction)revealItemInFinder:(id)sender
{ {
NSIndexSet * selectedRows = [o_outline_view selectedRowIndexes]; NSIndexSet *selectedRows = [o_outline_view selectedRowIndexes];
NSUInteger count = [selectedRows count]; [selectedRows enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL *stop) {
NSUInteger indexes[count];
[selectedRows getIndexes:indexes maxCount:count inIndexRange:nil];
NSMutableString * o_mrl; PLItem *o_item = [o_outline_view itemAtRow:idx];
for (NSUInteger i = 0; i < count; i++) {
PLItem *o_item = [o_outline_view itemAtRow:indexes[i]];
char * psz_url = decode_URI(input_item_GetURI([o_item input]));
o_mrl = [[NSMutableString alloc] initWithString: [NSString stringWithUTF8String:psz_url ? psz_url : ""]];
if (psz_url != NULL)
free( psz_url );
/* perform some checks whether it is a file and if it is local at all... */ /* perform some checks whether it is a file and if it is local at all... */
if ([o_mrl length] > 0) { char *psz_url = input_item_GetURI([o_item input]);
NSRange prefix_range = [o_mrl rangeOfString: @"file:"]; NSURL *url = [NSURL URLWithString:toNSStr(psz_url)];
if (prefix_range.location != NSNotFound) free(psz_url);
[o_mrl deleteCharactersInRange: prefix_range]; if (![url isFileURL])
return;
if (![[NSFileManager defaultManager] fileExistsAtPath:[url path]])
return;
if ([o_mrl characterAtIndex:0] == '/') msg_Dbg(VLCIntf, "Reveal url %s in finder", [[url path] UTF8String]);
[[NSWorkspace sharedWorkspace] selectFile: o_mrl inFileViewerRootedAtPath: o_mrl]; [[NSWorkspace sharedWorkspace] selectFile: [url path] inFileViewerRootedAtPath: [url path]];
} }];
[o_mrl release];
}
} }
/* When called retrieves the selected outlineview row and plays that node or item */ /* When called retrieves the selected outlineview row and plays that node or item */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment