Skip to content

system: load <libpath>/../pkg if <libpath>/pkg doesn't exist but <libpath>/../pkg does #1413

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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