special folders

Ken Ray kray at sonsothunder.com
Wed May 2 16:42:07 EDT 2007


On Wed, 02 May 2007 11:15:01 -0700, Sadhunathan Nadesan wrote:

> For example, in our case, we are providing a download of an 
> executable for windows users which installs as normal in the program 
> files directory. (Mac version, not sure where it goes).  However, a 
> separate stack that can be written to is obscurely (some might say) 
> squirreled away in a special folder - which turns out to be different 
> on different versions of windoz.  For example, its under all 
> users/application data (or something like that) on XP home and pro, 
> and something like c:/ProgramData on Vista basic (at least mine).  
> The mac I'm not sure.  Our code has a case statement to detect the 
> type of OS and pick the right special folder. 
> Why wouldn't we just put this stack in the same folder where we 
> install the executable?

Well, basically the issue is one of access rights; in a "personal" 
installation of Mac OS X or Windows, usually since there's only one 
user, it's likely that they will either be granted or grant themselves 
administration rights. In this case, it doesn't matter where you 
install the stack, since they'll have access anywhere.

However, in a "corporate" installation of Mac OS X or Windows, users 
are generally granted more limited rights (can only read files from 
certain directories, etc.). This becomes even more pronounced in Vista, 
btw. So if you installed a stack in the Program Files folder right next 
to the executable in Windows, and the user had limited rights, it is 
very likely that any changes made to that stack could not be saved 
(since the files would be read-only for that user).

There are a lot more examples, but you get the idea. So to develop for 
the widest possible distribution, you want to accommodate users of all 
levels, so the guidelines say that you should:

- Put the executable file in the Applications/Program Files/etc. folder
- Put files that the application uses, that usually won't be modified 
or need to be accessed by multiple users, and likely should not be seen 
(or not seen very often) by end users in an Application 
Support/Application Data/etc. folder
- Put files that *do* change, are user-specific, or hold user-generated 
data in the user's Documents/My Documents folder

It is therefore useful to use the specialFolderPath() function instead 
of hardcoding paths - especially when it comes to other languages. 
Although I don't know this for sure, it wouldn't surprise me to find 
out that certain folders are named differently in other localized OSes. 

Hope this helps,

Ken Ray
Sons of Thunder Software, Inc.
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/



More information about the use-livecode mailing list