Skip to content

Commit

Permalink
Move to AppData
Browse files Browse the repository at this point in the history
  • Loading branch information
fcharlie committed Mar 13, 2022
1 parent f4b9f85 commit 5d95c49
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
4 changes: 2 additions & 2 deletions AppExec/appsettings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace priv {

bool AppInitializeSettings(AppSettings &as) {
auto file = PathSearcher::Instance().JoinEtc(L"AppExec.json");
auto file = PathSearcher::Instance().JoinAppData(L"Privexec\\AppExec.json");
FD fd;
if (_wfopen_s(&fd.fd, file.data(), L"rb") != 0) {
return false;
Expand All @@ -29,7 +29,7 @@ bool AppInitializeSettings(AppSettings &as) {
}

bool AppApplySettings(const AppSettings &as) {
auto file = PathSearcher::Instance().JoinEtc(L"AppExec.json");
auto file = PathSearcher::Instance().JoinAppData(L"Privexec\\AppExec.json");
std::filesystem::path p(file);
auto parent = p.parent_path();
std::error_code e;
Expand Down
4 changes: 2 additions & 2 deletions Privexec/appalias.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ bool AppAliasInitializeBuilt(std::wstring_view file) {

std::wstring AppAliasFile() {
//
return PathSearcher::Instance().JoinEtc(L"Privexec.json");
return PathSearcher::Instance().JoinAppData(L"Privexec\\Privexec.json");
}

bool AppAliasInitialize(HWND hbox, priv::alias_t &alias) {
auto file = PathSearcher::Instance().JoinEtc(L"Privexec.json");
auto file = PathSearcher::Instance().JoinAppData(L"Privexec\\Privexec.json");
if (!bela::PathExists(file)) {
if (!AppAliasInitializeBuilt(file)) {
return false;
Expand Down
6 changes: 6 additions & 0 deletions include/vfsenv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,18 @@ class PathSearcher {
}
std::wstring JoinEtc(std::wstring_view p) { return (etc / p).wstring(); }
std::wstring JoinPath(std::wstring_view p) { return (basePath / p).wstring(); }
std::wstring JoinAppData(std::wstring_view p) { return (appdata / p).wstring(); }

private:
std::filesystem::path etc;
std::filesystem::path basePath;
std::filesystem::path appdata;
PathSearcher() {
bela::error_code ec;
if (!vfsInitialize(ec)) {
etc = std::filesystem::path{L"."};
basePath = std::filesystem::path{L"."};
appdata = std::filesystem::path{L"."};
}
}

Expand Down Expand Up @@ -74,13 +77,15 @@ class PathSearcher {
auto mode = it->get<std::string>();
if (!bela::EqualsIgnoreCase(mode, "Legacy")) {
etc = basePath / L"etc";
appdata = basePath / L"appdata";
return true;
}
}
} catch (const std::exception &) {
return false;
}
etc = basePath / L"bin\\etc";
appdata = basePath / L"bin\\appdata";
return true;
}

Expand All @@ -92,6 +97,7 @@ class PathSearcher {
auto baulkExePath = basePath / baulkExe;
if (std::filesystem::exists(baulkExePath, e)) {
etc = basePath / L"bin\\etc";
appdata = basePath / L"bin\\appdata";
return true;
}
basePath = basePath.parent_path();
Expand Down
4 changes: 2 additions & 2 deletions wsudo/wsudoalias.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ wsudo::AliasEngine::~AliasEngine() {
}

bool wsudo::AliasEngine::Initialize(bool verbose) {
auto file = priv::PathSearcher::Instance().JoinEtc(L"Privexec.json");
auto file = priv::PathSearcher::Instance().JoinAppData(L"Privexec\\Privexec.json");
DbgPrint(L"use %s", file);
priv::FD fd;
if (auto en = _wfopen_s(&fd.fd, file.data(), L"rb"); en != 0) {
Expand Down Expand Up @@ -49,7 +49,7 @@ std::optional<std::wstring> wsudo::AliasEngine::Target(std::wstring_view al) {
}

bool wsudo::AliasEngine::Apply() {
auto file = priv::PathSearcher::Instance().JoinEtc(L"Privexec.json");
auto file = priv::PathSearcher::Instance().JoinAppData(L"Privexec\\Privexec.json");
DbgPrint(L"use %s", file);
std::filesystem::path p(file);
auto parent = p.parent_path();
Expand Down

0 comments on commit 5d95c49

Please sign in to comment.