setup_output_dir(op_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(op_dir, force)
flag_file = output_flag_file(op_dir)
if File.exist?(op_dir)
unless File.directory?(op_dir)
error "'#{op_dir}' exists, and is not a directory"
end
begin
created = File.read(flag_file)
rescue SystemCallError
error "\nDirectory #{op_dir} already exists, but it looks like it\n" +
"isn't an RDoc directory. Because RDoc doesn't want to risk\n" +
"destroying any of your existing files, you'll need to\n" +
"specify a different output directory name (using the\n" +
"--op <dir> option).\n\n"
else
last = (Time.parse(created) unless force rescue nil)
end
else
FileUtils.mkdir_p(op_dir)
end
last
end