[macruby-changes] [4486] MacRuby/trunk/lib/tmpdir.rb

source_changes at macosforge.org source_changes at macosforge.org
Tue Aug 31 22:11:56 PDT 2010


Revision: 4486
          http://trac.macosforge.org/projects/ruby/changeset/4486
Author:   lsansonetti at apple.com
Date:     2010-08-31 22:11:53 -0700 (Tue, 31 Aug 2010)
Log Message:
-----------
Dir.tmpdir: returns NSTemporaryDirectory() in last resort and not /tmp

Modified Paths:
--------------
    MacRuby/trunk/lib/tmpdir.rb

Modified: MacRuby/trunk/lib/tmpdir.rb
===================================================================
--- MacRuby/trunk/lib/tmpdir.rb	2010-09-01 03:45:08 UTC (rev 4485)
+++ MacRuby/trunk/lib/tmpdir.rb	2010-09-01 05:11:53 UTC (rev 4486)
@@ -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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100831/bb0b8ccc/attachment.html>


More information about the macruby-changes mailing list