Path of Home directory

Discussion in 'Ruby' started by Martin Ankerl, Aug 18, 2004.

  1. I am writing a ruby application (http://speedreader.rubyforge.org/),
    where I would like to store some user information to something like
    ~/.speedreader, and a similar path in windows. I know that in Linux I
    can get this path with

    Dir.chdir
    homewd = Dir.pwd

    Does this work in windows too? I have currently no access to a windows
    machine.

    Martin
     
    Martin Ankerl, Aug 18, 2004
    #1
    1. Advertising

  2. Martin Ankerl wrote:

    > I know that in Linux I
    > can get this path with
    >
    > Dir.chdir
    > homewd = Dir.pwd
    >
    > Does this work in windows too? I have currently no access to a windows
    > machine.


    Based on my test on Windows XP, yes.

    But you might want to use the following instead:

    home_dir = File.expand_path("~")

    Regards,
    Florian Gross
     
    Florian Gross, Aug 18, 2004
    #2
    1. Advertising

  3. Martin Ankerl

    Brian Palmer Guest

    Florian Gross wrote:

    > Martin Ankerl wrote:
    >
    >> I know that in Linux I
    >> can get this path with
    >>
    >> Dir.chdir
    >> homewd = Dir.pwd
    >>
    >> Does this work in windows too? I have currently no access to a windows
    >> machine.

    >
    >
    > Based on my test on Windows XP, yes.
    >
    > But you might want to use the following instead:
    >
    > home_dir = File.expand_path("~")
    >
    > Regards,
    > Florian Gross


    Neither work on my XP Pro machine, HOME isn't a defined environment
    variable, though HOME_PATH is, if that means anything.

    -- Brian Palmer
     
    Brian Palmer, Aug 18, 2004
    #3
  4. Brian Palmer wrote:

    >>> Dir.chdir
    >>> homewd = Dir.pwd

    >> home_dir = File.expand_path("~")

    > Neither work on my XP Pro machine, HOME isn't a defined environment
    > variable, though HOME_PATH is, if that means anything.


    I have HOME, USERPROFILE and HOMEDRIVE + HOMEPATH. Ruby seems to be
    depending on HOME in those code samples. I propose that it should
    fallback to USERPROFILE and HOMEDRIVE + HOMEPATH (at least on Win32).

    Regards,
    Florian Gross
     
    Florian Gross, Aug 18, 2004
    #4
  5. Martin Ankerl

    Guest

    Hi,

    At Wed, 18 Aug 2004 11:00:56 +0900,
    Florian Gross wrote in [ruby-talk:109611]:
    > I have HOME, USERPROFILE and HOMEDRIVE + HOMEPATH. Ruby seems to be
    > depending on HOME in those code samples. I propose that it should
    > fallback to USERPROFILE and HOMEDRIVE + HOMEPATH (at least on Win32).


    Now modified in CVS HEAD.

    --
    Nobu Nakada
     
    , Aug 18, 2004
    #5
  6. wrote:

    > Hi,


    Moin!

    >>I have HOME, USERPROFILE and HOMEDRIVE + HOMEPATH. Ruby seems to be
    >>depending on HOME in those code samples. I propose that it should
    >>fallback to USERPROFILE and HOMEDRIVE + HOMEPATH (at least on Win32).

    > Now modified in CVS HEAD.


    Thanks for the quick response. :)
     
    Florian Gross, Aug 18, 2004
    #6
  7. > Now modified in CVS HEAD.

    That was quick. Thanks!

    Martin
     
    Martin Ankerl, Aug 18, 2004
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. john
    Replies:
    4
    Views:
    712
    Jim Higson
    Jun 15, 2006
  2. Edward Diener
    Replies:
    5
    Views:
    1,160
    Edward Diener
    Jul 8, 2007
  3. nancyflorida
    Replies:
    0
    Views:
    369
    nancyflorida
    Nov 12, 2007
  4. nancyflorida
    Replies:
    0
    Views:
    357
    nancyflorida
    Nov 12, 2007
  5. Chad Perrin
    Replies:
    7
    Views:
    334
    OscarRyz
    Aug 11, 2012
Loading...

Share This Page