Skip to content

Commit 456042c

Browse files
committed
merge revision(s) 17643:
* 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_7@17801 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 8ab6e3a commit 456042c

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Wed Jul 2 18:22:52 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
2+
3+
* lib/tmpdir.rb (@@systmpdir): prior LOCAL_APPDATA if possible, and
4+
should be clean. based on a patch from arton <artonx AT
5+
yahoo.co.jp> at [ruby-dev:35269]
6+
17
Wed Jul 2 18:16:19 2008 Masaki Suketa <masaki.suketa@nifty.ne.jp>
28

39
* ext/win32ole/win32ole.c (date2time_str): fix the overflow in

lib/tmpdir.rb

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,23 @@ class Dir
1212

1313
begin
1414
require 'Win32API'
15+
CSIDL_LOCAL_APPDATA = 0x001c
1516
max_pathlen = 260
1617
windir = ' '*(max_pathlen+1)
1718
begin
18-
getdir = Win32API.new('kernel32', 'GetSystemWindowsDirectory', 'PL', 'L')
19+
getdir = Win32API.new('shell32', 'SHGetFolderPath', 'LLLLP', 'L')
20+
raise RuntimeError if getdir.call(0, CSIDL_LOCAL_APPDATA, 0, 0, windir) != 0
21+
windir = File.expand_path(windir.rstrip)
1922
rescue RuntimeError
20-
getdir = Win32API.new('kernel32', 'GetWindowsDirectory', 'PL', 'L')
23+
begin
24+
getdir = Win32API.new('kernel32', 'GetSystemWindowsDirectory', 'PL', 'L')
25+
rescue RuntimeError
26+
getdir = Win32API.new('kernel32', 'GetWindowsDirectory', 'PL', 'L')
27+
end
28+
len = getdir.call(windir, windir.size)
29+
windir = File.expand_path(windir[0, len])
2130
end
22-
len = getdir.call(windir, windir.size)
23-
windir = File.expand_path(windir[0, len])
24-
temp = File.join(windir, 'temp')
31+
temp = File.join(windir.untaint, 'temp')
2532
@@systmpdir = temp if File.directory?(temp) and File.writable?(temp)
2633
rescue LoadError
2734
end
@@ -41,8 +48,8 @@ def Dir::tmpdir
4148
break
4249
end
4350
end
51+
File.expand_path(tmp)
4452
end
45-
File.expand_path(tmp)
4653
end
4754

4855
# Dir.mktmpdir creates a temporary directory.

version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define RUBY_RELEASE_DATE "2008-07-02"
33
#define RUBY_VERSION_CODE 187
44
#define RUBY_RELEASE_CODE 20080702
5-
#define RUBY_PATCHLEVEL 41
5+
#define RUBY_PATCHLEVEL 42
66

77
#define RUBY_VERSION_MAJOR 1
88
#define RUBY_VERSION_MINOR 8

0 commit comments

Comments
 (0)