mirror of
https://github.com/open-goal/jak-project
synced 2026-07-09 06:53:45 -04:00
extractor: support extracting using a folder path (#3422)
Patching up the extractor while working on the launcher, fixes: - makes it so you can compile successfully given a folder path (currently assumes your project path contains `iso_data`) - ignore `buildinfo.json` from validation code. - fixes an edge-case that could recursively fill up your entire hard-drive! - allows overriding the decompilation configuration via flag - adds a way to specify where the ISO should be extracted to
This commit is contained in:
@@ -110,6 +110,8 @@ struct {
|
||||
fs::path path_to_data;
|
||||
} gFilePathInfo;
|
||||
|
||||
fs::path g_iso_data_directory = "";
|
||||
|
||||
/*!
|
||||
* Get the path to the current executable.
|
||||
*/
|
||||
@@ -207,6 +209,28 @@ fs::path get_jak_project_dir() {
|
||||
return gFilePathInfo.path_to_data;
|
||||
}
|
||||
|
||||
fs::path get_iso_dir_for_game(GameVersion game_version) {
|
||||
if (!g_iso_data_directory.empty()) {
|
||||
return g_iso_data_directory;
|
||||
}
|
||||
// Find the location based on the game version
|
||||
std::string expected_subdir = "jak1";
|
||||
if (game_version == GameVersion::Jak2) {
|
||||
expected_subdir = "jak2";
|
||||
} else if (game_version == GameVersion::Jak3) {
|
||||
expected_subdir = "jak3";
|
||||
}
|
||||
const auto temp_dir = get_jak_project_dir() / "iso_data" / expected_subdir;
|
||||
if (fs::exists(temp_dir)) {
|
||||
g_iso_data_directory = temp_dir;
|
||||
}
|
||||
return g_iso_data_directory;
|
||||
}
|
||||
|
||||
void set_iso_data_dir(const fs::path& directory) {
|
||||
g_iso_data_directory = directory;
|
||||
}
|
||||
|
||||
std::string get_file_path(const std::vector<std::string>& input) {
|
||||
// TODO - clean this behaviour up, it causes unexpected behaviour when working with files
|
||||
// the project path should be explicitly provided by whatever if needed
|
||||
@@ -757,4 +781,9 @@ std::pair<int, std::string> get_majority_file_line_endings_and_count(
|
||||
return {lf_count + crlf_count, "\n"};
|
||||
}
|
||||
|
||||
bool is_dir_in_dir(const fs::path& parent, const fs::path& child) {
|
||||
// Check if the parent path is a prefix of the child path
|
||||
return child.has_parent_path() && child.parent_path().lexically_relative(parent) == fs::path(".");
|
||||
}
|
||||
|
||||
} // namespace file_util
|
||||
|
||||
Reference in New Issue
Block a user