summaryrefslogtreecommitdiff
path: root/lib/rbot
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rbot')
-rw-r--r--lib/rbot/ircbot.rb2
-rw-r--r--lib/rbot/utils.rb8
2 files changed, 9 insertions, 1 deletions
diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb
index ac7aa829..8249895b 100644
--- a/lib/rbot/ircbot.rb
+++ b/lib/rbot/ircbot.rb
@@ -266,6 +266,8 @@ class IrcBot
Dir.mkdir("#{botclass}/logs") unless File.exist?("#{botclass}/logs")
Dir.mkdir("#{botclass}/registry") unless File.exist?("#{botclass}/registry")
+ Dir.mkdir("#{botclass}/safe_save") unless File.exist?("#{botclass}/safe_save")
+ Utils.set_safe_save_dir("#{botclass}/safe_save")
@ping_timer = nil
@pong_timer = nil
diff --git a/lib/rbot/utils.rb b/lib/rbot/utils.rb
index ae45e5d5..d1052390 100644
--- a/lib/rbot/utils.rb
+++ b/lib/rbot/utils.rb
@@ -320,9 +320,15 @@ module Irc
end
+ @@safe_save_dir = nil
+ def Utils.set_safe_save_dir(str)
+ @@safe_save_dir = str.dup
+ end
+
def Utils.safe_save(file)
+ raise 'No safe save directory defined!' if @@safe_save_dir.nil?
basename = File.basename(file)
- temp = Tempfile.new(basename)
+ temp = Tempfile.new(basename,@@safe_save_dir)
temp.binmode
yield temp if block_given?
temp.close