summaryrefslogtreecommitdiff
path: root/lib/rbot
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2006-07-26 16:54:21 +0000
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2006-07-26 16:54:21 +0000
commit82af99ab6793dc6fc976fa97f9ff3d12b73688ba (patch)
tree8ecf0cae81ec773ebb5fde21962a81e5dfbfe2ac /lib/rbot
parentf891f1f39db461392c0e6074fadc688647886ea7 (diff)
Guess properly default botclass under Windows (preventing a backtrace at the same time, woot)
Diffstat (limited to 'lib/rbot')
-rw-r--r--lib/rbot/ircbot.rb19
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb
index 4209aeee..7f258b0b 100644
--- a/lib/rbot/ircbot.rb
+++ b/lib/rbot/ircbot.rb
@@ -183,8 +183,23 @@ class IrcBot
exit 2
end
- botclass = "#{Etc.getpwuid(Process::Sys.geteuid)[:dir]}/.rbot" unless botclass
- #botclass = "#{ENV['HOME']}/.rbot" unless botclass
+ unless botclass and not botclass.empty?
+ # We want to find a sensible default.
+ # * On POSIX systems we prefer ~/.rbot for the effective uid of the process
+ # * On Windows (at least the NT versions) we want to put our stuff in the
+ # Application Data folder.
+ # We don't use any particular O/S detection magic, exploiting the fact that
+ # Etc.getpwuid is nil on Windows
+ if Etc.getpwuid(Process::Sys.geteuid)
+ botclass = Etc.getpwuid(Process::Sys.geteuid)[:dir].dup
+ else
+ if ENV.has_key?('APPDATA')
+ botclass = ENV['APPDATA'].dup
+ botclass.gsub!("\\","/")
+ end
+ end
+ botclass += "/.rbot"
+ end
botclass = File.expand_path(botclass)
@botclass = botclass.gsub(/\/$/, "")