Re: More NSFileManager Issues
Re: More NSFileManager Issues
- Subject: Re: More NSFileManager Issues
- From: Andreas Grosam <email@hidden>
- Date: Mon, 29 Oct 2012 11:39:26 +0100
On 29.10.2012, at 11:22, Vincent Habchi wrote:
> Since I am here…
>
> Le 29 oct. 2012 à 10:56, Andreas Grosam <email@hidden> a écrit :
>
>> With NSFileManager I've created a file in the temporary directory. Attempting to delete it, fails:
>>
>> NSFileManager* fm = [[NSFileManager alloc] init];
>> NSLog(@"tmp file: %@", [_input1000 path]);
>> BOOL isDirectory;
>> if ([fm fileExistsAtPath:[_input1000 path] isDirectory:&isDirectory] || isDirectory) {
>> NSError* error;
>> if ([fm removeItemAtURL:_input1000 error:&error] == NO) {
>> NSLog(@"ERROR: tear down testing environment with error: %@", error);
>> }
>> }
>>
>> Console:
>>
>> tmp file: /var/folders/m9/5p__qm3967qchc9_26tl85km0000gn/T/RelaxTest/input1000.txt
>>
>> ERROR: tear down testing environment with error: Error Domain=NSCocoaErrorDomain Code=4 "The file “input1000.txt” doesn’t exist." UserInfo=0x10011e700 {NSURL=/var/folders/m9/5p__qm3967qchc9_26tl85km0000gn/T/RelaxTest/input1000.txt}
>
> Shouldn’t your URL (the one in the the error message just above) look like ‘file://var/folders…’ rather than a mere ‘/var/folders…’?
Ah!
The URL has been erroneously created as follows:
_input1000 = [NSURL URLWithString:tmpFile];
That should be
_input1000 = [NSURL fileURLWithPath:tmpFile];
Thanks for the hint! :)
Yet, the createDirectoryAtPath:withIntermediateDirectories:attributes:error: issue still exists.
Regards
Andreas
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden