Can we put the compiled images in the documents directory instead of the resources directory?

Is there a way that we can have corona put the images in the documents directory instead of the resource directory? Currently any image that is compiled into an app is put in the resources directory. Any image you download would be put in the documents directory. 

Here is my case:

if you update your images from the web, that would mean that there are two images, one in docs, and one in resources, since you can’t replace on in resources, and you can’t save something to resource after the fact.

The ResourceDirectory seems to be read-only at runtime.

By designating images to be stored in DocumentsDirectory by the compiler, they could be replaced easily at runtime and not have the old version and the newer version in the app space.

Thanks!
Stu

I’m not sure this is currently possible in Corona (I could be wrong), and for the majority of people I would guess this isn’t an issue. 

If you want everything in the documents folder, you could always ship the app without any images in the resource folder (which will bring down it’s default file size too), and have the initial images download on when the user first starts up.

Not ideal, but could be quicker than hoping for this to be changed by Corona.

An alternate option would be to wrap the image handler in code that checks the documents directory first, and if the target is not found, it checks the resource directory. Since there is no clean failure code (other than CRASH) for the newImage* functions, you can’t try one and try the other on failure of the first request.

Ah, I assumed you’d be doing something similar to that anyway, but you’re quite right.

Just in case anyone who reads this needs a “does the file exist” function, here is one that I use:

function fileExists(myFile, directoryName) local filePath = system.pathForFile(myFile, directoryName) local results = false if filePath == nil then return false else local file = io.open(filePath, "r") --If the file exists, return true if file then io.close(file) results = true end return results end end --check a file if fileExists("myImage.png", system.DocumentsDirectory) then myImage = display.newImageRect("myImage.png", system.DocumentsDirectory, 128, 128) else myImage = display.newImageRect("myImage.png", 128, 128)end end

I’m not sure this is currently possible in Corona (I could be wrong), and for the majority of people I would guess this isn’t an issue. 

If you want everything in the documents folder, you could always ship the app without any images in the resource folder (which will bring down it’s default file size too), and have the initial images download on when the user first starts up.

Not ideal, but could be quicker than hoping for this to be changed by Corona.

An alternate option would be to wrap the image handler in code that checks the documents directory first, and if the target is not found, it checks the resource directory. Since there is no clean failure code (other than CRASH) for the newImage* functions, you can’t try one and try the other on failure of the first request.

Ah, I assumed you’d be doing something similar to that anyway, but you’re quite right.

Just in case anyone who reads this needs a “does the file exist” function, here is one that I use:

function fileExists(myFile, directoryName) local filePath = system.pathForFile(myFile, directoryName) local results = false if filePath == nil then return false else local file = io.open(filePath, "r") --If the file exists, return true if file then io.close(file) results = true end return results end end --check a file if fileExists("myImage.png", system.DocumentsDirectory) then myImage = display.newImageRect("myImage.png", system.DocumentsDirectory, 128, 128) else myImage = display.newImageRect("myImage.png", 128, 128)end end