Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Reading a file from %PROGRAMDATA% or /Library/Application Support/
Started by ponywolf Jul 10 2019 07:11 AM

3 replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

ponywolf

[GLOBAL: userInfoPane.html]
ponywolf
  • Contributor

  • 271 posts
  • Corona SDK

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?

 

 



[TOPIC: post.html]
#2

ponywolf

[GLOBAL: userInfoPane.html]
ponywolf
  • Contributor

  • 271 posts
  • Corona SDK

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?



[TOPIC: post.html]
#3

davebollinger

[GLOBAL: userInfoPane.html]
davebollinger
  • Corona Geek

  • 1,357 posts
  • Corona SDK

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]



[TOPIC: post.html]
#4

ponywolf

[GLOBAL: userInfoPane.html]
ponywolf
  • Contributor

  • 271 posts
  • Corona SDK

print(os.getenv("PROGRAMDATA"))

Worked like a charm... Thx!




[topic_controls]
[/topic_controls]