From 82af99ab6793dc6fc976fa97f9ff3d12b73688ba Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Wed, 26 Jul 2006 16:54:21 +0000 Subject: [PATCH] Guess properly default botclass under Windows (preventing a backtrace at the same time, woot) --- lib/rbot/ircbot.rb | 19 +++++++++++++++++-- 1 file 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(/\/$/, "") -- 2.39.5