1
0
Fork 0
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:
Nobuyoshi Nakada 2022-10-25 16:07:09 +09:00 committed by git
parent d55f72bcdb
commit 883d9c305f

View file

@ -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.