Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
Users.cpp
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#include "Stroika/Foundation/StroikaPreComp.h"
5
6#if qStroika_Foundation_Common_Platform_Windows
7#include <Windows.h>
8#endif
9
10#include "Stroika/Foundation/Characters/SDKChar.h"
11#if qStroika_Foundation_Common_Platform_Windows
12#include "Stroika/Foundation/Execution/Platform/Windows/Exception.h"
13#endif
15
16#if qStroika_Foundation_Common_Platform_POSIX
17#include "Platform/POSIX/Users.h"
18#endif
19
20#include "Users.h"
21
22using namespace Stroika::Foundation;
23using namespace Stroika::Foundation::Execution;
24
27
28/*
29 ********************************************************************************
30 ************************ Execution::GetCurrentUserName *************************
31 ********************************************************************************
32 */
33String Execution::GetCurrentUserName ([[maybe_unused]] UserNameFormat format)
34{
35#if qStroika_Foundation_Common_Platform_Windows && 0
36 EXTENDED_NAME_FORMAT useFormat = NameDisplay;
37 ULONG sz = 0;
38 ::GetUserNameEx (useFormat, nullptr, &sz);
39 StackBuffer<Characters::SDKChar> buf{Memory::eUninitialized, sz + 1};
40 Execution::ThrowIfZeroGetLastError (::GetUserNameEx (useFormat, buf, &sz));
41 return String::FromSDKString (buf);
42#elif qStroika_Foundation_Common_Platform_Windows
43 ULONG sz = 0;
44 ::GetUserName (nullptr, &sz);
45 StackBuffer<Characters::SDKChar> buf{Memory::eUninitialized, sz + 1};
46 Execution::Platform::Windows::ThrowIfZeroGetLastError (::GetUserName (buf.data (), &sz));
47 return String::FromSDKString (buf);
48#elif qStroika_Foundation_Common_Platform_POSIX
49 return Platform::POSIX::uid_t2UserName (Platform::POSIX::GetUID ());
50#else
51#endif
52}
String is like std::u32string, except it is much easier to use, often much more space efficient,...
Definition String.h:201
Logically halfway between std::array and std::vector; Smart 'direct memory array' - which when needed...