Add wxFileName::GetOwner() (PR #27201)

55 views
Skip to first unread message

Blake-Madden

unread,
Oct 9, 2026, 1:35:03 PM (5 days ago) Oct 9
to wx-...@googlegroups.com, Subscribed

Tested under Windows 11, macOS Golden Gate, and Linux Mint.


You can view, comment on, or merge this pull request online at:

  https://github.com/wxWidgets/wxWidgets/pull/27201

Commit Summary

  • 35a38b4 Add wxFileName::GetOwner()

File Changes

(3 files)

Patch Links:

—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/27201@github.com>

VZ

unread,
Oct 11, 2026, 9:49:33 AM (4 days ago) Oct 11
to wx-...@googlegroups.com, Subscribed

@vadz requested changes on this pull request.

This opens a can of worms because I'm not sure it's a good idea to represent an account as just wxString. The first problem with this is that under Unix it's really an UID and there may not be any associated string (which is perfectly normal when copying files from a different system using different UIDs and reporting error for it is not a good idea). The second one is that under Windows accounts have hierarchy.

So I'd think about adding wxLocalAccount or something like this with appropriate functions to retrieve its contents.


In src/common/filename.cpp:

> +        }
+
+        ::LocalFree(secDesc);
+
+        if ( !owner.empty() )
+            return owner;
+    }
+#elif defined(wxHAVE_LSTAT)
+    wxStructStat stBuf;
+    if ( StatAny(stBuf, *this) )
+    {
+        struct passwd pwd;
+        struct passwd* result = nullptr;
+        std::vector<char> buf(1024);
+        int rc;
+        while ( (rc = getpwuid_r(stBuf.st_uid, &pwd, buf.data(), buf.size(),

We're supposed to use #ifdef HAVE_GETPWUID_R around this function although I don't know if there are still any systems not providing it in current use.

Also, and maybe more importantly, we should provide a wrapper for it as this is different from what the existing code in src/common/tarstrm.cpp does (notably this always uses UTF-8 which is not correct if locale is not UTF-8).


In src/common/filename.cpp:

> +    }
+#elif defined(wxHAVE_LSTAT)
+    wxStructStat stBuf;
+    if ( StatAny(stBuf, *this) )
+    {
+        struct passwd pwd;
+        struct passwd* result = nullptr;
+        std::vector<char> buf(1024);
+        int rc;
+        while ( (rc = getpwuid_r(stBuf.st_uid, &pwd, buf.data(), buf.size(),
+                                 &result)) == ERANGE )
+        {
+            buf.resize(buf.size() * 2);
+        }
+
+        if ( rc == 0 && result != nullptr )

We may want to return the numeric UID if we failed to find the name.

—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/27201/review/5483518375@github.com>

Blake-Madden

unread,
Oct 11, 2026, 1:59:37 PM (3 days ago) Oct 11
to wx-...@googlegroups.com, Subscribed
Blake-Madden left a comment (wxWidgets/wxWidgets#27201)

I'm taking a swing at wxLocalAccount now, will update here later...

—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/27201/c6111984575@github.com>

Blake-Madden

unread,
Oct 11, 2026, 2:43:06 PM (3 days ago) Oct 11
to wx-...@googlegroups.com, Subscribed

@Blake-Madden commented on this pull request.


In src/common/filename.cpp:

> +        }
+
+        ::LocalFree(secDesc);
+
+        if ( !owner.empty() )
+            return owner;
+    }
+#elif defined(wxHAVE_LSTAT)
+    wxStructStat stBuf;
+    if ( StatAny(stBuf, *this) )
+    {
+        struct passwd pwd;
+        struct passwd* result = nullptr;
+        std::vector<char> buf(1024);
+        int rc;
+        while ( (rc = getpwuid_r(stBuf.st_uid, &pwd, buf.data(), buf.size(),

done

—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/27201/review/5484464738@github.com>

Blake-Madden

unread,
Oct 11, 2026, 2:44:21 PM (3 days ago) Oct 11
to wx-...@googlegroups.com, Subscribed

@Blake-Madden commented on this pull request.


In src/common/filename.cpp:

> +    }
+#elif defined(wxHAVE_LSTAT)
+    wxStructStat stBuf;
+    if ( StatAny(stBuf, *this) )
+    {
+        struct passwd pwd;
+        struct passwd* result = nullptr;
+        std::vector<char> buf(1024);
+        int rc;
+        while ( (rc = getpwuid_r(stBuf.st_uid, &pwd, buf.data(), buf.size(),
+                                 &result)) == ERANGE )
+        {
+            buf.resize(buf.size() * 2);
+        }
+
+        if ( rc == 0 && result != nullptr )

Implemented wxLocalAccount, which includes UI and domain (MSW), along with the name.

—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/27201/review/5484468532@github.com>

Blake-Madden

unread,
Oct 11, 2026, 2:44:52 PM (3 days ago) Oct 11
to wx-...@googlegroups.com, Push

@Blake-Madden pushed 2 commits.

  • d46388a Add wxLocalAccount type, GetOwner now returns ID, domain, and name info (when applicable)
  • 2c3fd83 Add tests for wxLocalAccount and GetOwner

—
View it on GitHub or unsubscribe.


Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/27201/before/35a38b4cd91e27676893de14d22c5afadaa94350/after/2c3fd8313bd314f4d236243ce5093ed935e3a8d9@github.com>

VZ

unread,
Oct 11, 2026, 5:29:30 PM (3 days ago) Oct 11
to wx-...@googlegroups.com, Subscribed

@vadz commented on this pull request.

Thanks, this looks mostly good now, but I think we should apply it to master after branching 3.4 as I'd like to stop adding features to 3.4 to avoid introducing any problems after 3.3.4.


In include/wx/filename.h:

> @@ -127,6 +127,49 @@ extern WXDLLIMPEXP_DATA_BASE(const wxULongLong) wxInvalidSize;
 
 
 
+// ----------------------------------------------------------------------------
+// wxLocalAccount: identifies a user or group account of the local system

This probably belongs in its own header, as it could be useful elsewhere.


In include/wx/filename.h:

> @@ -127,6 +127,49 @@ extern WXDLLIMPEXP_DATA_BASE(const wxULongLong) wxInvalidSize;
 
 
 
+// ----------------------------------------------------------------------------
+// wxLocalAccount: identifies a user or group account of the local system
+// ----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_BASE wxLocalAccount
+{
+public:
+    // Creates an invalid account object.
+    wxLocalAccount() = default;
+

As this seems to be copyable, better make it explicit with

wxLocalAccount(const wxLocalAccount&) = default;
wxLocalAccount& operator=(const wxLocalAccount&) = default;

—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/27201/review/5485028912@github.com>

Blake-Madden

unread,
Oct 11, 2026, 7:06:59 PM (3 days ago) Oct 11
to wx-...@googlegroups.com, Subscribed

@Blake-Madden commented on this pull request.


In include/wx/filename.h:

> @@ -127,6 +127,49 @@ extern WXDLLIMPEXP_DATA_BASE(const wxULongLong) wxInvalidSize;
 
 
 
+// ----------------------------------------------------------------------------
+// wxLocalAccount: identifies a user or group account of the local system
+// ----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_BASE wxLocalAccount
+{
+public:
+    // Creates an invalid account object.
+    wxLocalAccount() = default;
+

done.

—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/27201/review/5485418683@github.com>

Blake-Madden

unread,
Oct 11, 2026, 7:18:58 PM (3 days ago) Oct 11
to wx-...@googlegroups.com, Subscribed

@Blake-Madden commented on this pull request.


In include/wx/filename.h:

> @@ -127,6 +127,49 @@ extern WXDLLIMPEXP_DATA_BASE(const wxULongLong) wxInvalidSize;
 
 
 
+// ----------------------------------------------------------------------------
+// wxLocalAccount: identifies a user or group account of the local system

done

—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/27201/review/5485460504@github.com>

Blake-Madden

unread,
Oct 11, 2026, 7:24:18 PM (3 days ago) Oct 11
to wx-...@googlegroups.com, Push

@Blake-Madden pushed 2 commits.

  • 90eb899 Move wxLocalAccount to its own file
  • b5a3339 Add new file to build system

—
View it on GitHub or unsubscribe.


Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/27201/before/2c3fd8313bd314f4d236243ce5093ed935e3a8d9/after/b5a3339bd78fd7c8391f4da4e7d845a2a29a8c15@github.com>

Lauri Nurmi

unread,
Oct 12, 2026, 2:20:23 AM (3 days ago) Oct 12
to wx-...@googlegroups.com, Subscribed

@lanurmi commented on this pull request.


In include/wx/localaccount.h:

> +// Copyright:   (c) 2026 Blake Madden
+// Licence:     wxWindows licence
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_LOCALACCOUNT_H_
+#define _WX_LOCALACCOUNT_H_
+
+#include "wx/string.h"
+
+class WXDLLIMPEXP_FWD_BASE wxFileName;
+
+// ----------------------------------------------------------------------------
+// wxLocalAccount: identifies a user account of the local system
+// ----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_BASE wxLocalAccount
⬇️ Suggested change
-class WXDLLIMPEXP_BASE wxLocalAccount
+class WXDLLIMPEXP_BASE wxWARN_UNUSED wxLocalAccount

—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/27201/review/5487106837@github.com>

Blake-Madden

unread,
Oct 12, 2026, 6:08:16 AM (3 days ago) Oct 12
to wx-...@googlegroups.com, Push

@Blake-Madden pushed 1 commit.

—
View it on GitHub or unsubscribe.


Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/27201/before/b5a3339bd78fd7c8391f4da4e7d845a2a29a8c15/after/93315741f263ade26985d222ec231b3d16872735@github.com>

Reply all
Reply to author
Forward
0 new messages