summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--ext/bigdecimal/MANIFEST1
-rw-r--r--lib/cgi/session.rb3
-rw-r--r--lib/drb/unix.rb4
-rw-r--r--lib/tempfile.rb10
-rw-r--r--lib/tmpdir.rb26
6 files changed, 45 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 41514ed..4003a6a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Tue Jul 22 00:19:19 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * lib/tmpdir.rb: new library to get temporary directory path,
+ using GetTempPath on Win32 environment.
+
+ * lib/tempfile.rb: now uses tmpdir.rb.
+
+ * lib/cgi/session.rb, ib/drb/unix.rb: ditto.
+
Mon Jul 21 01:53:43 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
* string.c: use StringValueCStr to retrieve paths to system calls.
diff --git a/ext/bigdecimal/MANIFEST b/ext/bigdecimal/MANIFEST
index 8e9415e..88fc3c2 100644
--- a/ext/bigdecimal/MANIFEST
+++ b/ext/bigdecimal/MANIFEST
@@ -11,6 +11,7 @@ lib/bigdecimal/jacobian.rb
lib/bigdecimal/newton.rb
lib/bigdecimal/ludcmp.rb
lib/bigdecimal/util.rb
+lib/bigdecimal/nlsolve.rb
sample/linear.rb
sample/nlsolve.rb
sample/pi.rb
diff --git a/lib/cgi/session.rb b/lib/cgi/session.rb
index 9306508..ae4fb19 100644
--- a/lib/cgi/session.rb
+++ b/lib/cgi/session.rb
@@ -3,6 +3,7 @@
# Copyright (C) 2000 Information-technology Promotion Agency, Japan
require 'cgi'
+require 'tmpdir'
class CGI
class Session
@@ -109,7 +110,7 @@ class CGI
end
def initialize(session, option={})
- dir = option['tmpdir'] || ENV['TMP'] || '/tmp'
+ dir = option['tmpdir'] || Dir::TMPDIR
prefix = option['prefix'] || ''
id = session.session_id
unless check_id(id)
diff --git a/lib/drb/unix.rb b/lib/drb/unix.rb
index f9a2f75..6c6b703 100644
--- a/lib/drb/unix.rb
+++ b/lib/drb/unix.rb
@@ -1,5 +1,6 @@
require 'socket'
require 'drb/drb'
+require 'tmpdir'
module DRb
@@ -52,8 +53,7 @@ module DRb
Max_try = 10
private
def self.temp_server
- tmpdir = ENV['TMPDIR'] || ENV['TMP'] || ENV['TEMP'] || '/tmp'
- tmpdir = '/tmp' if $SAFE > 0 and tmpdir.tainted?
+ tmpdir = Dir::TMPDIR
n = 0
while true
begin
diff --git a/lib/tempfile.rb b/lib/tempfile.rb
index b122795..baaac8f 100644
--- a/lib/tempfile.rb
+++ b/lib/tempfile.rb
@@ -5,6 +5,7 @@
#
require 'delegate'
+require 'tmpdir'
# A class for managing temporary files. This library is written to be
# thread safe.
@@ -17,11 +18,10 @@ class Tempfile < SimpleDelegator
# object works just like a File object.
#
# If tmpdir is omitted, the temporary directory is determined by
- # ENV['TMPDIR'], ENV['TMP'] and and ENV['TEMP'] in the order named.
- # If none of them is available, or when $SAFE > 0 and the given
- # tmpdir is tainted, it uses /tmp. (Note that ENV values are
- # tainted by default)
- def initialize(basename, tmpdir=ENV['TMPDIR']||ENV['TMP']||ENV['TEMP']||'/tmp')
+ # Dir::TMPDIR provided by 'tmpdir.rb'.
+ # When $SAFE > 0 and the given tmpdir is tainted, it uses
+ # /tmp. (Note that ENV values are tainted by default)
+ def initialize(basename, tmpdir=Dir::TMPDIR)
if $SAFE > 0 and tmpdir.tainted?
tmpdir = '/tmp'
end
diff --git a/lib/tmpdir.rb b/lib/tmpdir.rb
new file mode 100644
index 0000000..5e8dd6b
--- /dev/null
+++ b/lib/tmpdir.rb
@@ -0,0 +1,26 @@
+#
+# tmpdir - retrieve temporary directory path
+#
+# $Id$
+#
+
+class Dir
+ begin
+ require "Win32API"
+ max_pathlen = 260
+ t_path = ' '*(max_pathlen+1)
+ t_path[0, Win32API.new('kernel32', 'GetTempPath', 'LP', 'L').call(t_path.size, t_path)]
+ t_path.untaint
+ TMPDIR = t_path
+ rescue LoadError
+ if $SAFE > 0
+ TMPDIR = '/tmp'
+ else
+ TMPDIR = ENV['TMPDIR']||ENV['TMP']||ENV['TEMP']||'/tmp'
+ end
+ end
+end
+
+if __FILE__ == $0
+ puts Dir::TMPDIR
+end