Joel VanderWerf wrote:
> Trans wrote:
>> I have a little app that needs to store session data. I assume the
>> best place to store it is in one's home directory, but I need this app
>> to be cross-platform. I glanced through all rbconfig.rb's
>> Config::CONFIG settings but did not see anything for it. How does one
>> access a cross-platform home directory?
>
> This is one way of guessing:
>
> case RUBY_PLATFORM
> when /win32/
>    ENV['APPDATA'] ||
>    ENV['USERPROFILE'] ||
>    ENV['HOME']
>
> else
>    ENV['HOME'] ||
>    File.expand_path('~')
> end
>
> Typical values:
>
> ENV['APPDATA'] == "C:\Documents and Settings\username\Application Data"
> ENV['USERPROFILE'] == "C:\Documents and Settings\username"
>
> (This is from my 'preferences' lib.)
>
> I have no idea what is right on OS X. I'm sure someone has thought this
> through in more detail...
>
> --
>        vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407
>
>

I think Mac OS X should have the traditional unix variables set, like ${HOME}
and ${EDITOR} but I don't own a mac to find out :'(.


--
    
Email and shopping with the feelgood factor!
55% of income to good causes. http://www.ippimail.com