summaryrefslogtreecommitdiff
path: root/lib/rbot/utils.rb
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2006-10-15 21:09:43 +0000
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2006-10-15 21:09:43 +0000
commit6c0ef220d25d7a569c38e53730377a2ff8eb92b7 (patch)
tree69c4486ec7dcb8971745fbc64b36f0d707fcc96e /lib/rbot/utils.rb
parentfa5cda0fe01afd7e06560ab28a3d125e81d14ec9 (diff)
Safe-save tempfiles are now created in a botclass-local directory, because atomic renaming only works within a filesystem
Diffstat (limited to 'lib/rbot/utils.rb')
-rw-r--r--lib/rbot/utils.rb8
1 files changed, 7 insertions, 1 deletions
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