diff --git a/addons/gut/doubler.gd b/addons/gut/doubler.gd index c6736ed3..b40695d4 100644 --- a/addons/gut/doubler.gd +++ b/addons/gut/doubler.gd @@ -159,19 +159,29 @@ func double(path): return load(_double(path)) func clear_output_directory(): - var d = Directory.new() - d.open(_output_dir) - d.list_dir_begin(true) - var files = [] - var f = d.get_next() - while(f != ''): - d.remove(f) - f = d.get_next() + var did = false + if(_output_dir.find('user://') == 0): + var d = Directory.new() + var result = d.open(_output_dir) + # BIG GOTCHA HERE. If it cannot open the dir w/ erro 31, then the + # directory becomes res:// and things go on normally and gut clears out + # out res:// which is SUPER BAD. + if(result == OK): + d.list_dir_begin(true) + var files = [] + var f = d.get_next() + while(f != ''): + print('deleting ', f) + d.remove(f) + f = d.get_next() + did = true + return did func delete_output_directory(): - clear_output_directory() - var d = Directory.new() - d.remove(_output_dir) + var did = clear_output_directory() + if(did): + var d = Directory.new() + d.remove(_output_dir) func set_use_unique_names(should): _use_unique_names = should