Tar Module - Extract tar files with Corona

i can confirm that this works very well

http://www.izarc.org/download.html

nice find [import]uid: 89663 topic_id: 23242 reply_id: 93209[/import]

Wow, great job all! [import]uid: 71024 topic_id: 23242 reply_id: 93214[/import]

Hey guys, yeah after talking with josh quick i realised i should be opening it in “rb” binary. I will fix this in a few minutes and update the files for you.

Delighted to hear its working for people now :slight_smile: [import]uid: 84637 topic_id: 23242 reply_id: 93254[/import]

Edit : Just updated the file

Same link as the first post or here again : http://www.infuseddreams.com/corona/Tar_Lib.zip
Changes :

  1. Fixed the library not working on windows
  2. Fixed issues with onComplete function
  3. Added Notes text that defines the requirements for tar archives.

Enjoy :slight_smile: [import]uid: 84637 topic_id: 23242 reply_id: 93267[/import]

@sharp1959 nice Find probably easier than my solution haha :slight_smile:
this was my solution:

goto and download tare07.zip

http://geoffair.net/unix/tar-01.htm#downloads

extract to c:\tar

make tar.bat file and copy to c:\tar

@echo off  
  
chdir /D %~dp0/tarMe  
  
setlocal enabledelayedexpansion  
set myvar   
  
rem for %%i In (\*.\*) DO set myvar=!myvar! %%i  
for %%i In (\*.\*) DO set myvar=!myvar! %%i  
  
echo %myvar%  
c:\tar\tar.exe -cvf c:\tar\myTar.tar %myvar%  
  
pause  
  

makeDir c:\tar\tarMe

copy files you want tared into c:\tar\tarMe\ and run c:\tar\tar.bat file

[import]uid: 89663 topic_id: 23242 reply_id: 93206[/import]

Is there an option to add a file to a TAR (or zip) for emailing?

I’d like to compress and add a password and then send a voice recorded file.

Thanks in advance.

Neil Friend [import]uid: 140436 topic_id: 23242 reply_id: 100333[/import]

@neil24

with this version of tar there is no compression done, it basically just allows you to bundle files together. [import]uid: 89663 topic_id: 23242 reply_id: 100349[/import]

Thanks for the response, is there an option in Corona to add a password to a file before emailing it?

Thanks

Neil [import]uid: 140436 topic_id: 23242 reply_id: 100352[/import]

@neil

Not that i am aware of at this time. [import]uid: 89663 topic_id: 23242 reply_id: 100619[/import]

Danny - We would like to have our data file untar in the background without blocking the user interface. In general, I understand that co-routine is the approach to use for something like this in Lua. But how would you recommend that we implement it with this untar function? Is it even possible?

Really appreciate your help, this code really solves a lot of problems for us! [import]uid: 41124 topic_id: 23242 reply_id: 103223[/import]

Doe this still exist? the link to the tar_lib.zip seems to be broken for me. [import]uid: 88147 topic_id: 23242 reply_id: 108081[/import]

Sorry about that, I recently changed servers and didn’t have a 100% up to date backup of my site.

Here is the new download link:

http://www.infuseddreams.com/apps/Tar_Lib.zip
@akao, does it block at the moment? I never tested for that, I will do some tests and see [import]uid: 84637 topic_id: 23242 reply_id: 108226[/import]

I have a completely noobie question, but I’m learning in crisis mode so my understanding is not very systematic. I have made a tar of images and posted them to my server. What I can’t figure out is where in the main.lua to specify the pathname to the file. I have:

local fileToUntar = “images.tar”

But how do I set the path to “http://www.myserver.com/project/images.tar”?

Also, do I need to change anything in this line?:
tar.untar(fileToUntar, system.ResourceDirectory, system.DocumentsDirectory, onExtractComplete)

Thanks for helping un-noobing me. [import]uid: 97058 topic_id: 23242 reply_id: 113640[/import]

download the file first to the system.TemporaryDirectory then extract it to the system.DocumentsDirectory. Thats how i do it there could be a better way.

tar.untar(fileToUntar, system.TemporaryDirectory, system.DocumentsDirectory, onExtractComplete)

http://developer.anscamobile.com/reference/index/networkdownload [import]uid: 89663 topic_id: 23242 reply_id: 113664[/import]

Thanks, ezraanderson1979. I now have the code working so the tar downloads but it does not seem to expand and the images it contains never load. Here’s what I have for the relevant code in the main.lua. Anyone see an error?

local tar = require(“tar”)

local function networkListener( event )
if ( event.isError ) then
print ( “Network error - download failed” )
end
print ( “images” … event.response )
end

network.download( “http://www.myserver.com/folder/folder/images.tar”, “GET”, networkListener, “images.tar”, system.TemporaryDirectory )

local fileToUntar = “images.tar”

–Extract the file
tar.untar(fileToUntar, system.TemporaryDirectory, system.DocumentsDirectory, onExtractComplete)

imgDir = “images/”

Using the above code, I can see that the tar downloads into the cache but that’s it. So I tried changing the system.TemporaryDirectory to system.ResourcesDirectory. This downloaded to the data folder but it never expanded either (yes, I also tried changing the tar.lua to reflect the change in the download directory). Any help is appreciated. Thanks! [import]uid: 97058 topic_id: 23242 reply_id: 113848[/import]

Have you tried putting the tar into the Documents directory? [import]uid: 41124 topic_id: 23242 reply_id: 113856[/import]

Try this

local tar = require(“updatePackageTar”)

local path = system.pathForFile( fileToUntar, system.TemporaryDirectory)
local fhd = io.open( path )

if fhd then
tar.untar(fileToUntar, system.TemporaryDirectory, system.DocumentsDirectory, onExtractComplete)
fhd:close()
else
end

edit: your code looks good to me. try putting print statements inside the tar.lua to see if the code is being executed ie: untar(filename, fileDir, destdir, onComplete) print(‘i am in the tar func’)
[import]uid: 89663 topic_id: 23242 reply_id: 113858[/import]

Thanks, ezraanderson1979, but I’m not quite sure I understand the first line since the tar is “tar.lua” not “updatePackageTar.”

I put the rest of the code as-is directly after the code I posted previously, replacing nothing. The tar did not expand. I placed the code in the tar.lua, and nothing happened there either. Sorry to be a bit dense, but where would this code go, does it replace anything, and what does the first line mean.

Thanks very much! [import]uid: 97058 topic_id: 23242 reply_id: 113897[/import]

Yes,akao, but nothing happened. [import]uid: 97058 topic_id: 23242 reply_id: 113898[/import]

@kungpowell You need to untar in your network download callback since the network callback is asynchronous. [import]uid: 41124 topic_id: 23242 reply_id: 113909[/import]