diff options
author | B Stack <bgstack15@gmail.com> | 2020-04-18 17:00:42 +0000 |
---|---|---|
committer | B Stack <bgstack15@gmail.com> | 2020-04-18 17:00:42 +0000 |
commit | b4ecf755bad016b0d7fbb277106887f405f6b600 (patch) | |
tree | 8cfcea5441be72ad92095a3887ded84d38f9ba11 /zen/system.cpp | |
parent | Merge branch '10.22' into 'master' (diff) | |
parent | add upstream 10.23 (diff) | |
download | FreeFileSync-b4ecf755bad016b0d7fbb277106887f405f6b600.tar.gz FreeFileSync-b4ecf755bad016b0d7fbb277106887f405f6b600.tar.bz2 FreeFileSync-b4ecf755bad016b0d7fbb277106887f405f6b600.zip |
Merge branch '10.23' into 'master'10.23
add upstream 10.23
See merge request opensource-tracking/FreeFileSync!20
Diffstat (limited to 'zen/system.cpp')
-rw-r--r-- | zen/system.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/zen/system.cpp b/zen/system.cpp index 9401b94f..d9a169c7 100644 --- a/zen/system.cpp +++ b/zen/system.cpp @@ -29,7 +29,7 @@ std::wstring zen::getUserName() //throw FileError struct passwd buffer2 = {}; struct passwd* pwsEntry = nullptr; if (::getpwuid_r(userIdNo, &buffer2, &buffer[0], buffer.size(), &pwsEntry) != 0) //getlogin() is deprecated and not working on Ubuntu at all!!! - THROW_LAST_FILE_ERROR(_("Cannot get process information."), L"getpwuid_r"); + THROW_LAST_FILE_ERROR(_("Cannot get process information."), "getpwuid_r"); if (!pwsEntry) throw FileError(_("Cannot get process information."), L"no login found"); //should not happen? @@ -96,9 +96,22 @@ std::wstring zen::getOsDescription() //throw FileError { try { - const std::string osName = trimCpy(getCommandOutput("lsb_release --id -s" )); //throw SysError - const std::string osVersion = trimCpy(getCommandOutput("lsb_release --release -s")); // - return utfTo<std::wstring>(osName + ' ' + osVersion); //e.g. "CentOS 7.7.1908" + std::wstring osName; + std::wstring osVersion; + + if (const auto [exitCode, output] = consoleExecute("lsb_release --id -s", std::nullopt); //throw SysError + exitCode != 0) + throw SysError(formatSystemError("lsb_release --id", replaceCpy(_("Exit code %x"), L"%x", numberTo<std::wstring>(exitCode)), output)); + else + osName = trimCpy(output); + + if (const auto [exitCode, output] = consoleExecute("lsb_release --release -s", std::nullopt); //throw SysError + exitCode != 0) + throw SysError(formatSystemError("lsb_release --release", replaceCpy(_("Exit code %x"), L"%x", numberTo<std::wstring>(exitCode)), output)); + else + osVersion = trimCpy(output); + + return osName + L' ' + osVersion; //e.g. "CentOS 7.7.1908" } catch (const SysError& e) { throw FileError(_("Cannot get process information."), e.toString()); } |