LiveSplit / LiveSplit/livesplit-core
[ASR] Expose access to "special folder" paths
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 227
- Forks
- 81
- Avg merge
- 22h 45m
- Merged PRs (30d)
- 3
Description
Currently autosplitters can only get the path of the executable they're attached to. Sometimes the file you want to read is not relative to this - e.g. if it's in my documents or under %appdata%. There should be some way to get at these "special folders".
Rather than dealing with string substitutions, I think dotnet has a relatively clean interface we could borrow:
string path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
Now dotnet tries to map the same enum values across platforms - e.g. my documents becomes XDG_DOCUMENTS_DIR on linux (source). Since we're trying to replicate whatever logic the game's doing, I think it's better for them to be explicitly different, any logic we implemented might not work the same as the game's.
My proposed API would be something like:
enum SpecialFolder : uint32_t {
WIN_DOCUMENTS,
WIN_APPDATA,
WIN_LOCAL_APPDATA,
// ...
XDG_DOCUMENTS,
// ...
};
bool runtime_get_special_folder(SpecialFolder folder, char8_t* buf, uintptr_t* len);
This would have the same semantics as process_get_path - so trying to get WIN_DOCUMENTS on a linux host would return false/0 length.
As an additional complication, when running a windows game under wine, you'll want to be able to get the special folders in the emulated windows filesystem, rather than on the host linux system. From what I can tell, the best process for finding these is:
- Pick the process you want to get the path for - different processes may have different wine prefixes, and thus different filesystems
- Search
/proc/{pid}/environforWINEPREFIX. If it doesn't exist, assume~/.wine. - Read though
$WINEPREFIX/user.reg(which storesHKEY_CURRENT_USER), and look for the shell folders. There are two sections, I'm not entirely sure which one takes priority, but I don't imagine many people are manually editing these files anyway, let alone only editing one.
Since this needs to be based on a specific process, it would need another export:
bool runtime_get_wine_special_folder(AttachedProcess process, SpecialFolder folder, char8_t* buf, uintptr_t* len);
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the existing process_get_path entry point and the runtime export layer, then compare their platform-specific implementations. Define the special-folder API and process-aware Wine behavior described in the issue, including failure for unsupported host folders. Done means callers can retrieve platform-appropriate paths and Wine paths for the selected process.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, rust
- Domain
- api, operating-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100