mirror of
https://github.com/status-im/react-native-camera.git
synced 2025-02-25 02:15:13 +00:00
35 lines
893 B
Mathematica
35 lines
893 B
Mathematica
|
//
|
||
|
// RNFileSystem.m
|
||
|
// RCTCamera
|
||
|
//
|
||
|
// Created by Joao Guilherme Daros Fidelis on 19/01/18.
|
||
|
//
|
||
|
|
||
|
#import "RNFileSystem.h"
|
||
|
|
||
|
@implementation RNFileSystem
|
||
|
|
||
|
+ (BOOL)ensureDirExistsWithPath:(NSString *)path
|
||
|
{
|
||
|
BOOL isDir = NO;
|
||
|
NSError *error;
|
||
|
BOOL exists = [[NSFileManager defaultManager] fileExistsAtPath:path isDirectory:&isDir];
|
||
|
if (!(exists && isDir)) {
|
||
|
[[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:&error];
|
||
|
if (error) {
|
||
|
return NO;
|
||
|
}
|
||
|
}
|
||
|
return YES;
|
||
|
}
|
||
|
|
||
|
+ (NSString *)generatePathInDirectory:(NSString *)directory withExtension:(NSString *)extension
|
||
|
{
|
||
|
NSString *fileName = [[[NSUUID UUID] UUIDString] stringByAppendingString:extension];
|
||
|
[RNFileSystem ensureDirExistsWithPath:directory];
|
||
|
return [directory stringByAppendingPathComponent:fileName];
|
||
|
}
|
||
|
|
||
|
@end
|
||
|
|