[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: File.expand_path and ~ on windows

Berger, Daniel

9/19/2003 4:45:00 PM

> -----Original Message-----
> From: Sean O'Dell [mailto:sean@cSePlsoAfMt.com[REMOVE_THE_SPAM]]
> Sent: Friday, September 19, 2003 10:19 AM
> To: ruby-talk@ruby-lang.org
> Subject: Re: File.expand_path and ~ on windows
>
>
> Austin Ziegler wrote:
>
> > On Fri, 19 Sep 2003 11:36:28 +0900, Tom Felker wrote:
> >
> >>Wouldn't it make more sense to expand it to My Documents
> (C:\Documents
> >>and Settings\Username\My Documents on WinXP)? I suppose it
> would be
> >>worthwhile to be able to disable it, though.
> >
> >
> > No. ~ has no meaning to Windows shells. There are times when I wish
> > that it
> > didn't to Unix shells. After all, that's what ${HOME} is for.
>
> This is true; but I think for portability reasons, since COMMAND.COM
> isn't exactly what I would call a culture of shell idioms, ~
> and ${HOME}
> (%HOME%) should be considered synonymous. If not ~, then at least
> ${HOME} ought to point to C:\Documents and Settings\UserName I think.
>
> Sean O'Dell

FWIW, it is possible to set a HOME directory. On XP Pro: Control Panel ->
User Accounts -> Advanced -> Users.

Then, right click on a given user and click "properties" and click the
"profile" tab. There you should see a "home folder" option. This is what
sets the LPUSER_INFO_11 struct value for the usri11_home_dir member.

So, in theory you can get a user's home dir like this:

# Available on RAA - shameless plug
require "sys/win32etc"
include Sys

home = Win32Etc.getpwnam("some_user").home_dir

However, it seems that in practice this value is rarely set (it wasn't in
any of the 3 machines that I tested) and that %HOME% should be the first
default.

Regards,

Dan

1 Answer

Sean O'Dell

9/19/2003 4:56:00 PM

0

Berger, Daniel wrote:
>>-----Original Message-----
>>From: Sean O''Dell [mailto:sean@cSePlsoAfMt.com[REMOVE_THE_SPAM]]
>>Sent: Friday, September 19, 2003 10:19 AM
>>To: ruby-talk@ruby-lang.org
>>Subject: Re: File.expand_path and ~ on windows
>>
>>
>>Austin Ziegler wrote:
>>
>>
>>>On Fri, 19 Sep 2003 11:36:28 +0900, Tom Felker wrote:
>>>
>>>
>>>>Wouldn''t it make more sense to expand it to My Documents
>>
>>(C:\Documents
>>
>>>>and Settings\Username\My Documents on WinXP)? I suppose it
>>
>>would be
>>
>>>>worthwhile to be able to disable it, though.
>>>
>>>
>>>No. ~ has no meaning to Windows shells. There are times when I wish
>>>that it
>>>didn''t to Unix shells. After all, that''s what ${HOME} is for.
>>
>>This is true; but I think for portability reasons, since COMMAND.COM
>>isn''t exactly what I would call a culture of shell idioms, ~
>>and ${HOME}
>>(%HOME%) should be considered synonymous. If not ~, then at least
>>${HOME} ought to point to C:\Documents and Settings\UserName I think.
>>
>> Sean O''Dell
>
>
> FWIW, it is possible to set a HOME directory. On XP Pro: Control Panel ->
> User Accounts -> Advanced -> Users.
>
> Then, right click on a given user and click "properties" and click the
> "profile" tab. There you should see a "home folder" option. This is what
> sets the LPUSER_INFO_11 struct value for the usri11_home_dir member.
>
> So, in theory you can get a user''s home dir like this:
>
> # Available on RAA - shameless plug
> require "sys/win32etc"
> include Sys
>
> home = Win32Etc.getpwnam("some_user").home_dir
>
> However, it seems that in practice this value is rarely set (it wasn''t in
> any of the 3 machines that I tested) and that %HOME% should be the first
> default.

That''s interesting; it''s there in Win2k as well.

I would say (in agreement) that ~ should first be wherever %HOME% points
to, then wherever the home directory is set in the registry (if it''s not
an empty/whitespace-filled string) and THEN C:\Documents and
Settings\UserName after that. /whew

Sean O''Dell