• 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
File best practice questions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

File best practice questions


  • Subject: File best practice questions
  • From: Thomas Summerall <email@hidden>
  • Date: Fri, 14 Mar 2008 15:47:36 -0400

I come from a c/c++ and Mac Classic background.  As a result I appreciate the practice of dealing with files using symbolic unique identifiers, like FSSpecs, rather than paths.

As OSX is now Unix-ish it is suddenly more path-based and I find that a lot of time is spent in our c code converting back and forth from paths to FSSpecs to NSFiles to CFURLs and on and on depending on what the needs and return types of the various sdks and apis we use are.

I find I'm having to do the same thing a bit in my Applescript-based installer.

Ordering Finder around with applescript further confuses the mix.

My installer's pretty simple.  It just copies a folder from inside the installer package to the destination folder chosen by the user after it checks to make sure certain things about the system are correct.

But every once in a while it fails on some user's machines for various reasons, only some of which I've so far identified.  I can make it fail on my machine several ways, for example by adding troublesome characters like slashes and double quotes to my destination folder name.

So my question is this:  given that I have to allow the user to pick the destination folder and that I need to construct the path to my source folder in my installer package what is the best way to minimize or, dare I say, eliminate problematic paths and path conversions?

Right now I keep pretty much everything in old style paths and tell the finder to duplicate the source folder to the target folder as paths.  I build my source path like this (path to me as string) & ":Contents:My Install folder Name"

People have suggested using aliases instead of paths, but since I am constructing the paths anyway will that really help since they'll have to be a path string before they are an alias?

Does the Finder always want colon paths?

Should I not use the finder and instead use a shell command instead?

Is there a class that encapsulates all this into something nicely abstract that Does The Right Thing (c) ?

Any tips or links to thorough documentation about the most foolproof way to avoid the common path and file errors would be appreciated.  (I've read the basic file handling docs that define what a POSIX file is and so forth.)

Thanks very much,
Thomas Summerall
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: File best practice questions
      • From: "Gary (Lists)" <email@hidden>
  • Prev by Date: Re: Double mounted afp volumes
  • Next by Date: Changing terminal title - all or nothing
  • Previous by thread: Re: Double mounted afp volumes
  • Next by thread: Re: File best practice questions
  • Index(es):
    • Date
    • Thread