Moving Files From /private/tmp
Moving Files From /private/tmp
- Subject: Moving Files From /private/tmp
- From: Oliver Cameron <email@hidden>
- Date: Tue, 29 Mar 2005 22:28:03 +0100
I'm having some trouble using the NSFileManager method
movePath:toPath:handler. Basically, what I want to do is place a png
file inside a folder I create in /private/tmp, then later retrieve this
file and overwrite a file with the same filename somewhere in the Users
folder. This is my code to do this:
NSString *privateString = @"/private/tmp/My Folder/";
NSString *privateFullString = [privateString
stringByAppendingPathComponent:[file lastPathComponent]];
[[NSFileManager defaultManager] movePath:privateFullString
toPath:[NSHomeDirectory()
stringByAppendingPathComponent:@"FolderWhereFileWithSameFileNameIs"]
handler:nil];
When I NSLog(privateFullString), I get the correct file path. And I
checked /private/tmp and my file is correctly getting added to it, but
when I try and move it (via the code above), nothing happens.
So I checked what movePath:toPath:handler: returned (a BOOL) and it
returned NO, so something was going wrong. My suspicion is permissions,
but I have no other place in which I can move these files (due to a
restrictive plist), so I can't use NSTemporaryThingy() and I'd rather
not have the user need admin access.
So as a last attempt I tried using NSData, and got the contents of the
file in /private/tmp with a +dataWithContentsOfFile call, I then used
writeToFile:atomically and checked its BOOL, it was also returning no
and didn't work. So I'm pretty much out of ideas, anything at all is
useful.
Thanks,
Oliver
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden