17 #ifndef __STOUT_OS_WINDOWS_SU_HPP__ 18 #define __STOUT_OS_WINDOWS_SU_HPP__ 37 #if defined(SECURITY_WIN32) || defined(SECURITY_KERNEL) 40 #define SECURITY_WIN32 43 #endif // SECURITY_WIN32 || SECURITY_KERNEL 78 "os::user: Retrieving user information via uid " 79 "is not supported on Windows");
82 EXTENDED_NAME_FORMAT username_format = NameSamCompatible;
83 ULONG buffer_size = 0;
84 if (::GetUserNameExW(username_format,
nullptr, &buffer_size) == FALSE) {
85 if (::GetLastError() != ERROR_MORE_DATA) {
86 return WindowsError(
"os::user: Failed to get buffer size for username");
90 std::vector<wchar_t> user_name;
91 user_name.reserve(buffer_size);
92 if (::GetUserNameExW(username_format, user_name.data(), &buffer_size)
94 return WindowsError(
"os::user: Failed to get username from OS");
97 return stringify(std::wstring(user_name.data()));
105 #endif // __STOUT_OS_WINDOWS_SU_HPP__ Try< uid_t > uid(const std::string &path, const FollowSymlink follow=FollowSymlink::FOLLOW_SYMLINK)
Definition: stat.hpp:224
Definition: errorbase.hpp:36
Result< std::string > user(Option< uid_t > uid=None())
Definition: su.hpp:284
Definition: error.hpp:108
Definition: posix_signalhandler.hpp:23
Result< uid_t > getuid(const Option< std::string > &user=None())
Definition: su.hpp:41
Result< gid_t > getgid(const Option< std::string > &user=None())
Definition: su.hpp:118
Try< Nothing > su(const std::string &user)
Definition: su.hpp:326
std::string stringify(int flags)