szabgab has asked for the wisdom of the Perl Monks concerning the following question:

When writing code that should run on several platforms you have various things to consider. One of them is finding the home directory of the current user. Doing that on an arbitrary OS used to be difficult or at least error prone but thanks to Adam Kennedy and his File::HomeDir module it is just calling the my_home method now.

For the location of the configuration files one should use the my_data method

What is not yet clear to me is how should I call the application specific configuration files (or if I use a full directory, the configuration directory)?
.something is the Unix/Linux style.
What should be on windows?
And for other OS-es?
Is there a standard platform independent way to generate names of the configuration files?

Update

I slightly updated the text above but also interesting the trouble Subversion has with the .svn directories.
I couldn't yet figure out the convention used in vi (on Windows) either.
  • Comment on platform independent naming of configuration files

Replies are listed 'Best First'.
Re: platform independent naming of configuration files
by b4swine (Pilgrim) on Aug 18, 2007 at 15:46 UTC

    As you might expect, there are no clear standards for windows.

    The environment variables

    • USERPROFILE="C:\Documents and Settings\username"
    • HOMEDRIVE="C:"
    • HOMEPATH="\Documents and Settings\username"
    give you the home directory. I am not sure if HOMEDRIVE.HOMEPATH is ever different from USERPROFILE, and if so, which one is better to use.

    Programs which need to store their own data create a directory

    • "$ENV{USERPROFILE}\Application Data\Your Application Name"
    and then create any kind of files or directories within that.

    The other possibility is to use registries, but if you want to have cross-platform programs, then it is best to stick to configuration files.


    Update

    I misread your question. You know the directory, but are asking what the filename should be. There, as I said there appears to be no standard. Since you have your very own directory, there can be no fear of trampling on other names, so why not use the same name you would have if it had been on Unix.

Re: platform independent naming of configuration files
by BrowserUk (Patriarch) on Aug 18, 2007 at 17:58 UTC

    The windows convention would be to store it in the registry.

    1. Per user config under HKEY_CURRENT_USER
    2. Per machine config under HKEY_LOCAL_MACHINE
    3. And anything not tied to either of those under HKEY_CURRENT_CONFIG

    Done properly, it allows the user to log on on any machine in the domain, or even a different domain with appropriate privaledges, and have their configuration follow them automatically.

    Configuration is so platform dependant, and the way fo achieving it so vaiable between platforms, and good cross-platform configuration module would account for these differences under the covers.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.