Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Path of Home directory

Reply
Thread Tools

Path of Home directory

 
 
Martin Ankerl
Guest
Posts: n/a
 
      08-17-2004
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
 
Reply With Quote
 
 
 
 
Florian Gross
Guest
Posts: n/a
 
      08-18-2004
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
 
Reply With Quote
 
 
 
 
Brian Palmer
Guest
Posts: n/a
 
      08-18-2004
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



 
Reply With Quote
 
Florian Gross
Guest
Posts: n/a
 
      08-18-2004
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
 
Reply With Quote
 
nobu.nokada@softhome.net
Guest
Posts: n/a
 
      08-18-2004
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


 
Reply With Quote
 
Florian Gross
Guest
Posts: n/a
 
      08-18-2004
http://www.velocityreviews.com/forums/(E-Mail Removed) 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.
 
Reply With Quote
 
Martin Ankerl
Guest
Posts: n/a
 
      08-18-2004
> Now modified in CVS HEAD.

That was quick. Thanks!

Martin
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
getting the user's home directory path Chad Perrin Ruby 7 08-11-2012 01:00 AM
Is there a function that can test if a path is in a directory or oneof its sub-directory (recursively)? Peng Yu Python 0 11-06-2009 03:41 AM
physical path to virtual path under virtual directory =?Utf-8?B?SmVmZiBCZWVt?= ASP .Net 4 08-01-2007 02:59 PM
Getting the home directory in Python and a bug in os.path.expanduser Edward Diener Python 5 07-08-2007 02:30 AM
virtual directory name? or unc directory path? Steve Singer ASP .Net 0 02-15-2005 10:26 PM



Advertisments