Skip to content
Browse files

Dir.tmpdir: returns NSTemporaryDirectory() in last resort and not /tmp

git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/trunk@4486 23306eb0-4c56-4727-a40e-e92c0eb68959
  • Loading branch information...
1 parent 2af1f13 commit 0639af17bf62b1d571b6076632da9034c4600308 Laurent Sansonetti committed
Showing with 10 additions and 4 deletions.
  1. +10 −4 lib/tmpdir.rb
View
14 lib/tmpdir.rb
@@ -12,22 +12,28 @@
class Dir
- @@systmpdir ||= defined?(Etc.systmpdir) ? Etc.systmpdir : '/tmp'
+ def Dir::systmpdir
+ @@systmpdir ||= begin
+ framework 'Foundation'
+ NSTemporaryDirectory()
+ end
+ end
##
# Returns the operating system's temporary file path.
def Dir::tmpdir
- tmp = '.'
+ tmp = nil
if $SAFE > 0
- tmp = @@systmpdir
+ tmp = systmpdir
else
- for dir in [ENV['TMPDIR'], ENV['TMP'], ENV['TEMP'], @@systmpdir, '/tmp']
+ for dir in [ENV['TMPDIR'], ENV['TMP'], ENV['TEMP']]
if dir and stat = File.stat(dir) and stat.directory? and stat.writable?
tmp = dir
break
end rescue nil
end
+ tmp ||= systmpdir
File.expand_path(tmp)
end
end

0 comments on commit 0639af1

Please sign in to comment.
Something went wrong with that request. Please try again.