Since I was looking for a version of Scala, all I could find was the McDowell JNA code above. Here I turn on the Scala port, as it is currently not suitable.
import com.sun.jna.platform.win32._ object jna { def getHome: java.io.File = { if (!com.sun.jna.Platform.isWindows()) { new java.io.File(System.getProperty("user.home")) } else { val pszPath: Array[Char] = new Array[Char](WinDef.MAX_PATH) new java.io.File(Shell32.INSTANCE.SHGetSpecialFolderPath(null, pszPath, ShlObj.CSIDL_MYDOCUMENTS, false) match { case true => new String(pszPath.takeWhile(c => c != '\0')) case _ => System.getProperty("user.home") }) } } }
As with the Java version, you will need to add Java Native Access , including both jar files, to your specified libraries.
It's nice to see that JNA now makes it a lot easier than when the source code was sent.
Peter Jun 22 '14 at 13:30 2014-06-22 13:30
source share