A few Codea versions back, this code would save an image, and retrieve it…
local path = os.getenv("HOME").."/Documents/tempImage.png"
local file = io.open(path,"rb")
local contents = file:read("*all")
But now, the file read fails to find the image. Was there a change somewhere along the line in where Documents is relative to HOME or … Hmm. Honestly, I can’t figure out what changed on me.
Any clues appreciated.
@Mark I dug up one of my old projects that read a file from Documents. I didn’t have a png image there so I used a txt file that was there. I had no trouble reading the txt file using the line below to point to the file. So if it worked for the txt file, it should be the same for your png file.
PS. I loaded a png file in my Documents folder and had no trouble reading it.
local file = os.getenv("HOME").."/Documents/test1.txt"
As it turns out, this is working in code – but failing on a compiled app. It did work at one time, because I put out a couple of additions of the app this way. But now there seems to be a difference between how this works in Codea, and how it works when compiled.
@Mark I only use Codea so I can’t give you any suggestions for compiled code. There might be something if you do a forum search. I’ll try a search to see if I run across anything.
@Mark Try doing a search with documents xcode ( both words). I ran across this link but didn’t look at it too close. There were also other discussions found that I didn’t look at.
Thanks, I did have some icons I was using that were held in the documents folder. I’ll move things around and see if that resolves the issues – but I’ll note that at some point, it was working, because multiple versions of this app went out and worked without making those changes. Things can get scarily delicate on the other side of xcode. I have one app that runs fine in simulator, but when archived and pushed up as an app, it fails – and I still don’t have a good clue why.