File tree Expand file tree Collapse file tree 3 files changed +42
-0
lines changed
Expand file tree Collapse file tree 3 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,30 @@ - (dispatch_queue_t)methodQueue
4444 }];
4545}
4646
47+ RCT_EXPORT_METHOD (deleteRecording:(NSString *)path callback:(RCTResponseSenderBlock)callback)
48+ {
49+ [self .screenRecordCoordinator removeRecordingWithFilePath: path];
50+ callback (@[path]);
51+ }
52+
53+ RCT_EXPORT_METHOD (copyRecording:(NSString *)path callback:(RCTResponseSenderBlock)callback)
54+ {
55+ static NSString *letters = @" abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" ;
56+ NSMutableString *randomString = [NSMutableString stringWithCapacity: 15 ];
57+ for (int i=0 ; i<15 ; i++) {
58+ [randomString appendFormat: @" %C " , [letters characterAtIndex: arc4random () % [letters length ]]];
59+ }
60+
61+ NSString *newPath = [[NSString stringWithFormat: @" %@ /%@ " ,
62+ [path stringByDeletingLastPathComponent ], letters]
63+ stringByAppendingPathExtension: [path pathExtension ]];
64+
65+ [self .screenRecordCoordinator copyRecordingWithFilePath: path destFileURL: newPath];
66+ NSArray *recordings = [self .screenRecordCoordinator listAllReplays ];
67+
68+ callback (@[recordings, newPath]);
69+ }
70+
4771RCT_EXPORT_METHOD (getRecordings:(RCTResponseSenderBlock)callback)
4872{
4973 NSArray *recordings = [self .screenRecordCoordinator listAllReplays ];
Original file line number Diff line number Diff line change @@ -54,6 +54,14 @@ import Foundation
5454 }
5555 }
5656 }
57+
58+ class func deleteItem( at url: URL ) {
59+ do {
60+ try FileManager . default. removeItem ( at: url)
61+ } catch let error as NSError {
62+ print ( " Error deleting file! " )
63+ }
64+ }
5765
5866 class func filePath( _ fileName: String ) -> String
5967 {
Original file line number Diff line number Diff line change @@ -46,6 +46,16 @@ import AVKit
4646 }
4747 }
4848
49+ func removeRecording( withFilePath fileURL: String )
50+ {
51+ ReplayFileUtil . deleteItem ( at: URL ( fileURLWithPath: fileURL) )
52+ }
53+
54+ func copyRecording( withFilePath fileURL: String , destFileURL: String )
55+ {
56+ ReplayFileUtil . copyItem ( at: URL ( fileURLWithPath: fileURL) , to: URL ( fileURLWithPath: destFileURL) )
57+ }
58+
4959 func previewRecording ( withFileName fileURL: String ) {
5060 if UIVideoEditorController . canEditVideo ( atPath: fileURL) {
5161 previewDelegateView. setCoordinator ( coordinator: self )
You can’t perform that action at this time.
0 commit comments