std::string GetInstallPath() { // 1. Try command line argument auto path = std::string(gCustomOpenrctDataPath); if (!path.empty()) { path = Path::GetAbsolute(path); } else { // 2. Try ${exeDir}/data auto exePath = Platform::GetCurrentExecutablePath(); auto exeDirectory = Path::GetDirectory(exePath); path = Path::Combine(exeDirectory, "data"); if (!Path::DirectoryExists(path)) { // 3. Try standard system app directories path = FindInstallPath(); if (path.empty()) { // 4. Fallback to ${cwd}/data path = GetCurrentWorkingDirectory(); if (!path.empty()) { path = Path::Combine(path, "data"); } else { return "/"; } } } } return path; }
void CInstallPathDlg::OnSearch() { if (FindInstallPath(m_strPath)) UpdateData(FALSE); }