Tools/Extractors: Warn when casc storage could not be opened in remote mode because a local installation was detected in input/cache directory

This commit is contained in:
Shauren
2023-06-23 10:27:44 +02:00
parent 9ad1e5d635
commit 8ffc4c1034
3 changed files with 13 additions and 2 deletions

View File

@@ -47,6 +47,7 @@ char const* CASC::HumanReadableCASCError(uint32 error)
case ERROR_ACCESS_DENIED: return "ACCESS_DENIED";
case ERROR_FILE_NOT_FOUND: return "FILE_NOT_FOUND";
case ERROR_FILE_ENCRYPTED: return "FILE_ENCRYPTED";
case ERROR_FILE_OFFLINE: return "FILE_OFFLINE";
default: return "UNKNOWN";
}
}
@@ -210,6 +211,15 @@ CASC::Storage* CASC::Storage::OpenRemote(boost::filesystem::path const& path, ui
return nullptr;
}
DWORD features = 0;
if (!GetStorageInfo(handle, CascStorageFeatures, &features) || !(features & CASC_FEATURE_ONLINE))
{
printf("Local casc storage detected in cache path \"%s\" (or its parent directory). Remote storage not opened!\n", args.szLocalPath);
CascCloseStorage(handle);
SetCascError(ERROR_FILE_OFFLINE);
return nullptr;
}
printf("Opened remote casc storage '%s'\n", path.string().c_str());
Storage* storage = new Storage(handle);

View File

@@ -148,7 +148,8 @@ void CreateDir(boost::filesystem::path const& path)
if (fs::exists(path))
return;
if (!fs::create_directory(path))
boost::system::error_code err;
if (!fs::create_directory(path, err) || err)
throw std::runtime_error("Unable to create directory" + path.string());
}

View File

@@ -49,7 +49,7 @@ namespace VMAP
TileAssembler::TileAssembler(const std::string& pSrcDirName, const std::string& pDestDirName)
: iDestDir(pDestDirName), iSrcDir(pSrcDirName)
{
boost::filesystem::create_directory(iDestDir);
boost::filesystem::create_directories(iDestDir);
}
TileAssembler::~TileAssembler()