vlc | branch: master | Filip Roséen <[email protected]> | Thu Jul 26 11:42:38 2018 +0200| [f70f368e8130c1ecdd2bff1b22e9dd08c8e433b8] | committer: Jean-Baptiste Kempf
gui: macosx: simplify saving of playlist Signed-off-by: Jean-Baptiste Kempf <[email protected]> > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f70f368e8130c1ecdd2bff1b22e9dd08c8e433b8 --- modules/gui/macosx/VLCMainMenu.m | 63 ++++++++++++++-------------------------- 1 file changed, 22 insertions(+), 41 deletions(-) diff --git a/modules/gui/macosx/VLCMainMenu.m b/modules/gui/macosx/VLCMainMenu.m index e0a22d6506..d3bf3cb4ac 100644 --- a/modules/gui/macosx/VLCMainMenu.m +++ b/modules/gui/macosx/VLCMainMenu.m @@ -1169,50 +1169,31 @@ if ([savePanel runModal] == NSFileHandlingPanelOKButton) { NSString *filename = [[savePanel URL] path]; + NSString *ext; + char const* psz_module; + + switch ([_playlistSaveAccessoryPopup indexOfSelectedItem]) { + case 0: psz_module = "export-m3u"; + ext = @"m3u"; + break; + case 1: psz_module = "export-xspf"; + ext = @"xspf"; + break; + case 2: psz_module = "export-html"; + ext = @"html"; + break; + default: + return; + } - if ([_playlistSaveAccessoryPopup indexOfSelectedItem] == 0) { - NSString *actualFilename; - NSRange range; - range.location = [filename length] - [@".m3u" length]; - range.length = [@".m3u" length]; - - if ([filename compare:@".m3u" options: NSCaseInsensitiveSearch range: range] != NSOrderedSame) - actualFilename = [NSString stringWithFormat: @"%@.m3u", filename]; - else - actualFilename = filename; - - playlist_Export(p_playlist, - [actualFilename fileSystemRepresentation], - "export-m3u"); - } else if ([_playlistSaveAccessoryPopup indexOfSelectedItem] == 1) { - NSString *actualFilename; - NSRange range; - range.location = [filename length] - [@".xspf" length]; - range.length = [@".xspf" length]; - - if ([filename compare:@".xspf" options: NSCaseInsensitiveSearch range: range] != NSOrderedSame) - actualFilename = [NSString stringWithFormat: @"%@.xspf", filename]; - else - actualFilename = filename; - - playlist_Export(p_playlist, - [actualFilename fileSystemRepresentation], - "export-xspf"); - } else { - NSString *actualFilename; - NSRange range; - range.location = [filename length] - [@".html" length]; - range.length = [@".html" length]; + NSString *actualFilename = filename; - if ([filename compare:@".html" options: NSCaseInsensitiveSearch range: range] != NSOrderedSame) - actualFilename = [NSString stringWithFormat: @"%@.html", filename]; - else - actualFilename = filename; + if ([[filename pathExtension] caseInsensitiveCompare:ext] != NSOrderedSame) + actualFilename = [NSString stringWithFormat: @"%@.%@", filename, ext]; - playlist_Export(p_playlist, - [actualFilename fileSystemRepresentation], - "export-html"); - } + playlist_Export(p_playlist, + [actualFilename fileSystemRepresentation], + psz_module); } } _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
