Afficher un message
Vieux 13/09/2007, 20h37   #2
Joel VanderWerf
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Cross-platform Home Directory?

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

  Réponse avec citation
 
Page generated in 0,04579 seconds with 9 queries