Commit 9bebb458 authored by Felix Paul Kühne's avatar Felix Paul Kühne

Library: also delete associated subtitle files if the user removes a clip

parent 5d626497
......@@ -13,6 +13,7 @@
#import "VLCPlaylistTableViewCell.h"
#import "VLCPlaylistGridView.h"
#import "VLCMenuViewController.h"
#import "NSString+SupportedMedia.h"
@implementation EmptyLibraryView
@end
......@@ -118,7 +119,23 @@
- (void)removeMediaObject:(MLFile *)mediaObject
{
[[NSFileManager defaultManager] removeItemAtPath:[[NSURL URLWithString:mediaObject.url] path] error:nil];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *folderLocation = [[[NSURL URLWithString:mediaObject.url] path] stringByDeletingLastPathComponent];
NSArray *allfiles = [fileManager contentsOfDirectoryAtPath:folderLocation error:nil];
NSString *fileName = [[[[NSURL URLWithString:mediaObject.url] path] lastPathComponent] stringByDeletingPathExtension];
NSIndexSet *indexSet = [allfiles indexesOfObjectsPassingTest:^BOOL(id obj, NSUInteger idx, BOOL *stop) {
return ([obj rangeOfString:fileName].location != NSNotFound);
}];
unsigned int count = indexSet.count;
NSString *additionalFilePath;
NSUInteger currentIndex = [indexSet firstIndex];
for (unsigned int x = 0; x < count; x++) {
additionalFilePath = allfiles[currentIndex];
if ([additionalFilePath isSupportedSubtitleFormat])
[fileManager removeItemAtPath:[folderLocation stringByAppendingPathComponent:additionalFilePath] error:nil];
currentIndex = [indexSet indexGreaterThanIndex:currentIndex];
}
[fileManager removeItemAtPath:[[NSURL URLWithString:mediaObject.url] path] error:nil];
[[MLMediaLibrary sharedMediaLibrary] updateMediaDatabase];
[self updateViewContents];
}
......
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