mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Accept a nonexistent game local path when creating game handle
This gives a better user experience when LOOT is launched before the game's launcher has been run.
This commit is contained in:
+2
-2
@@ -98,8 +98,8 @@ endif()
|
||||
|
||||
ExternalProject_Add(libloadorder
|
||||
PREFIX "external"
|
||||
URL "https://github.com/Ortham/libloadorder/archive/14.1.0.tar.gz"
|
||||
URL_HASH "SHA256=9ff9c73612bc9e375759e122bfd56a4a45d8a4ca36837f610c05ab52fef9d67b"
|
||||
URL "https://github.com/Ortham/libloadorder/archive/14.2.0.tar.gz"
|
||||
URL_HASH "SHA256=247969e3fb67ad0a883ac81ac52a4258ee92b8417d11f45308cc23ccc0d61b36"
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_IN_SOURCE 1
|
||||
BUILD_COMMAND cargo build --release --manifest-path ffi/Cargo.toml --target ${RUST_TARGET} &&
|
||||
|
||||
+8
-5
@@ -112,15 +112,18 @@ LOOT_API std::unique_ptr<GameInterface> CreateGameHandle(
|
||||
}
|
||||
|
||||
auto resolvedGamePath = ResolvePath(gamePath);
|
||||
if (!fs::is_directory(resolvedGamePath))
|
||||
if (!fs::is_directory(resolvedGamePath)) {
|
||||
throw std::invalid_argument("Given game path \"" + gamePath.u8string() +
|
||||
"\" does not resolve to a valid directory.");
|
||||
}
|
||||
|
||||
auto resolvedGameLocalPath = ResolvePath(gameLocalPath);
|
||||
if (!gameLocalPath.empty() && !fs::is_directory(resolvedGameLocalPath))
|
||||
throw std::invalid_argument("Given game local path \"" +
|
||||
gameLocalPath.u8string() +
|
||||
"\" does not resolve to a valid directory.");
|
||||
if (!gameLocalPath.empty() && fs::exists(resolvedGameLocalPath) &&
|
||||
!fs::is_directory(resolvedGameLocalPath)) {
|
||||
throw std::invalid_argument(
|
||||
"Given game local path \"" + gameLocalPath.u8string() +
|
||||
"\" resolves to a path that exists but is not a valid directory.");
|
||||
}
|
||||
|
||||
return std::make_unique<Game>(game, resolvedGamePath, resolvedGameLocalPath);
|
||||
}
|
||||
|
||||
@@ -115,9 +115,15 @@ TEST_P(CreateGameHandleTest, shouldThrowIfPassedAGamePathThatDoesNotExist) {
|
||||
std::invalid_argument);
|
||||
}
|
||||
|
||||
TEST_P(CreateGameHandleTest, shouldThrowIfPassedALocalPathThatDoesNotExist) {
|
||||
TEST_P(CreateGameHandleTest, shouldSucceedIfPassedALocalPathThatDoesNotExist) {
|
||||
EXPECT_NO_THROW(handle_ = CreateGameHandle(
|
||||
GetParam(), dataPath.parent_path(), missingPath));
|
||||
EXPECT_TRUE(handle_);
|
||||
}
|
||||
|
||||
TEST_P(CreateGameHandleTest, shouldThrowIfPassedALocalPathThatIsNotADirectory) {
|
||||
EXPECT_THROW(
|
||||
CreateGameHandle(GetParam(), dataPath.parent_path(), missingPath),
|
||||
CreateGameHandle(GetParam(), dataPath.parent_path(), dataPath / blankEsm),
|
||||
std::invalid_argument);
|
||||
}
|
||||
|
||||
|
||||
@@ -122,10 +122,19 @@ TEST_P(LoadOrderHandlerTest, constructorShouldThrowIfNoGamePathIsSet) {
|
||||
std::invalid_argument);
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
TEST_P(LoadOrderHandlerTest, constructorShouldThrowOnLinuxIfNoLocalPathIsSet) {
|
||||
EXPECT_THROW(LoadOrderHandler(GetParam(), dataPath.parent_path()),
|
||||
std::system_error);
|
||||
#ifdef _WIN32
|
||||
TEST_P(LoadOrderHandlerTest, constructorShouldNotThrowIfNoLocalPathIsSet) {
|
||||
EXPECT_NO_THROW(LoadOrderHandler(GetParam(), dataPath.parent_path()));
|
||||
}
|
||||
#else
|
||||
TEST_P(LoadOrderHandlerTest,
|
||||
constructorShouldNotThrowIfNoLocalPathIsSetAndGameTypeIsMorrowind) {
|
||||
if (GetParam() == GameType::tes3) {
|
||||
EXPECT_NO_THROW(LoadOrderHandler(GetParam(), dataPath.parent_path()));
|
||||
} else {
|
||||
EXPECT_THROW(LoadOrderHandler(GetParam(), dataPath.parent_path()),
|
||||
std::system_error);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user