From 32c98c5dbeb68abe6baad0d2942c496341795594 Mon Sep 17 00:00:00 2001 From: Constantine Mureev Date: Thu, 16 Jan 2014 11:54:04 +0400 Subject: [PATCH] Add new methods for getting all files path/url --- CMDataStorage/CMDataStorage.h | 18 ++++++++++++++++++ CMDataStorage/CMDataStorage.m | 10 ++++++++++ 2 files changed, 28 insertions(+) diff --git a/CMDataStorage/CMDataStorage.h b/CMDataStorage/CMDataStorage.h index c1c3c44..310acda 100644 --- a/CMDataStorage/CMDataStorage.h +++ b/CMDataStorage/CMDataStorage.h @@ -105,4 +105,22 @@ */ - (NSString *)filePathWithKey:(NSString *)key; +/** +Returns a new array containing the CMDataStorage files paths. + + The order of the elements in the array is not defined. + + @return The NSArray object with all files url stored in CMDataStorage folder. + */ +- (NSArray*)allKeysURLs; + +/** + Returns a new array containing the CMDataStorage files paths. + + The order of the elements in the array is not defined. + + @return The NSArray object with all files paths stored in + */ +- (NSArray*)allKeysPaths; + @end diff --git a/CMDataStorage/CMDataStorage.m b/CMDataStorage/CMDataStorage.m index a2befd8..b2e9ec4 100644 --- a/CMDataStorage/CMDataStorage.m +++ b/CMDataStorage/CMDataStorage.m @@ -202,6 +202,16 @@ - (NSString *)filePathWithKey:(NSString *)key { return [[self fileURLWithKey:key] path]; } +- (NSArray*)allKeysURLs { + NSArray *dirContents = [get_file_manager() contentsOfDirectoryAtURL:self.cachePath includingPropertiesForKeys:nil options:0 error:nil]; + return dirContents; +} + +- (NSArray*)allKeysPaths { + NSArray *dirContents = [get_file_manager() contentsOfDirectoryAtPath:[self.cachePath path] error:nil]; + return dirContents; +} + #pragma mark - Private