• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Moving Files From /private/tmp
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Moving Files From /private/tmp


  • Subject: Re: Moving Files From /private/tmp
  • From: Justin Spahr-Summers <email@hidden>
  • Date: Tue, 29 Mar 2005 16:59:36 -0600

From

> [NSHomeDirectory()
> stringByAppendingPathComponent:@"FolderWhereFileWithSameFileNameIs"]

I assume you are trying to replace a file already there. The
NSFileManager documentation says:

"The file specified in source must exist, while destination must not yet exist."

Maybe you should call - removeFileAtPath:handler: first.

On Tue, 29 Mar 2005 22:28:03 +0100, Oliver Cameron <email@hidden> wrote:
> 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

References: 
 >Moving Files From /private/tmp (From: Oliver Cameron <email@hidden>)

  • Prev by Date: Re: Overlapping NSMovieViews step on each other
  • Next by Date: Re: Up arrow in NSTextView
  • Previous by thread: Moving Files From /private/tmp
  • Next by thread: Re: Moving Files From /private/tmp
  • Index(es):
    • Date
    • Thread