My Windows application is frequently used on *nix using Wine.
As it is a file-centric application, it frequently uses (and presents to an user) Windows "documents" folder (as resolved using CSIDL_PERSONAL). Unfortunately under Wine that points to fake Wine/Windows directory that's usually empty and unused. I'd like to point user to his Unix home folder instead.
Is there any reliable way to find out its location under Wine?
I was hoping I can read HOME environment variable, but it's not exported (contrary to most other variables) to Windows environment.
Currently I'm guessing the home using Z:\home\%USERNAME%. But that does not look robust to me.
If there's no way to find home directory, is there at least a way to detect Wine root drive (Z: by default), so I do not need to hard-code at least a drive-part of path?
For a lack of better answer, I'm sharing my current workaround/hack:
For *nix platforms, where I have deployment under control (OS X particularly), I copy the HOME environment variable to another variable from a startup script (say the WINE_HOME). Most environment variables (with notable exception of the HOME) are exported to Windows/Wine environment. So I can read the WINE_HOME from my application, prepend Z:\ and convert slashes to backslashes.
For platforms, where I do not have deployment under control, I can use the USERNAME variable only to guess the home as Z:\home\%USERNAME%. This particularly does not work on OS X, where the home is in the /users not the /home.
EDIT: I found a question Get Wine path of file that helps a bit. In *nix you can use the winepath -w ~ to get Z:\home\username. But running the same from Windows environment does not resolve the ~. You can at least run the winepath -w /home/username to get Z:\home\username to find out a drive of the Wine root (in case it's not the default Z:\).
In Wine drive Z: always maps to the root (/) hence your way of detecting is cool. But if the user does
rm ~/.wine/dosdevices/z\:
this won't work of course. In wine mailing this there was a discussion about the security implications of Z: mapping.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With