Quellcode durchsuchen

文件重命名

harry vor 3 Jahren
Ursprung
Commit
a0faec920e

+ 1 - 1
BFCommonKit/Classes/BFUtility/PQBridgeObject.h

@@ -24,7 +24,7 @@ NS_ASSUME_NONNULL_BEGIN
 + (NSString *)base64Md5ForFilePath:(NSString *)filePath;
 
 // 对文件重命名
-+ (NSString *)p_setupFileRename:(NSString *)filePath;
++ (nullable NSString *)p_setupFileRename:(NSString *)filePath;
 
 
 @end

+ 7 - 7
BFCommonKit/Classes/BFUtility/PQBridgeObject.m

@@ -139,7 +139,7 @@ int32_t const CHUNK_SIZE = 8 * 1024;
  @param filePath 旧路径
  @return 新路径
  */
-+ (NSString *)p_setupFileRename:(NSString *)filePath {
++ (nullable NSString *)p_setupFileRename:(NSString *)filePath {
     
     NSString *lastPathComponent = [NSString new];
     //获取文件名: 视频.MP4
@@ -153,13 +153,13 @@ int32_t const CHUNK_SIZE = 8 * 1024;
     NSFileManager *fileManager = [NSFileManager defaultManager];
     //通过移动该文件对文件重命名
     BOOL isSuccess = [fileManager moveItemAtPath:filePath toPath:moveToPath error:nil];
-    if (isSuccess) {
-        NSLog(@"rename success");
-    }else{
-        NSLog(@"rename fail");
-    }
+//    if (isSuccess) {
+//        NSLog(@"rename success");
+//    }else{
+//        NSLog(@"rename fail");
+//    }
     
-    return moveToPath;
+    return isSuccess ? moveToPath : nil;
 }
 
 /**