• 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
Best way to move a file out of the way?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Best way to move a file out of the way?


  • Subject: Best way to move a file out of the way?
  • From: Daryle Walker <email@hidden>
  • Date: Tue, 24 Mar 2015 20:55:11 -0400

Right now, my command-line tool errors out if the destination filename, chosen automatically from the NSURLResponse object, already exists in the working directory. Should I keep it that way, or put the new file there anyway? If the latter, this involves doing something to the previous file with that name (or keeping it the same and renaming the new file instead). Should I delete the old file (causing problems if transferring the new one fails), try replacing (does it work across volumes), or trashing the old file (does this send the instant-delete GUI alert if it happens while current Trash items are emptied)?

If renaming is the answer, is there any sample code to do this safely, taking care of all cases?  (For example, replacement name already taken, or adding an extension if the file doesn’t start with one, etc.)

—
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com

_______________________________________________

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


  • Follow-Ups:
    • Re: Best way to move a file out of the way?
      • From: Marco S Hyman <email@hidden>
    • Re: Best way to move a file out of the way?
      • From: "Stephen J. Butler" <email@hidden>
  • Prev by Date: Bug with Localized Failure Reason and file moving
  • Next by Date: Re: Bug with Localized Failure Reason and file moving
  • Previous by thread: Re: Bug with Localized Failure Reason and file moving
  • Next by thread: Re: Best way to move a file out of the way?
  • Index(es):
    • Date
    • Thread