diff options
author | B Stack <bgstack15@gmail.com> | 2021-02-02 11:44:31 -0500 |
---|---|---|
committer | B Stack <bgstack15@gmail.com> | 2021-02-02 11:44:31 -0500 |
commit | d299ddd2f27a437f0fc0cb49abdfd6dd8e3d94f8 (patch) | |
tree | 4d7c950512836f473a6a8cbb521c61e800db6584 /FreeFileSync/Source/ffs_paths.cpp | |
parent | Merge branch '11.5' into 'master' (diff) | |
download | FreeFileSync-d299ddd2f27a437f0fc0cb49abdfd6dd8e3d94f8.tar.gz FreeFileSync-d299ddd2f27a437f0fc0cb49abdfd6dd8e3d94f8.tar.bz2 FreeFileSync-d299ddd2f27a437f0fc0cb49abdfd6dd8e3d94f8.zip |
add upstream 11.6
Diffstat (limited to 'FreeFileSync/Source/ffs_paths.cpp')
-rw-r--r-- | FreeFileSync/Source/ffs_paths.cpp | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/FreeFileSync/Source/ffs_paths.cpp b/FreeFileSync/Source/ffs_paths.cpp index 3b058270..6a81257e 100644 --- a/FreeFileSync/Source/ffs_paths.cpp +++ b/FreeFileSync/Source/ffs_paths.cpp @@ -7,7 +7,6 @@ #include "ffs_paths.h" #include <zen/file_access.h> #include <zen/thread.h> -#include <zen/symlink_target.h> #include <zen/sys_info.h> #include <wx/stdpaths.h> #include <wx/app.h> @@ -26,21 +25,27 @@ Zstring getProcessParentFolderPath() //note: compiler generates magic-statics code => fine, we don't expect accesses during shutdown => don't need FunStatGlobal<> static const Zstring exeFolderParentPath = [] { - Zstring exeFolderPath = beforeLast(utfTo<Zstring>(wxStandardPaths::Get().GetExecutablePath()), FILE_NAME_SEPARATOR, IfNotFoundReturn::none); try { - //get rid of relative path fragments, e.g.: C:\Data\Projects\FreeFileSync\Source\..\Build\Bin - exeFolderPath = getSymlinkResolvedPath(exeFolderPath); //throw FileError + const Zstring exePath = getRealProcessPath(); //throw FileError + const Zstring parentFolderPath = beforeLast(exePath, FILE_NAME_SEPARATOR, IfNotFoundReturn::none); + return beforeLast(parentFolderPath, FILE_NAME_SEPARATOR, IfNotFoundReturn::none); + } + catch (const FileError& e) + { + throw std::runtime_error(std::string(__FILE__) + '[' + numberTo<std::string>(__LINE__) + "] " + utfTo<std::string>(e.toString())); } - catch (FileError&) { assert(false); } - - return beforeLast(exeFolderPath, FILE_NAME_SEPARATOR, IfNotFoundReturn::none); }(); return exeFolderParentPath; } } +Zstring fff::getInstallDirPath() +{ + return getProcessParentFolderPath(); + +} //getFfsVolumeId() might be called during static destruction, e.g. async update check @@ -48,7 +53,7 @@ VolumeId fff::getFfsVolumeId() //throw FileError { static VolumeId volumeId; //POD => no "magic static" code gen static constinit2 std::once_flag onceFlagGetFfsVolumeId; //=> no "magic static" code gen - std::call_once(onceFlagGetFfsVolumeId, [] { volumeId = getVolumeId(getProcessPath()); }); //throw FileError + std::call_once(onceFlagGetFfsVolumeId, [] { volumeId = getVolumeId(getRealProcessPath()); }); //throw FileError return volumeId; } @@ -68,6 +73,8 @@ Zstring fff::getResourceDirPf() Zstring fff::getConfigDirPathPf() { + warn_static("Linux/macOS TODO: consider getuid() == 0 as request for elevation, NOT impersonation") + //note: compiler generates magic-statics code => fine, we don't expect accesses during shutdown static const Zstring cfgFolderPathPf = [] { |