diff --git a/source/lib/res/file/tests/test_archive_builder.h b/source/lib/res/file/tests/test_archive_builder.h index 1b5ea99447..17f9d87854 100644 --- a/source/lib/res/file/tests/test_archive_builder.h +++ b/source/lib/res/file/tests/test_archive_builder.h @@ -88,20 +88,19 @@ public: path_init(); // required for file_make_unique_fn_copy (void)file_set_root_dir(0, "."); vfs_init(); - TS_ASSERT_OK(dir_create("archivetest", S_IRWXU|S_IRWXG|S_IRWXO)); - TS_ASSERT_OK(vfs_mount("", "archivetest")); } void tearDown() { vfs_shutdown(); - dir_delete("archivetest"); - file_delete(archive_fn); path_reset_root_dir(); } void test_create_archive_with_random_files() { + TS_ASSERT_OK(dir_create("archivetest", S_IRWXU|S_IRWXG|S_IRWXO)); + TS_ASSERT_OK(vfs_mount("", "archivetest")); + generate_random_files(); TS_ASSERT_OK(archive_build(archive_fn, filenames)); @@ -126,13 +125,15 @@ public: SAFE_ARRAY_DELETE(files[i].data); } TS_ASSERT_OK(archive_close(ha)); + + dir_delete("archivetest"); + file_delete(archive_fn); } void test_multiple_init_shutdown() { - vfs_init(); + // setUp has already vfs_init-ed it and tearDown will vfs_shutdown. vfs_shutdown(); vfs_init(); - vfs_shutdown(); } }; diff --git a/source/lib/res/file/vfs.cpp b/source/lib/res/file/vfs.cpp index f3afe7d4bd..e65fcb63d2 100644 --- a/source/lib/res/file/vfs.cpp +++ b/source/lib/res/file/vfs.cpp @@ -744,7 +744,7 @@ static enum VfsInitState VFS_INITIALIZED, VFS_SHUTDOWN } -vfs_init_state; +vfs_init_state = VFS_BEFORE_INIT; // make the VFS tree ready for use. must be called before all other // functions below, barring explicit mentions to the contrary. diff --git a/source/lib/res/file/vfs_optimizer.cpp b/source/lib/res/file/vfs_optimizer.cpp index d7becb34eb..da99ecba05 100644 --- a/source/lib/res/file/vfs_optimizer.cpp +++ b/source/lib/res/file/vfs_optimizer.cpp @@ -570,11 +570,13 @@ static LibError vfs_opt_init(const char* trace_filename, const char* archive_fn_ // note: this is needed by should_rebuild_main_archive and later in // vfs_opt_continue; must be done here instead of inside the former // because that is not called when force_build == true. + { char dir[PATH_MAX]; path_dir_only(archive_fn_fmt, dir); RETURN_ERR(file_get_sorted_dirents(dir, existing_archives)); DirEntIt new_end = std::remove_if(existing_archives.begin(), existing_archives.end(), IsArchive(archive_fn)); existing_archives.erase(new_end, existing_archives.end()); + } // bail if we shouldn't rebuild the archive. if(!force_build && !should_rebuild_main_archive(trace_filename, existing_archives)) @@ -595,7 +597,7 @@ static LibError vfs_opt_init(const char* trace_filename, const char* archive_fn_ ConnectionBuilder cbuilder; RETURN_ERR(cbuilder.run(trace_filename, connections)); - // create output filelist by first adding the above edges (most + // create output filename list by first adding the above edges (most // frequent first) and then adding the rest sequentially. TourBuilder builder(file_nodes, connections, fn_vector); fn_vector.push_back(0); // 0-terminate for use as Filenames