I'm looking for a way to get the path to the user's home folder that will work on any sys target. The only way I can think of is to use the HOME
/UserProfile
environment variable, but I can't find a cross-target way to get environment variable values. Is there another way?
You can use Sys.getEnv()
to obtain the value of the environment variable, and Sys.systemName()
to check which OS you're running on:
var home = Sys.getEnv(if (Sys.systemName() == "Windows") "UserProfile" else "HOME");