diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-03-16 06:20:23 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-03-16 06:20:23 +0000 |
commit | 3694f1dda70923b2acc66af6553c422ba87daddd (patch) | |
tree | 0d45296d39a940100f86a76f75a4a345312a78a7 /lib/tmpdir.rb | |
parent | 724f1f4a6e3698d1a34ca3442a6cb3e890e94a99 (diff) | |
download | ruby-3694f1dda70923b2acc66af6553c422ba87daddd.tar.gz |
* ext/tmpdir: split from lib/tmpdir.rb.
* win32/win32.c (rb_w32_system_tmpdir): extracted from init_env.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/tmpdir.rb')
-rw-r--r-- | lib/tmpdir.rb | 32 |
1 files changed, 5 insertions, 27 deletions
diff --git a/lib/tmpdir.rb b/lib/tmpdir.rb index 32befa3e8a..302c2fb39f 100644 --- a/lib/tmpdir.rb +++ b/lib/tmpdir.rb @@ -5,36 +5,14 @@ # require 'fileutils' +begin + require 'tmpdir.so' +rescue LoadError +end class Dir - @@systmpdir = '/tmp' - - if /mswin|mingw|cygwin/ =~ RUBY_PLATFORM and - begin - require 'Win32API' - true - rescue LoadError - end - CSIDL_LOCAL_APPDATA = 0x001c - max_pathlen = 260 - windir = "\0"*(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.rstrip! - rescue RuntimeError - begin - getdir = Win32API.new('kernel32', 'GetSystemWindowsDirectory', 'PL', 'L') - rescue RuntimeError - getdir = Win32API.new('kernel32', 'GetWindowsDirectory', 'PL', 'L') - end - windir[getdir.call(windir, windir.size)..-1] = "" - end - windir.force_encoding(Dir.pwd.encoding) - temp = File.expand_path('temp', windir.untaint) - @@systmpdir = temp if File.directory?(temp) and File.writable?(temp) - end + @@systmpdir ||= '/tmp' ## # Returns the operating system's temporary file path. |