Commit e512846c authored by Gleb Pinigin's avatar Gleb Pinigin

Add helper category method to NSString to determine when filePath is supported...

Add helper category method to NSString to determine when filePath is supported media/subtitle format or not
parent 58e3450c
//
// NSString+SupportedMedia.h
// VLC for iOS
//
// Created by Gleb on 6/1/13.
// Copyright (c) 2013 VideoLAN. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface NSString (SupportedMedia)
- (BOOL)isSupportedMediaFormat;
- (BOOL)isSupportedSubtitleFormat;
@end
//
// NSString+SupportedMedia.m
// VLC for iOS
//
// Created by Gleb on 6/1/13.
// Copyright (c) 2013 VideoLAN. All rights reserved.
//
#import "NSString+SupportedMedia.h"
@implementation NSString (SupportedMedia)
- (BOOL)isSupportedMediaFormat
{
NSUInteger options = NSRegularExpressionSearch | NSCaseInsensitiveSearch;
return ([self rangeOfString:kSupportedFileExtensions options:options].location != NSNotFound);
}
- (BOOL)isSupportedSubtitleFormat
{
NSUInteger options = NSRegularExpressionSearch | NSCaseInsensitiveSearch;
return ([self rangeOfString:kSupportedSubtitleFileExtensions options:options].location != NSNotFound);
}
@end
......@@ -8,6 +8,7 @@
#import "VLCAppDelegate.h"
#import "DirectoryWatcher.h"
#import "NSString+SupportedMedia.h"
#import "VLCPlaylistViewController.h"
#import "VLCMovieViewController.h"
......@@ -151,7 +152,7 @@
NSArray *foundFiles = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:[self directoryPath] error:nil];
NSMutableArray *matchedFiles = [NSMutableArray arrayWithCapacity:foundFiles.count];
for (NSString *fileName in foundFiles) {
if ([fileName rangeOfString:kSupportedFileExtensions options:NSRegularExpressionSearch|NSCaseInsensitiveSearch].length != 0) {
if ([fileName isSupportedMediaFormat]) {
[matchedFiles addObject:[[self directoryPath] stringByAppendingPathComponent:fileName]];
}
}
......@@ -205,7 +206,7 @@
NSMutableArray *filePaths = [NSMutableArray arrayWithCapacity:[foundFiles count]];
NSURL *fileURL;
for (NSString *fileName in foundFiles) {
if ([fileName rangeOfString:kSupportedFileExtensions options:NSRegularExpressionSearch|NSCaseInsensitiveSearch].length != 0) {
if ([fileName isSupportedMediaFormat]) {
[filePaths addObject:[directoryPath stringByAppendingPathComponent:fileName]];
/* exclude media files from backup (QA1719) */
......
......@@ -7,6 +7,7 @@
//
#import "VLCDropboxController.h"
#import "NSString+SupportedMedia.h"
#import "VLCAppDelegate.h"
@interface VLCDropboxController ()
......@@ -68,7 +69,7 @@
#pragma mark - restClient delegate
- (BOOL)_supportedFileExtension:(NSString *)filename
{
if ([filename rangeOfString:kSupportedFileExtensions options:NSRegularExpressionSearch|NSCaseInsensitiveSearch].length != 0 || [filename rangeOfString:kSupportedSubtitleFileExtensions options:NSRegularExpressionSearch|NSCaseInsensitiveSearch].length != 0)
if ([filename isSupportedMediaFormat] || [filename isSupportedSubtitleFormat])
return YES;
return NO;
......
......@@ -190,6 +190,7 @@
A7A0E9FA174BA66000162F25 /* papasscode_marker@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = A7A0E9F2174BA66000162F25 /* papasscode_marker@2x.png */; };
A7A0E9FB174BA66000162F25 /* PAPasscodeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A7A0E9F4174BA66000162F25 /* PAPasscodeViewController.m */; };
A7C30259175A3C7A00AD4388 /* DirectoryWatcher.m in Sources */ = {isa = PBXBuildFile; fileRef = A7C30258175A3C7A00AD4388 /* DirectoryWatcher.m */; };
A7C3025E175A53D400AD4388 /* NSString+SupportedMedia.m in Sources */ = {isa = PBXBuildFile; fileRef = A7C3025D175A53D400AD4388 /* NSString+SupportedMedia.m */; };
A7CB0DB11716F72600050CF3 /* PlayingExternally@2x~iphone.png in Resources */ = {isa = PBXBuildFile; fileRef = A7CB0DAD1716F72600050CF3 /* PlayingExternally@2x~iphone.png */; };
A7CB0DB21716F72600050CF3 /* PlayingExternally~iphone.png in Resources */ = {isa = PBXBuildFile; fileRef = A7CB0DAE1716F72600050CF3 /* PlayingExternally~iphone.png */; };
A7CB0DB31716F72600050CF3 /* PlayingExternally~ipad.png in Resources */ = {isa = PBXBuildFile; fileRef = A7CB0DAF1716F72600050CF3 /* PlayingExternally~ipad.png */; };
......@@ -484,6 +485,8 @@
A7A0E9F4174BA66000162F25 /* PAPasscodeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PAPasscodeViewController.m; sourceTree = "<group>"; };
A7C30257175A3C7A00AD4388 /* DirectoryWatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DirectoryWatcher.h; sourceTree = "<group>"; };
A7C30258175A3C7A00AD4388 /* DirectoryWatcher.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DirectoryWatcher.m; sourceTree = "<group>"; };
A7C3025C175A53D400AD4388 /* NSString+SupportedMedia.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+SupportedMedia.h"; sourceTree = "<group>"; };
A7C3025D175A53D400AD4388 /* NSString+SupportedMedia.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+SupportedMedia.m"; sourceTree = "<group>"; };
A7CB0DAD1716F72600050CF3 /* PlayingExternally@2x~iphone.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "PlayingExternally@2x~iphone.png"; sourceTree = "<group>"; };
A7CB0DAE1716F72600050CF3 /* PlayingExternally~iphone.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "PlayingExternally~iphone.png"; sourceTree = "<group>"; };
A7CB0DAF1716F72600050CF3 /* PlayingExternally~ipad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "PlayingExternally~ipad.png"; sourceTree = "<group>"; };
......@@ -1007,6 +1010,7 @@
7D5F7AB717526573006CCCFA /* Accessory dialogs */,
7D5E39CC174FCDBE007DAFA1 /* Dropbox Integration */,
7D31CF061746AEF2005997E0 /* UI Elements */,
A7C3025A175A538700AD4388 /* Extensions */,
7DADC5601704FACC001DAC63 /* Imported */,
7DADC55C1704FAA8001DAC63 /* XIBs */,
A7924697170F0ED20036AAF2 /* Resources */,
......@@ -1124,6 +1128,15 @@
path = Assets;
sourceTree = "<group>";
};
A7C3025A175A538700AD4388 /* Extensions */ = {
isa = PBXGroup;
children = (
A7C3025C175A53D400AD4388 /* NSString+SupportedMedia.h */,
A7C3025D175A53D400AD4388 /* NSString+SupportedMedia.m */,
);
name = Extensions;
sourceTree = "<group>";
};
CC1BBC441704936500A20CBF /* External VLC Libraries */ = {
isa = PBXGroup;
children = (
......@@ -1383,6 +1396,7 @@
7D5F7AC317529430006CCCFA /* VLCHorizontalSwipeGestureRecognizer.m in Sources */,
7D5F7AC61752943F006CCCFA /* VLCVerticalSwipeGestureRecognizer.m in Sources */,
A7C30259175A3C7A00AD4388 /* DirectoryWatcher.m in Sources */,
A7C3025E175A53D400AD4388 /* NSString+SupportedMedia.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......
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