4#include "Stroika/Foundation/StroikaPreComp.h"
8#include "Stroika/Foundation/Execution/Exceptions.h"
25uid_t Platform::POSIX::UserName2UID (
const String& name)
27 size_t bufsize = ::sysconf (_SC_GETPW_R_SIZE_MAX);
31 StackBuffer<char> buf{Memory::eUninitialized, bufsize};
34 struct passwd* result =
nullptr;
35 int err = ::getpwnam_r (name.
AsNarrowSDKString ().c_str (), &pwd, buf.data (), bufsize, &result);
36 if (err < 0) [[unlikely]] {
39 if (result ==
nullptr) [[unlikely]] {
50String Platform::POSIX::uid_t2UserName (uid_t uid)
52 size_t bufsize = ::sysconf (_SC_GETPW_R_SIZE_MAX);
56 StackBuffer<char> buf{Memory::eUninitialized, bufsize};
59 struct passwd* result =
nullptr;
60 int err = ::getpwuid_r (uid, &pwd, buf.data (), bufsize, &result);
64 if (result ==
nullptr) {
68 return String::FromSDKString (pwd.pw_name);
76uid_t Platform::POSIX::GetUID ()
86uid_t Platform::POSIX::GetEffectiveUID ()
String is like std::u32string, except it is much easier to use, often much more space efficient,...
nonvirtual string AsNarrowSDKString() const
Logically halfway between std::array and std::vector; Smart 'direct memory array' - which when needed...
void Throw(T &&e2Throw)
identical to builtin C++ 'throw' except that it does helpful, type dependent DbgTrace() messages firs...
void ThrowPOSIXErrNo(errno_t errNo=errno)
treats errNo as a POSIX errno value, and throws a SystemError (subclass of @std::system_error) except...