Re: Best way to move a file out of the way?

2015-03-29 Thread Marco S Hyman
> On Mar 29, 2015, at 10:51 PM, Daryle Walker wrote: > >> An idea... move the destination file, if it exists, to the trash. >> See NSFileManager's trashItemAtURL:resultingItemURL:error: to do that in a >> safe manner. Trash the old file then save the new. > > That was one of my suggestions. S

Re: Best way to move a file out of the way?

2015-03-29 Thread Daryle Walker
> On Mar 24, 2015, at 9:46 PM, Marco S Hyman wrote: > >> 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.) > > An idea... move th

Re: Best way to move a file out of the way?

2015-03-24 Thread Marco S Hyman
> 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.) An idea... move the destination file, if it exists, to the trash. See NSFileManag

Re: Best way to move a file out of the way?

2015-03-24 Thread Stephen J. Butler
I would say rename the new destination file if you think you should keep the old one around. However, if it's always the case that the new file should replace the old one when it finishes downloading, then you should save the new file under a temporary name and use -[NSFileManager replaceItemAtURL

Best way to move a file out of the way?

2015-03-24 Thread Daryle Walker
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