Bug in lfs

…oh man the forum just ate my original post :(  Let’s try again

The issue seems to be with what directory this brings back:

[lua]

local path = system.pathForFile("", system.ResourceDirectory)
print (“Path:”,path)  

[/lua]

On my Mac, I get: /Applications/CoronaSDK/Corona Simulator.app/Contents/Resources/CoronaResources.bundle/Contents/Resources    
 

I was expecting it to give me my project folder, or the sandbox, but it gave me this ‘virtual space’ inside the corona simulator instead.  There were widget files inside, along with the folder that I created with my earlier test, which explains why i was able to pull that directory listing without getting an error. 

I was able to get a folder listing by specifying the full folder path to the simulator’s sandbox on my mac:

[lua]

  new_folder_path = “/Users/raymonddelia/Library/Application Support/Corona Simulator/folder access-59F5788A4F8488A6F0E9C61EA944F2C7/myFolder”
[/lua]

I had to copy in the ‘myFolder’ contents to the sandbox folder , since the simulator did not do it automatically.

Since that worked, I tried pointing to my project file:

[lua]
   new_folder_path = “/Users/raymonddelia/Documents/Corona Projects/folder access/myFolder”

[/lua]

It’s pretty odd that  specifying the folder/file seems to actually point to the project’s structure, like in your example.

It looks like the big show stopper is android, where we don’t get a path for the directory at all.

 

Ha - good catch! Ok, so it’s just to sit back and wait for a Corona Bug Fix to happen…

Coronaah staff - when? :slight_smile:

There are a couple of important notes.

1.  system.pathForFile() name says what it does… a path for a file.  It expects to get a path to a file, not a directory.  Now the underlying OS may allow this to work, but by doing so, you are taking advantage of a case that is not designed or tested for.  This will probably fail on Windows because of NTFS.  Unix tends to treat directories as files, so it might work under the Linux based Android or the Unix based Mac OS-X and iOS, but Corona Labs expects the first parameter to be to a file.

  1. Under Android, there is no system.ResourcesDirectory that has your APK’s file content.  It’s a renamed zip file.  We extract some files that are needed for Corona SDK to work, but as LFS’s name states it’s Lua File System, its just a wrapper around the native OS’s file system.  An APK isn’t a directory and cannot be accessed with LFS.  Native developers on Android have to deal with this same issue.   On iOS, the app bundle is a folder in the file system, so LFS should be able to read it.

Are you seeing conditions outside of these two that LFS’s is not working?

Thanks,

Rob

Hi Rob,

thanks for that. We’ve been using the #1 case you outlined for the last year in both Android and iOS without any problems, but using the DocumentsDirectory. I’ll change our apps over to using the root path and instead run chdir to switch to the directory - just to be sure.

As for #2 - how do you suggest a game should pick up files from the bundle on Android? Is the only way to download files and place them in the documents directory? We have a huge folder with json files in a subfolder in the system.ResourcesFolder, and we need to be able to read those files from the game…

You pretty much have to read them and save them out to the documents directory.

Rob