読み取り専用であるが、その中にファイルがあるフォルダーを別の場所にコピーしようとしています。-copyItemAtPath:toPath:error:を使用すると、フォルダーはコピーされますが、ファイルはコピーされません。エラーを示すサンプルコードを以下に示します。
この場合、コピーする前にフォルダのアクセス許可を変更することはできません。
誰かが提案を提供できますか?
エラーは次のとおりです
。ErrorDomain=NSPOSIXErrorDomain Code = 13 UserInfo =0x1001102a0"操作を完了できませんでした。アクセスが拒否されました。"
エラーのuserInfoは次のとおりです。{
NSDestinationFilePath="/Users/xxxxxxx/Desktop/readonlyfilecopy/testdir/Abbey Road.jpg";
NSFilePath = "/ Users / xxxxxxx / Desktop / testdir / Abbey Road.jpg";
NSUserStringVariant=コピー;
}
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSString* src = @"/Users/xxxxxxx/Desktop/testdir";
NSString* target = @"/Users/xxxxxxx/Desktop/readonlyfilecopy/testdir";
NSError* error = nil;
[[NSFileManager defaultManager] copyItemAtPath:src toPath:target error:&error];
if (error) {
NSLog(@"%@", error);
NSLog(@"%@", [error userInfo]);
}
[pool drain];
return 0;
}