Skip to content

Commit

Permalink
system: load <libpath>/../pkg if <libpath>/pkg doesn't exist but <lib…
Browse files Browse the repository at this point in the history
…path>/../pkg does
  • Loading branch information
illwieckz committed Nov 4, 2024
1 parent 559e2df commit 55c0989
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/engine/framework/System.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,25 @@ static void Init(int argc, char** argv)

// Initialize the filesystem. For pakpaths, the libpath is added first and has the
// lowest priority, while the homepath is added last and has the highest.
cmdlineArgs.pakPaths.insert(cmdlineArgs.pakPaths.begin(), FS::Path::Build(cmdlineArgs.libPath, "pkg"));

/* The default pakpath is <libpath>/pkg, but we load <libpath>/../pkg instead
if <libpath>/pkg doesn't exist but <libpath>/../pkg exists.
This is to make sure extracting the engine archive in a subfolder works.
Many file browsers create a parent directory when there is no directory in an archive. */
std::string defaultPakPath = FS::Path::Build(cmdlineArgs.libPath, "pkg");

std::error_code missing;
FS::RawPath::ListFiles(defaultPakPath, missing);
if (missing) {
std::string parentPakPath = FS::Path::Build(cmdlineArgs.libPath, FS::Path::Build("..", "pkg"));
FS::RawPath::ListFiles(parentPakPath, missing);
if (!missing) {
defaultPakPath = parentPakPath;
}
}

cmdlineArgs.pakPaths.insert(cmdlineArgs.pakPaths.begin(), defaultPakPath);

cmdlineArgs.pakPaths.push_back(FS::Path::Build(cmdlineArgs.homePath, "pkg"));
EarlyCvar("fs_legacypaks", cmdlineArgs);
FS::Initialize(cmdlineArgs.homePath, cmdlineArgs.libPath, cmdlineArgs.pakPaths);
Expand Down

0 comments on commit 55c0989

Please sign in to comment.