checking removable drives

Richard Gaskin ambassador at fourthworld.com
Wed Nov 2 23:42:36 CST 2005


Ken et al -

I appreciate the thought that y'all put into trying to solve this, but 
in brainstorming with Paul Looney and Bill Vlahos, each of them 
independently hit on a similar possible solution.  The only problem is 
that it's so simple it feels like cheating. :)

Keeping our focus on the goal of writing portable apps (that is, apps 
that can run self-contained on a removable device without leaving 
anything on the host machine), the problem could be defined not as "Are 
we on a removable drive?"  but "Can we write to our own program folder?"

There are two scenarios in which we can't write to our program's folder 
(there may be others, but these come two mind):

- Running from CD-ROM

- Running on a computer in a school lab or other multi-user
   environment where the user may not have permission to write
   to the program directory.

The latter case is why Microsoft and Apple recommend that we use the 
folders they specify for storing things like preferences and user data.

But is it really so much of a sin to store prefs in the program's own 
folder if possible?

So each of these clever gents suggested that we simply first try to 
write prefs to the program's own folder, and if that fails we then try 
to write to the OS-recommended folder for user prefs (Preferences on OS 
X and Application Data on XP).

If the app resides on removable media like a Zip or USB drive, it should 
have no trouble writing to its own folder and that's the end of it.  And 
if the program is installed in the Program Files directory as normal (or 
Applications on OS X), there should be no harm in writing to that 
folder.  If we can't write to that folder we're either on a CD or in a 
protected folder, and would need to write to the OS-recommended folder 
at that point.

Is this a foolhardy thing to do?

Could there be a downside to writing prefs or other such app-managed 
data to a folder either within or at the same level as our program's 
folder if we have permissions to do so?

It makes me nervous to consider anything in computing being this simple. ;)

--
  Richard Gaskin
  Fourth World Media Corporation
  __________________________________________________
  Rev tools and more: http://www.fourthworld.com/rev



More information about the use-livecode mailing list