mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[ruby/tmpdir] Found or raise
This commit is contained in:
parent
d55f72bcdb
commit
883d9c305f
1 changed files with 2 additions and 4 deletions
|
@ -19,7 +19,7 @@ class Dir
|
|||
# Returns the operating system's temporary file path.
|
||||
|
||||
def self.tmpdir
|
||||
tmp = ['TMPDIR', 'TMP', 'TEMP', ['system temporary path', @@systmpdir], ['/tmp']*2, ['.']*2].find do |name, dir = ENV[name]|
|
||||
['TMPDIR', 'TMP', 'TEMP', ['system temporary path', @@systmpdir], ['/tmp']*2, ['.']*2].find do |name, dir = ENV[name]|
|
||||
next if !dir
|
||||
dir = File.expand_path(dir)
|
||||
stat = File.stat(dir) rescue next
|
||||
|
@ -33,9 +33,7 @@ class Dir
|
|||
else
|
||||
break dir
|
||||
end
|
||||
end
|
||||
raise ArgumentError, "could not find a temporary directory" unless tmp
|
||||
tmp
|
||||
end or raise ArgumentError, "could not find a temporary directory"
|
||||
end
|
||||
|
||||
# Dir.mktmpdir creates a temporary directory.
|
||||
|
|
Loading…
Reference in a new issue