• 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: Tracking files the right way
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Tracking files the right way


  • Subject: Re: Tracking files the right way
  • From: Bill Bumgarner <email@hidden>
  • Date: Fri, 30 Aug 2002 09:24:35 -0400

On Friday, Aug 30, 2002, at 01:16 US/Eastern, Rosyna wrote:
Ack, at 8/29/02, Bill Bumgarner said:
- If you are going to track the file, *do not* track it to the trash!!! I can't tell you the number of times I have run across apps that happily maintain an FSRef straight into the trash can. Nice surprise for the user when the trash is emptied
Isn't it an equal surprise when the user drags the file to the trash? (Possibly by accident)

If the user explicitly drags a document to the trash-- by accident or otherwise-- then there isn't much the app can or should do about it beyond detecting the fact that file is in the trash and appropriately warning the user that they are editing/viewing something that is very likely going to go away in the future.

The behavior I have experienced-- on OS 9 and prior, not just OS X-- was for the applications to merrily open and edit the document in the trash with zero warning to the user.

- If you do use paths to refer to a file -- either directly storing the path or through one of the Core APIs-- NORMALIZE THE DAMNED PATH FIRST! I.e. If the user stores something in the Documents/ directory of their home account, store the path as '~/Documents' or '~user/Documents'. This can greatly easy the pain of working with certain applications in an account that can be accessed from multiple machines on a network where the path to ~/ can change depending on machine.
Do you have any recommendations for doing this?

Ahh... code examples, now we are back on track and moving away from bordering dangerously close to flogging a dead horse (not an accusation-- I clearly have my cat-o-nine tails in hand). :-)

The foundation offers:

- (NSString *)stringByStandardizingPath
- (NSString *)stringByAbbreviatingWithTildeInPath

The second does the obvious -- substitute '~/' with '~user/' if you want user A to be able to pass a path in their home directory to user B. The first performs a number of operations on the path. Notably, it ensures a path does not refer to /private/ if that part of the path can be removed while the path will still point to the same file. Unfortunately, -stringByStandardizingPath will also cause symlinks to be expanded -- not necessarily what you want.

Clearly, this is a problem that Apple hasn't fully thought through in a fashion that is available via the public APIs.

See the docs for -stringByStandardizingPath -- that method does pretty much everything you want, except that it also expands symlinks. If it didn't expand symlinks, it would be much more in line with the desired goal of path management.

I'll file a request via bugreport.apple.com.



- If you store a thousand file references into some random area of a Volume and the Volume name changes, you should only have to ask the user ONCE where the files have been move to -- your app should be bright enough to figure it out from that information! This is not hard to do and affects both aliased and non-aliased storage paradigms (i.e. if the user has copied the files and deleted the originals, for example).

Right, this is one (only) of the things I freakin loved about Adobe Premiere. It would search the current directory for the remaining missing files. I would really love if iTunes did this.

In general, this is a really good idea for any developer writing an app that involves some kind of a directory full of resources that isn't managed with NSFileWrapper or NSBundle. Store as much information using relative paths as you possibly can and automate the identification of files as much as possible.

Project Builder can also do this. If you select a bunch of files and 'set path' in the inspector, you can choose a folder. PBX will set the path reference to as many of them as it can find in that directory. Doesn't walk the tree or anything totally crafty, but a far cry better than having to set the path on each file individually when restructuring a project.

(BTW: if you need to move the .pbproj, set all file references to absolute, move the pbproj, then set all file references back to relative / project relative...)

b.bum
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Tracking files the right way
      • From: Rosyna <email@hidden>
References: 
 >Re: Tracking files the right way (From: Rosyna <email@hidden>)

  • Prev by Date: Re: Tracking files the right way - FIXED in 10.2!!!
  • Next by Date: Re: Executing A Shell Script...
  • Previous by thread: Re: Tracking files the right way
  • Next by thread: Re: Tracking files the right way
  • Index(es):
    • Date
    • Thread