It appeared to work for me, I’d be curious if it works for others too, but here’s the Mac desktop path in 1 line
local desktopPath= (string.sub((system.pathForFile(system.DocumentsDirectory)),1,(string.find( system.pathForFile(system.DocumentsDirectory),"/",8)))).."Desktop/"
I’ll look into this and see if my discovery method is coming up with the same path.
I assumed it was working since it worked in the past, but as we all know things change. I wonder if this isn’t something that changed since 10.10 and I missed it?
So, bad me if my assumption is the source of this issue.
Thanks Graham for giving me the motivation to check this out and some fallback code if mine failed. Speaking of which I’ll share my code below in a moment…
For those who are interested, this is the ‘summary’ of my path discovery of ‘dekstop’ and the equivalent of ‘my documents’ on OS X…
Username Discover with primary method and two fallbacks
-- OSX Discovery Utility local function getUserName() -- 1. Try the $USER variable local user = os.getenv("USER") if( user ) then print("Found $USER == " .. tostring( user ) ) return user end -- 2. Try extracting it from the $HOME path local user = os.getenv("HOME") if( user ) then print("Found $HOME == ", user ) user = string.split(user, "/") user = user[#user] if( user ) then print("Got USER from $HOME == " .. tostring( user ) ) return user end end -- 3. Try the $LOGNAME variable local user = os.getenv("LOGNAME") if( user ) then print("Got USER from $LOGNAME == " .. tostring( user ) ) return user end return nil end
My Documents
local pathSep = ( ssk.system.onWin ) and "\\" or "/" RGFiles.myDocumentsRoot = "" if( ssk.system.onOSX ) then RGFiles.myDocumentsRoot = getUserName() if( not RGFiles.myDocumentsRoot ) then RGFiles.myDocumentsRoot = "TBD" else RGFiles.myDocumentsRoot = "/Users/" .. RGFiles.myDocumentsRoot .. "/" .. "Documents" end end RGFiles.myDocumentsRoot = RGFiles.myDocumentsRoot .. pathSep
Desktop
RGFiles.desktopRoot = "" if( ssk.system.onOSX ) then RGFiles.desktopRoot = getUserName() if( not RGFiles.desktopRoot ) then RGFiles.desktopRoot = "TBD" else RGFiles.desktopRoot = "/Users/" .. RGFiles.desktopRoot .. "/" .. "Desktop" end end RGFiles.desktopRoot = RGFiles.desktopRoot .. pathSep
It appeared to work for me, I’d be curious if it works for others too, but here’s the Mac desktop path in 1 line
local desktopPath= (string.sub((system.pathForFile(system.DocumentsDirectory)),1,(string.find( system.pathForFile(system.DocumentsDirectory),"/",8)))).."Desktop/"
I’ll look into this and see if my discovery method is coming up with the same path.
I assumed it was working since it worked in the past, but as we all know things change. I wonder if this isn’t something that changed since 10.10 and I missed it?
So, bad me if my assumption is the source of this issue.
Thanks Graham for giving me the motivation to check this out and some fallback code if mine failed. Speaking of which I’ll share my code below in a moment…
For those who are interested, this is the ‘summary’ of my path discovery of ‘dekstop’ and the equivalent of ‘my documents’ on OS X…
Username Discover with primary method and two fallbacks
-- OSX Discovery Utility local function getUserName() -- 1. Try the $USER variable local user = os.getenv("USER") if( user ) then print("Found $USER == " .. tostring( user ) ) return user end -- 2. Try extracting it from the $HOME path local user = os.getenv("HOME") if( user ) then print("Found $HOME == ", user ) user = string.split(user, "/") user = user[#user] if( user ) then print("Got USER from $HOME == " .. tostring( user ) ) return user end end -- 3. Try the $LOGNAME variable local user = os.getenv("LOGNAME") if( user ) then print("Got USER from $LOGNAME == " .. tostring( user ) ) return user end return nil end
My Documents
local pathSep = ( ssk.system.onWin ) and "\\" or "/" RGFiles.myDocumentsRoot = "" if( ssk.system.onOSX ) then RGFiles.myDocumentsRoot = getUserName() if( not RGFiles.myDocumentsRoot ) then RGFiles.myDocumentsRoot = "TBD" else RGFiles.myDocumentsRoot = "/Users/" .. RGFiles.myDocumentsRoot .. "/" .. "Documents" end end RGFiles.myDocumentsRoot = RGFiles.myDocumentsRoot .. pathSep
Desktop
RGFiles.desktopRoot = "" if( ssk.system.onOSX ) then RGFiles.desktopRoot = getUserName() if( not RGFiles.desktopRoot ) then RGFiles.desktopRoot = "TBD" else RGFiles.desktopRoot = "/Users/" .. RGFiles.desktopRoot .. "/" .. "Desktop" end end RGFiles.desktopRoot = RGFiles.desktopRoot .. pathSep