New tmpdir.rb in CVS /lib

'ello,

Could we know why the change from using GetTempPath in the new tmpdir.rb

A) Access permissions ?
B) Problem under Terminal Server ?
C) No Unicode support ?
D) tmpdir should be personal to user ?
E) tmpdir should be common to all users on system ?
F) Not available on all Win32 versions.
G) Don’t worry, just testing.
H) Similar to G), but we ‘screwed-up’ for the very first time :wink:
I) Other ?

···

Thu Jul 24 01:32:04 2003 WATANABE Hirofumi eban@ruby-lang.org

* lib/tmpdir.rb (tmpdir): new method. remove TMPDIR.

use GetSystemWindowsDirectory(GetSystemDirectory), not GetTempPath.

</>

http://www.ruby-lang.org/cgi-bin/cvsweb.cgi/~checkout~/ruby/lib/tmpdir.rb?rev=1.4

Here is a (mutilated) section with my results:

@@systmpdir = '/tmp’
require 'Win32API’
max_pathlen = 260
windir = ’ '*(max_pathlen+1)
begin
getdir = Win32API.new(‘kernel32’, ‘GetSystemWindowsDirectory’, ‘PL’, ‘L’)
rescue RuntimeError => e
p ’ RuntimeError expected here (Win98se)'
p e
getdir = Win32API.new(‘kernel32’, ‘GetSystemDirectory’, ‘PL’, ‘L’)
end
getdir.call(windir, windir.size)
windir = File.expand_path(windir.rstrip.untaint)
temp = File.join(windir, ‘temp’)
@@systmpdir = temp if File.directory?(temp) and File.writable?(temp)

puts ‘-’ * 50
p [temp, @@systmpdir]
puts File.directory?(temp)
puts File.writable?(temp)


" RuntimeError expected here (Win98se)"
#<RuntimeError: GetProcAddress: GetSystemWindowsDirectory or GetSystemWindowsDirectoryA>

[“C:/WINDOWS/SYSTEM/temp”, “/tmp”]
false
false
</>

Apps should never store into C:\WINDOWS\SYSTEM (and no \temp dir in there).
So GetSystemDirectory is not good.

GetSystemWindowsDirectory

The GetSystemWindowsDirectory function retrieves the path of the
shared Windows directory on a multi-user system.

This function is provided primarily for compatibility.
</>

Why do you want the Windows directory ? … and if you do …

windir = File.expand_path(ENV[‘WINDIR’])
temp = File.join(windir, ‘temp’)
@@systmpdir = temp if File.directory?(temp) and File.writable?(temp)
p [temp, @@systmpdir]

["C:/WINDOWS/temp", "C:/WINDOWS/temp"]

I see %WINDIR%\temp as a dir for Windows OS and, perhaps, MS apps to use.

Thanks,

daz
(Feel free to ignore this)

Hi,

···

In message “New tmpdir.rb in CVS /lib” on 03/07/27, “daz” dooby@d10.karoo.co.uk writes:

Could we know why the change from using GetTempPath in the new tmpdir.rb

A) Access permissions ?
B) Problem under Terminal Server ?
C) No Unicode support ?
D) tmpdir should be personal to user ?
E) tmpdir should be common to all users on system ?
F) Not available on all Win32 versions.
G) Don’t worry, just testing.
H) Similar to G), but we ‘screwed-up’ for the very first time :wink:
I) Other ?

# Thu Jul 24 01:32:04 2003 WATANABE Hirofumi # # * lib/tmpdir.rb (tmpdir): new method. remove TMPDIR. # use GetSystemWindowsDirectory(GetSystemDirectory), not GetTempPath.

From things I’ve heard, behavior of GetTempPath varies Windows version
to version, besides it uses environment variable inside which make
taintness check difficult.

						matz.

Hi,

“daz” dooby@d10.karoo.co.uk writes:

Why do you want the Windows directory ? … and if you do …

I should have used GetWindowsDirectory. Fixed. Thanks.

···


eban