in reply to cross-platform way to get home directory

Windows lacks a meaningful home-directory concept. On UNIX systems $ENV{HOME} is the gold-standard.

-sam

  • Comment on Re: cross-platform way to get home directory

Replies are listed 'Best First'.
Re^2: cross-platform way to get home directory
by ikegami (Patriarch) on May 15, 2006 at 19:42 UTC

    Windows does have a home dir, but that's not where you want to place application settings

    Application settings should go in a subdir of the directory specified by registry value
    HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Local Settings
    The subdir should be of the form <company name>\<application name>.

    Application data should go in a subdir of the directory specified by registry value
    HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Local AppData
    The subdir should be of the form <company name>\<application name>.

    Replace %USERPROFILE% with the value of $ENV{USERPROFILE}.

      Windows may have something called a home directory, but it's basically useless. It doesn't have any of the useful meaning that $ENV{HOME} has on Unix.

      -sam

        What useful meaning does $ENV{HOME} have on Unix? Somewhere to put config files? yes ("Local Settings") Somewhere to put the user's personal files? yes ("My Documents")
Re^2: cross-platform way to get home directory
by QM (Parson) on May 15, 2006 at 19:43 UTC
    Not doubting you, but just one example.

    My XP system was setup (either automatically or by a human) with

    HOMEDRIVE=d: HOMEPATH=\Documents and Settings\myusername
    I should go add
    HOME=%HOMEDRIVE%%HOMEPATH
    though sweeping under the rug obvious problems with multiple users and delayed evaluation.

    For the OP, it may help to dictate to his/her users that $ENV{HOME} be set correctly.

    -QM
    --
    Quantum Mechanics: The dreams stuff is made of