Expected Config File Locations

Philip Newton philip.newton at gmail.com
Tue Aug 30 14:17:57 BST 2011


On Tue, Aug 30, 2011 at 14:55, Smylers <Smylers at stripey.com> wrote:
> In particular, on Windows:
>
> * system_cfg_dir returns the value of %windir%. Is %windir%\bang* a
>  sensible place for the config of a command called bang?
>
> * user_cfg_dir returns the user's home directory. Is that a sensible
>  place for a configuration file?
>
>  I see that psql uses %APPDATA%\postgesql\psqlrc.conf for per-user
>  config -- is that better?

I think that on Windows, the application data directory hierarchy is
the right place for programs to store their own configuration data
(the exact name of the directory depends on the version of the OS:
it's better to ask the system for the physical path corresponding to
the logical name "foo" than to hard-code the thing).

You even get to choose whether those settings are machine-specific
(things like caches) or not (settings a user might expect to find even
if he logs in with his account somewhere else, if his account is
shared across/available through multiple machines): you have
AppData/Local or AppData/Roaming. (Again, exact names vary.)

On the other hand, that's not a place most people dig around in,
themselves. So if it's a configuration file you expect the user to
edit, then the home directory or a sub directory might be better
(depending partly on whether you expect to have only one config file
or [potentially] several).

There may be a difference between $HOME (aka %HOME%),
%HOMEDRIVE%%HOMEPATH%, and the home directory you get through a system
call, though....

> * Most Windows systems seem to be single-user; do I even need both
>  system-wide and per-user locations on Windows, and if not which one
>  would you expect to find?

Many programs ask, when they get installed, whether to install it for
"just the current user ($name)" or for "all users".

Cheers,
Philip
-- 
Philip Newton <philip.newton at gmail.com>



More information about the london.pm mailing list