Tar Module - Extract tar files with Corona

@akao - untar in the callback seemed to work. But the images still do not show up. So (hopefully) one last question. What is the pathname for my images? As as test, my first page of my app has images that look in two places and neither work. The tar is called “images.tar”. I have one image looking for “images/myimage.png” and another looking for “my image.png”. Now that I have the tar unpacked, is there an implication for the path I’m not accounting for? Again, thanks! [import]uid: 97058 topic_id: 23242 reply_id: 113924[/import]

@akao, here’s how I ended up unpacking the tar:

local fileToUntar = “images.tar”
–IMAGES DOWNLOAD
local function networkListener( event )
tar.untar(fileToUntar, system.TemporaryDirectory, system.DocumentsDirectory, onExtractComplete)
end

network.download( “http://www.myserver.com/folder/folder/images.tar”, “GET”, networkListener, “images.tar”, system.TemporaryDirectory ) [import]uid: 97058 topic_id: 23242 reply_id: 113925[/import]

@kungpowell, I don’t see why you should prefix your image filenames with images/whatever.png.

Are they contained in a images subdirectory? if not the path would be just “whatever.png”

for instance:

[code]

display.newImage(“whatever.png”, system.DocumentsDirectory)

[/code] [import]uid: 84637 topic_id: 23242 reply_id: 113983[/import]

@Danny, that was what I thought, but nothing ever displays. I think it may have to do with the different way the images are being called. I initially output the project via the Kwik plug-in and then heavily modified it, and their code is a bit different. The directory for the images is defined in the main.lua as

imgDir = “”
I’ve also tried
imgDir = system.DocumentsDirectory

In the individual pages they are called as

right = ui.newButton{
defaultSrc=“p1_right@2.png”,
overSrc=“p1_right@2.png”,
}

Everything seems to work as you all have suggested, but I think I have a slightly different starting point than we’re solving for.You guys have been extremely helpful and very patient with me, and I don’t want to wear out my welcome, so please forgive me if I’m asking for more help than these forums intended for. But if we can solve it here it may be helpful for other graphics-heavy apps made with Kwik.
[import]uid: 97058 topic_id: 23242 reply_id: 114048[/import]

I’ve restored the ability to handle directories. It will unpack directories and sub-directories. How do I get this to you? [import]uid: 37366 topic_id: 23242 reply_id: 129361[/import]

Update: I figured out why this wasn’t handling POSIX tar files from OS X. The octal_to_number function couldn’t handle space-padded numbers. So, I added a trim() and it handles the tar files from OS X terminal without any trouble.

You should be able to get the files here:

https://github.com/mimetic/tar.lua.git [import]uid: 37366 topic_id: 23242 reply_id: 129385[/import]

I’ve restored the ability to handle directories. It will unpack directories and sub-directories. How do I get this to you? [import]uid: 37366 topic_id: 23242 reply_id: 129361[/import]

Update: I figured out why this wasn’t handling POSIX tar files from OS X. The octal_to_number function couldn’t handle space-padded numbers. So, I added a trim() and it handles the tar files from OS X terminal without any trouble.

You should be able to get the files here:

https://github.com/mimetic/tar.lua.git [import]uid: 37366 topic_id: 23242 reply_id: 129385[/import]

Nice work, thanks for sharing the changes! [import]uid: 84637 topic_id: 23242 reply_id: 129499[/import]

Nice work, thanks for sharing the changes! [import]uid: 84637 topic_id: 23242 reply_id: 129499[/import]

Thank you all for the code…

I will use it to download content for my app, do you know how can I protect this content with password?

It is possible to partition this file for example a 50 mb in 10 parts of 5mb? With it I will simulate a progress of the download :wink:

Thank you
[import]uid: 6732 topic_id: 23242 reply_id: 130178[/import]

Thank you all for the code…

I will use it to download content for my app, do you know how can I protect this content with password?

It is possible to partition this file for example a 50 mb in 10 parts of 5mb? With it I will simulate a progress of the download :wink:

Thank you
[import]uid: 6732 topic_id: 23242 reply_id: 130179[/import]

Thank you all for the code…

I will use it to download content for my app, do you know how can I protect this content with password?

It is possible to partition this file for example a 50 mb in 10 parts of 5mb? With it I will simulate a progress of the download :wink:

Thank you
[import]uid: 6732 topic_id: 23242 reply_id: 130178[/import]

Thank you all for the code…

I will use it to download content for my app, do you know how can I protect this content with password?

It is possible to partition this file for example a 50 mb in 10 parts of 5mb? With it I will simulate a progress of the download :wink:

Thank you
[import]uid: 6732 topic_id: 23242 reply_id: 130179[/import]

Hey gang. I started to use this last night and I’m running into a problem.

Here is the error:

2012-11-10 11:12:30.277 Corona Simulator[458:707] princess.tar  
2012-11-10 11:12:30.316 Corona Simulator[458:707] Runtime error  
 ...le/Projects/Technolio/TP\_Series/TP-Shapes-V2/tar.lua:199: bad argument #1 to 'sub' (string expected, got userdata)  
stack traceback:  
 [C]: ?  
 [C]: in function 'sub'  
 ...le/Projects/Technolio/TP\_Series/TP-Shapes-V2/tar.lua:199: in function 'untar'  
 ...ects/Technolio/TP\_Series/TP-Shapes-V2/gameselect.lua:29: in function 'unpackApp'  

Here is the relevant code:

 print(storyboard.gameInfo[idx].filename)  
 tar.untar(storyboard.gameInfo[idx].filename, system.CachesDirectory, system.CachesDirectory, onComplete)  

princess.tar exists in my Caches folder (doing this in the simulator)

MacbookPros-MacBook-Pro:Caches rmiracle$ ls -l  
total 49976  
drwxr-xr-x 4 rmiracle staff 136 Nov 9 23:18 princess  
-rw-r--r-- 1 rmiracle staff 25584128 Nov 9 23:19 princess.tar  

The unpacked folder I did by hand since I wanted to test further stuff until I figured out this error. The tar file is made up of sub-folders and I’m using the version from @ mimetic’s https://github.com/mimetic/tar.lua.git

Any thoughts?
Thanks
Rob [import]uid: 19626 topic_id: 23242 reply_id: 130552[/import]

Hey gang. I started to use this last night and I’m running into a problem.

Here is the error:

2012-11-10 11:12:30.277 Corona Simulator[458:707] princess.tar  
2012-11-10 11:12:30.316 Corona Simulator[458:707] Runtime error  
 ...le/Projects/Technolio/TP\_Series/TP-Shapes-V2/tar.lua:199: bad argument #1 to 'sub' (string expected, got userdata)  
stack traceback:  
 [C]: ?  
 [C]: in function 'sub'  
 ...le/Projects/Technolio/TP\_Series/TP-Shapes-V2/tar.lua:199: in function 'untar'  
 ...ects/Technolio/TP\_Series/TP-Shapes-V2/gameselect.lua:29: in function 'unpackApp'  

Here is the relevant code:

 print(storyboard.gameInfo[idx].filename)  
 tar.untar(storyboard.gameInfo[idx].filename, system.CachesDirectory, system.CachesDirectory, onComplete)  

princess.tar exists in my Caches folder (doing this in the simulator)

MacbookPros-MacBook-Pro:Caches rmiracle$ ls -l  
total 49976  
drwxr-xr-x 4 rmiracle staff 136 Nov 9 23:18 princess  
-rw-r--r-- 1 rmiracle staff 25584128 Nov 9 23:19 princess.tar  

The unpacked folder I did by hand since I wanted to test further stuff until I figured out this error. The tar file is made up of sub-folders and I’m using the version from @ mimetic’s https://github.com/mimetic/tar.lua.git

Any thoughts?
Thanks
Rob [import]uid: 19626 topic_id: 23242 reply_id: 130552[/import]

ping… anyone? Beuhler? [import]uid: 19626 topic_id: 23242 reply_id: 130930[/import]

ping… anyone? Beuhler? [import]uid: 19626 topic_id: 23242 reply_id: 130930[/import]

  1. is it an umcompressed tar?
  2. did you use this program for making the tar http://www.izarc.org/download.html
  3. have your tried it from the temporary directory instead of the the cache folder?
  4. have your tried the original tar.lua from danny, http://www.infuseddreams.com/apps/Tar_Lib.zip?
  5. have you tried with out the subfolders?
  6. maybe take out all non-abc characters from filenames.

if you want to post your tar file or an example of it i will try to duplicate your error.

it has always worked well for me on win sim, mac sim, ios,andriod. so i am unclear in what the problem might be. [import]uid: 89663 topic_id: 23242 reply_id: 131137[/import]

1. is it an umcompressed tar?
Yes

2. did you use this program for making the tar http://www.izarc.org/download.html
No, I used the tar from the command line. I know that was mentioned as a problem, but I also was hoping it would have been addressed.

3. have your tried it from the temporary directory instead of the the cache folder?
No. But I’ll give that a try, at least for the source folder. The un-tarred filed will have to go to Caches since Apple won’t let me unpack downloaded content to Documents.

4. have your tried the original tar.lua from danny, http://www.infuseddreams.com/apps/Tar_Lib.zip?
No.

5. have you tried with out the subfolders?
If it wont’ work with directories, I can’t use this solution.

6. maybe take out all non-abc characters from filenames.
This is impractical as well.

Thanks for the suggestions.
[import]uid: 19626 topic_id: 23242 reply_id: 131162[/import]