ruby-changes:6131
From: nobu <ko1@a...>
Date: Sun, 29 Jun 2008 09:44:06 +0900 (JST)
Subject: [ruby-changes:6131] Ruby:r17643 (ruby_1_8, trunk): * lib/tmpdir.rb (@@systmpdir): prior LOCAL_APPDATA if possible, and
nobu 2008-06-29 09:43:12 +0900 (Sun, 29 Jun 2008)
New Revision: 17643
Modified files:
branches/ruby_1_8/ChangeLog
branches/ruby_1_8/lib/tmpdir.rb
trunk/ChangeLog
trunk/lib/tmpdir.rb
Log:
* 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]
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/lib/tmpdir.rb?r1=17643&r2=17642&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/ChangeLog?r1=17643&r2=17642&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=17643&r2=17642&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/tmpdir.rb?r1=17643&r2=17642&diff_format=u
Index: ChangeLog
===================================================================
--- ChangeLog (revision 17642)
+++ ChangeLog (revision 17643)
@@ -1,3 +1,9 @@
+Sun Jun 29 09:43:10 2008 Nobuyoshi Nakada <nobu@r...>
+
+ * 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]
+
Sun Jun 29 07:53:08 2008 Masaki Suketa <masaki.suketa@n...>
* ext/win32ole/win32ole.c (date2time_str): fix the overflow in
Index: lib/tmpdir.rb
===================================================================
--- lib/tmpdir.rb (revision 17642)
+++ lib/tmpdir.rb (revision 17643)
@@ -12,16 +12,23 @@
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
@@ -41,8 +48,8 @@
break
end
end
+ File.expand_path(tmp)
end
- File.expand_path(tmp)
end
# Dir.mktmpdir creates a temporary directory.
Index: ruby_1_8/ChangeLog
===================================================================
--- ruby_1_8/ChangeLog (revision 17642)
+++ ruby_1_8/ChangeLog (revision 17643)
@@ -1,3 +1,9 @@
+Sun Jun 29 09:43:10 2008 Nobuyoshi Nakada <nobu@r...>
+
+ * 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]
+
Sun Jun 29 08:03:08 2008 Masaki Suketa <masaki.suketa@n...>
* ext/win32ole/win32ole.c (date2time_str): fix the overflow in
Index: ruby_1_8/lib/tmpdir.rb
===================================================================
--- ruby_1_8/lib/tmpdir.rb (revision 17642)
+++ ruby_1_8/lib/tmpdir.rb (revision 17643)
@@ -12,16 +12,23 @@
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
@@ -41,8 +48,8 @@
break
end
end
+ File.expand_path(tmp)
end
- File.expand_path(tmp)
end
# Dir.mktmpdir creates a temporary directory.
--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/