DolphinTool: initialize user directories (fix unintential deletion of Wii files)
This commit is contained in:
parent
b756dc40bb
commit
4d125064fe
|
@ -13,6 +13,7 @@ set_target_properties(dolphin-tool PROPERTIES OUTPUT_NAME dolphin-tool)
|
||||||
target_link_libraries(dolphin-tool
|
target_link_libraries(dolphin-tool
|
||||||
PRIVATE
|
PRIVATE
|
||||||
discio
|
discio
|
||||||
|
uicommon
|
||||||
videocommon
|
videocommon
|
||||||
cpp-optparse
|
cpp-optparse
|
||||||
)
|
)
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include "DolphinTool/ConvertCommand.h"
|
#include "DolphinTool/ConvertCommand.h"
|
||||||
|
#include "UICommon/UICommon.h"
|
||||||
|
|
||||||
#include <OptionParser.h>
|
#include <OptionParser.h>
|
||||||
|
|
||||||
|
@ -13,6 +14,11 @@ int ConvertCommand::Main(const std::vector<std::string>& args)
|
||||||
|
|
||||||
parser->usage("usage: convert [options]... [FILE]...");
|
parser->usage("usage: convert [options]... [FILE]...");
|
||||||
|
|
||||||
|
parser->add_option("-u", "--user")
|
||||||
|
.action("store")
|
||||||
|
.help("User folder path, required for temporary processing files."
|
||||||
|
"Will be automatically created if this option is not set.");
|
||||||
|
|
||||||
parser->add_option("-i", "--input")
|
parser->add_option("-i", "--input")
|
||||||
.type("string")
|
.type("string")
|
||||||
.action("store")
|
.action("store")
|
||||||
|
@ -56,6 +62,15 @@ int ConvertCommand::Main(const std::vector<std::string>& args)
|
||||||
|
|
||||||
const optparse::Values& options = parser->parse_args(args);
|
const optparse::Values& options = parser->parse_args(args);
|
||||||
|
|
||||||
|
// Initialize the dolphin user directory, required for temporary processing files
|
||||||
|
// If this is not set, destructive file operations could occur due to path confusion
|
||||||
|
std::string user_directory;
|
||||||
|
if (options.is_set("user"))
|
||||||
|
user_directory = static_cast<const char*>(options.get("user"));
|
||||||
|
|
||||||
|
UICommon::SetUserDirectory(user_directory);
|
||||||
|
UICommon::Init();
|
||||||
|
|
||||||
// Validate options
|
// Validate options
|
||||||
|
|
||||||
// --input
|
// --input
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include "DolphinTool/VerifyCommand.h"
|
#include "DolphinTool/VerifyCommand.h"
|
||||||
|
#include "UICommon/UICommon.h"
|
||||||
|
|
||||||
#include <OptionParser.h>
|
#include <OptionParser.h>
|
||||||
|
|
||||||
|
@ -13,6 +14,11 @@ int VerifyCommand::Main(const std::vector<std::string>& args)
|
||||||
|
|
||||||
parser->usage("usage: verify [options]...");
|
parser->usage("usage: verify [options]...");
|
||||||
|
|
||||||
|
parser->add_option("-u", "--user")
|
||||||
|
.action("store")
|
||||||
|
.help("User folder path, required for temporary processing files."
|
||||||
|
"Will be automatically created if this option is not set.");
|
||||||
|
|
||||||
parser->add_option("-i", "--input")
|
parser->add_option("-i", "--input")
|
||||||
.type("string")
|
.type("string")
|
||||||
.action("store")
|
.action("store")
|
||||||
|
@ -28,6 +34,15 @@ int VerifyCommand::Main(const std::vector<std::string>& args)
|
||||||
|
|
||||||
const optparse::Values& options = parser->parse_args(args);
|
const optparse::Values& options = parser->parse_args(args);
|
||||||
|
|
||||||
|
// Initialize the dolphin user directory, required for temporary processing files
|
||||||
|
// If this is not set, destructive file operations could occur due to path confusion
|
||||||
|
std::string user_directory;
|
||||||
|
if (options.is_set("user"))
|
||||||
|
user_directory = static_cast<const char*>(options.get("user"));
|
||||||
|
|
||||||
|
UICommon::SetUserDirectory(user_directory);
|
||||||
|
UICommon::Init();
|
||||||
|
|
||||||
// Validate options
|
// Validate options
|
||||||
const std::string input_file_path = static_cast<const char*>(options.get("input"));
|
const std::string input_file_path = static_cast<const char*>(options.get("input"));
|
||||||
if (input_file_path.empty())
|
if (input_file_path.empty())
|
||||||
|
|
Loading…
Reference in New Issue