setup_output_dir(dir, force)
public
Create an output dir if it doesn’t exist. If it does exist, but doesn’t
contain the flag file created.rid then we refuse to use it, as we
may clobber some manually generated documentation
Show source
def setup_output_dir(dir, force)
flag_file = output_flag_file dir
last = {}
if @options.dry_run then
elsif File.exist? dir then
error "#{dir} exists and is not a directory" unless File.directory? dir
begin
open flag_file do |io|
unless force then
Time.parse io.gets
io.each do |line|
file, time = line.split "\t", 2
time = Time.parse(time) rescue next
last[file] = time
end
end
end
rescue SystemCallError, TypeError
error Directory
end unless @options.force_output
else
FileUtils.mkdir_p dir
FileUtils.touch output_flag_file dir
end
last
end