Skip to content

fix: resolve current account home directory - #233

Open
Max-Sum wants to merge 1 commit into
PlayCover:masterfrom
Max-Sum:fix-user-dir
Open

fix: resolve current account home directory#233
Max-Sum wants to merge 1 commit into
PlayCover:masterfrom
Max-Sum:fix-user-dir

Conversation

@Max-Sum

@Max-Sum Max-Sum commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

NSHomeDirectoryForUser could return a container path instead of user directory.
Use getpwuid_r(getuid()) instead.

And also fix the hard-coded path in keymapping.

Just tried building with the latest source code, but NSHomeDirectoryForUser(userName) doesn’t seem to be working.

It returns /Users/$USER/Library/Containers/{App_Bundle_ID}/Data instead of /Users/$USER.

Originally posted by @viatearz in #221 (comment)

@TheMoonThatRises

Copy link
Copy Markdown
Member

@viatearz can you provide some feedback? I can't tell if this is entirely necessary, i.e. why not just utilize NSHomeDirectoryForUser(userName) and strip back to the first two path components as slashes always represent directories/files.

@viatearz

Copy link
Copy Markdown
Contributor

@viatearz can you provide some feedback? I can't tell if this is entirely necessary, i.e. why not just utilize NSHomeDirectoryForUser(userName) and strip back to the first two path components as slashes always represent directories/files.

@TheMoonThatRises I also prefer the simpler solution, as it will be easier to maintain.

But I would choose to strip the path at the first occurrence of /Library/Containers/, since the path prefix can vary when the home directory is located on an external disk.

@Max-Sum

Max-Sum commented Aug 15, 2026

Copy link
Copy Markdown
Contributor Author

@viatearz can you provide some feedback? I can't tell if this is entirely necessary, i.e. why not just utilize NSHomeDirectoryForUser(userName) and strip back to the first two path components as slashes always represent directories/files.

@TheMoonThatRises I also prefer the simpler solution, as it will be easier to maintain.

But I would choose to strip the path at the first occurrence of /Library/Containers/, since the path prefix can vary when the home directory is located on an external disk.

Should we reply on the uncertain behavior of NSHomeDirectoryForUser which causes the issue in the first place?

@TheMoonThatRises

Copy link
Copy Markdown
Member

From what I gather NSHomeDirectoryForUser returns the "home" path that iOS allows the application to see, which would be the sandbox path. I believe this was the original reason to utilizing the hard-coded home directory path previously, though undocumented. I believe @viatearz's plan for dynamically retrieving the proper home path to be a good solution, as it is easily maintainable.

Comment thread PlayTools/PlayLoader.m Outdated
@viatearz

Copy link
Copy Markdown
Contributor

@TheMoonThatRises I think the getpwuid_r approach is also acceptable, although it is a bit complicated. Perhaps we should prioritize fixing the nightly version first.

@TheMoonThatRises

Copy link
Copy Markdown
Member

Is it possible for the code to be simplified though? Theres a lot of memory operations for retrieving the home path

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants