summaryrefslogtreecommitdiff
path: root/platform/ios/test/OHHTTPStubs/OHHTTPStubs/Sources/OHPathHelpers.m
diff options
context:
space:
mode:
Diffstat (limited to 'platform/ios/test/OHHTTPStubs/OHHTTPStubs/Sources/OHPathHelpers.m')
-rw-r--r--platform/ios/test/OHHTTPStubs/OHHTTPStubs/Sources/OHPathHelpers.m35
1 files changed, 35 insertions, 0 deletions
diff --git a/platform/ios/test/OHHTTPStubs/OHHTTPStubs/Sources/OHPathHelpers.m b/platform/ios/test/OHHTTPStubs/OHHTTPStubs/Sources/OHPathHelpers.m
new file mode 100644
index 0000000000..cac24a636a
--- /dev/null
+++ b/platform/ios/test/OHHTTPStubs/OHHTTPStubs/Sources/OHPathHelpers.m
@@ -0,0 +1,35 @@
+//
+// OHPathHelpers.m
+// Pods
+//
+// Created by Olivier Halligon on 18/04/2015.
+//
+//
+
+#import "OHPathHelpers.h"
+
+NSString* OHPathForFile(NSString* fileName, Class inBundleForClass)
+{
+ NSBundle* bundle = [NSBundle bundleForClass:inBundleForClass];
+ return OHPathForFileInBundle(fileName, bundle);
+}
+
+NSString* OHPathForFileInBundle(NSString* fileName, NSBundle* bundle)
+{
+ return [bundle pathForResource:[fileName stringByDeletingPathExtension]
+ ofType:[fileName pathExtension]];
+}
+
+NSString* OHPathForFileInDocumentsDir(NSString* fileName)
+{
+ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+ NSString *basePath = (paths.count > 0) ? [paths objectAtIndex:0] : nil;
+ return [basePath stringByAppendingPathComponent:fileName];
+}
+
+NSBundle* OHResourceBundleForClass(NSString* bundleBasename, Class inBundleForClass)
+{
+ NSBundle* classBundle = [NSBundle bundleForClass:inBundleForClass];
+ return [NSBundle bundleWithPath:[classBundle pathForResource:bundleBasename
+ ofType:@"bundle"]];
+} \ No newline at end of file