aboutsummaryrefslogtreecommitdiff
path: root/zenserver/frontend/frontend.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2022-09-05 11:04:15 +0200
committerGitHub <[email protected]>2022-09-05 02:04:15 -0700
commit14d140ee60821463a54dc45576e5c2273d0c2802 (patch)
treebe7661e11b4c6b61fcc07f8d2364b4fa27b8c61d /zenserver/frontend/frontend.cpp
parentDon't use -r option for 7z, it is not needed and picks up more than you expec... (diff)
downloadzen-14d140ee60821463a54dc45576e5c2273d0c2802.tar.xz
zen-14d140ee60821463a54dc45576e5c2273d0c2802.zip
Fix/safer html folder detection (#153)v0.1.4-pre26
* safer detection of html folder for frontend in debug mode * changelog
Diffstat (limited to 'zenserver/frontend/frontend.cpp')
-rw-r--r--zenserver/frontend/frontend.cpp28
1 files changed, 19 insertions, 9 deletions
diff --git a/zenserver/frontend/frontend.cpp b/zenserver/frontend/frontend.cpp
index e203e0631..1b6fe6378 100644
--- a/zenserver/frontend/frontend.cpp
+++ b/zenserver/frontend/frontend.cpp
@@ -163,20 +163,30 @@ HttpFrontendService::HttpFrontendService(std::filesystem::path Directory) : m_Di
}
std::error_code ErrorCode;
- for (auto Path = SelfPath.parent_path(); !Path.empty(); Path = Path.parent_path())
+ auto Path = SelfPath;
+ while (Path.has_parent_path())
{
- if (!std::filesystem::is_regular_file(Path / "xmake.lua", ErrorCode))
+ auto ParentPath = Path.parent_path();
+ if (ParentPath == Path)
{
- continue;
+ break;
}
-
- auto HtmlDir = (Path / __FILE__).parent_path() / "html";
- if (std::filesystem::is_directory(HtmlDir, ErrorCode))
+ if (std::filesystem::is_regular_file(ParentPath / "xmake.lua", ErrorCode))
{
- m_Directory = HtmlDir;
+ if (ErrorCode)
+ {
+ break;
+ }
+
+ auto HtmlDir = ParentPath / "zenserver" / "frontend" / "html";
+ if (std::filesystem::is_directory(HtmlDir, ErrorCode))
+ {
+ m_Directory = HtmlDir;
+ }
+ break;
}
- break;
- }
+ Path = ParentPath;
+ };
#endif
}