@@ -56,11 +56,12 @@ static std::string fs_win32_owner(std::string_view path, bool group)
5656 PSECURITY_DESCRIPTOR pSD = nullptr ;
5757 PSID pSid = nullptr ;
5858 DWORD r;
59+ const std::string cpath (path);
5960 // https://learn.microsoft.com/en-us/windows/win32/api/aclapi/nf-aclapi-getnamedsecurityinfoa
6061 if (group)
61- r = GetNamedSecurityInfoA (path. data (), SE_FILE_OBJECT , GROUP_SECURITY_INFORMATION , nullptr , &pSid, nullptr , nullptr , &pSD);
62+ r = GetNamedSecurityInfoA (cpath. c_str (), SE_FILE_OBJECT , GROUP_SECURITY_INFORMATION , nullptr , &pSid, nullptr , nullptr , &pSD);
6263 else
63- r = GetNamedSecurityInfoA (path. data (), SE_FILE_OBJECT , OWNER_SECURITY_INFORMATION , &pSid, nullptr , nullptr , nullptr , &pSD);
64+ r = GetNamedSecurityInfoA (cpath. c_str (), SE_FILE_OBJECT , OWNER_SECURITY_INFORMATION , &pSid, nullptr , nullptr , nullptr , &pSD);
6465
6566 std::string s;
6667 if (r == ERROR_SUCCESS )
@@ -77,16 +78,17 @@ static std::string fs_win32_owner(std::string_view path, bool group)
7778static std::optional<uid_t > fs_stat_uid (std::string_view path)
7879{
7980 int r = 0 ;
81+ const std::string cpath (path);
8082
8183#if defined(HAVE_STATX)
8284 struct statx sx;
83- r = ::statx (AT_FDCWD , path. data (), AT_NO_AUTOMOUNT , STATX_UID , &sx);
85+ r = ::statx (AT_FDCWD , cpath. c_str (), AT_NO_AUTOMOUNT , STATX_UID , &sx);
8486 if (r == 0 )
8587 return sx.stx_uid ;
8688#endif
8789
8890 if (r == 0 || errno == ENOSYS ){
89- if (struct stat s; !::stat (path. data (), &s))
91+ if (struct stat s; !::stat (cpath. c_str (), &s))
9092 return s.st_uid ;
9193 }
9294
@@ -96,15 +98,17 @@ static std::optional<uid_t> fs_stat_uid(std::string_view path)
9698static std::optional<gid_t > fs_stat_gid (std::string_view path)
9799{
98100 int r = 0 ;
101+ const std::string cpath (path);
102+
99103#if defined(HAVE_STATX)
100104 struct statx sx;
101- r = ::statx (AT_FDCWD , path. data (), AT_NO_AUTOMOUNT , STATX_GID , &sx);
105+ r = ::statx (AT_FDCWD , cpath. c_str (), AT_NO_AUTOMOUNT , STATX_GID , &sx);
102106 if (r == 0 )
103107 return sx.stx_gid ;
104108#endif
105109
106110if (r == 0 || errno == ENOSYS ){
107- if (struct stat s; !::stat (path. data (), &s))
111+ if (struct stat s; !::stat (cpath. c_str (), &s))
108112 return s.st_gid ;
109113}
110114
0 commit comments