use temporary files to avoid permission errors on Windows
This commit is contained in:
parent
9dc04b648c
commit
684410836c
|
@ -60,18 +60,16 @@ shared_context "unit" do
|
||||||
#
|
#
|
||||||
# @return [Pathname]
|
# @return [Pathname]
|
||||||
def temporary_file(contents=nil)
|
def temporary_file(contents=nil)
|
||||||
f = Tempfile.new("vagrant-unit")
|
dir = temporary_dir
|
||||||
|
f = dir.join("tempfile")
|
||||||
|
|
||||||
if contents
|
contents ||= ""
|
||||||
|
f.open("w") do |f|
|
||||||
f.write(contents)
|
f.write(contents)
|
||||||
f.flush
|
f.flush
|
||||||
end
|
end
|
||||||
|
|
||||||
# Store the tempfile in an instance variable so that it is not
|
return Pathname.new(Vagrant::Util::Platform.fs_real_path(f.to_s))
|
||||||
# garbage collected, so that the tempfile is not unlinked.
|
|
||||||
@_temp_files << f
|
|
||||||
|
|
||||||
return Pathname.new(f.path)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# This creates a temporary directory and returns a {Pathname}
|
# This creates a temporary directory and returns a {Pathname}
|
||||||
|
|
Loading…
Reference in New Issue