summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--lib/tmpdir.rb19
-rw-r--r--version.h2
3 files changed, 20 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index c9e5f26a6c..151f8b2052 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Wed Jul 2 18:19:45 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * lib/tmpdir.rb (@@systmpdir): prior LOCAL_APPDATA if possible, and
+ should be clean. based on a patch from arton <artonx AT
+ yahoo.co.jp> at [ruby-dev:35269]
+
Wed Jul 2 18:13:30 2008 Masaki Suketa <masaki.suketa@nifty.ne.jp>
* ext/win32ole/win32ole.c (date2time_str): fix the overflow in
diff --git a/lib/tmpdir.rb b/lib/tmpdir.rb
index 434d1bf053..7f9fd9a543 100644
--- a/lib/tmpdir.rb
+++ b/lib/tmpdir.rb
@@ -10,16 +10,23 @@ class Dir
begin
require 'Win32API'
+ CSIDL_LOCAL_APPDATA = 0x001c
max_pathlen = 260
windir = ' '*(max_pathlen+1)
begin
- getdir = Win32API.new('kernel32', 'GetSystemWindowsDirectory', 'PL', 'L')
+ getdir = Win32API.new('shell32', 'SHGetFolderPath', 'LLLLP', 'L')
+ raise RuntimeError if getdir.call(0, CSIDL_LOCAL_APPDATA, 0, 0, windir) != 0
+ windir = File.expand_path(windir.rstrip)
rescue RuntimeError
- getdir = Win32API.new('kernel32', 'GetWindowsDirectory', 'PL', 'L')
+ begin
+ getdir = Win32API.new('kernel32', 'GetSystemWindowsDirectory', 'PL', 'L')
+ rescue RuntimeError
+ getdir = Win32API.new('kernel32', 'GetWindowsDirectory', 'PL', 'L')
+ end
+ len = getdir.call(windir, windir.size)
+ windir = File.expand_path(windir[0, len])
end
- len = getdir.call(windir, windir.size)
- windir = File.expand_path(windir[0, len])
- temp = File.join(windir, 'temp')
+ temp = File.join(windir.untaint, 'temp')
@@systmpdir = temp if File.directory?(temp) and File.writable?(temp)
rescue LoadError
end
@@ -39,7 +46,7 @@ class Dir
break
end
end
+ File.expand_path(tmp)
end
- File.expand_path(tmp)
end
end
diff --git a/version.h b/version.h
index 71fa3a20d1..74e54493ce 100644
--- a/version.h
+++ b/version.h
@@ -2,7 +2,7 @@
#define RUBY_RELEASE_DATE "2008-07-02"
#define RUBY_VERSION_CODE 186
#define RUBY_RELEASE_CODE 20080702
-#define RUBY_PATCHLEVEL 259
+#define RUBY_PATCHLEVEL 260
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 8