Reading a file from %PROGRAMDATA% or /Library/Application Support/

Hey all,

I need to read a json file from another programs %PROGRAMDATA% or /Library/Application Support/ to get a server port to send info to.

Is sandboxing on Win32/osX going to be a issue here?

Sandboxing doesn’t seem to be the issue… MacOS and Windows will read that file if I give it the exact path, but Win32 doesn’t seem to resolve %PROGRAMDATA% to the right folder…

Any ideas?

i don’t think you’ll get environment variable expansion from native lua, an os-specific native plugin would be needed for each…

local lfs = require("lfs") ats = lfs.attributes("%PROGRAMDATA%") if (ats) then for k,v in pairs(ats) do print(k,v) end else print("NOPE") end --\> NOPE ats = lfs.attributes("C:\\ProgramData") if (ats) then for k,v in pairs(ats) do print(k,v) end else print("NOPE") end --\> {ats}

unless perhaps this works (universally) on your system(s):

print(os.getenv("PROGRAMDATA"))

then you could probably “manually” assemble the correct full path from there on.

[edited]

print(os.getenv("PROGRAMDATA"))

Worked like a charm… Thx!

Sandboxing doesn’t seem to be the issue… MacOS and Windows will read that file if I give it the exact path, but Win32 doesn’t seem to resolve %PROGRAMDATA% to the right folder…

Any ideas?

i don’t think you’ll get environment variable expansion from native lua, an os-specific native plugin would be needed for each…

local lfs = require("lfs") ats = lfs.attributes("%PROGRAMDATA%") if (ats) then for k,v in pairs(ats) do print(k,v) end else print("NOPE") end --\> NOPE ats = lfs.attributes("C:\\ProgramData") if (ats) then for k,v in pairs(ats) do print(k,v) end else print("NOPE") end --\> {ats}

unless perhaps this works (universally) on your system(s):

print(os.getenv("PROGRAMDATA"))

then you could probably “manually” assemble the correct full path from there on.

[edited]

print(os.getenv("PROGRAMDATA"))

Worked like a charm… Thx!