mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@17643 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
803893b8e1
commit
08db814b84
2 changed files with 19 additions and 6 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
Sun Jun 29 09:43:10 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]
|
||||||
|
|
||||||
Sun Jun 29 08:03:08 2008 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
Sun Jun 29 08:03:08 2008 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
||||||
|
|
||||||
* ext/win32ole/win32ole.c (date2time_str): fix the overflow in
|
* ext/win32ole/win32ole.c (date2time_str): fix the overflow in
|
||||||
|
|
|
@ -12,8 +12,14 @@ class Dir
|
||||||
|
|
||||||
begin
|
begin
|
||||||
require 'Win32API'
|
require 'Win32API'
|
||||||
|
CSIDL_LOCAL_APPDATA = 0x001c
|
||||||
max_pathlen = 260
|
max_pathlen = 260
|
||||||
windir = ' '*(max_pathlen+1)
|
windir = ' '*(max_pathlen+1)
|
||||||
|
begin
|
||||||
|
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
|
||||||
begin
|
begin
|
||||||
getdir = Win32API.new('kernel32', 'GetSystemWindowsDirectory', 'PL', 'L')
|
getdir = Win32API.new('kernel32', 'GetSystemWindowsDirectory', 'PL', 'L')
|
||||||
rescue RuntimeError
|
rescue RuntimeError
|
||||||
|
@ -21,7 +27,8 @@ class Dir
|
||||||
end
|
end
|
||||||
len = getdir.call(windir, windir.size)
|
len = getdir.call(windir, windir.size)
|
||||||
windir = File.expand_path(windir[0, len])
|
windir = File.expand_path(windir[0, len])
|
||||||
temp = File.join(windir, 'temp')
|
end
|
||||||
|
temp = File.join(windir.untaint, 'temp')
|
||||||
@@systmpdir = temp if File.directory?(temp) and File.writable?(temp)
|
@@systmpdir = temp if File.directory?(temp) and File.writable?(temp)
|
||||||
rescue LoadError
|
rescue LoadError
|
||||||
end
|
end
|
||||||
|
@ -41,9 +48,9 @@ class Dir
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
File.expand_path(tmp)
|
File.expand_path(tmp)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Dir.mktmpdir creates a temporary directory.
|
# Dir.mktmpdir creates a temporary directory.
|
||||||
#
|
#
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue