Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
We don't bite newbies here... much
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
Actually, I am using add_data (the idea is that with a tied hash, your keys are file names, the values the data of the archive). But now that I've source-dove, I see that as written, Archive::Tar doesn't appear to be designed as to modify existing tar files: it seems to be set to either allow reading from a file, or to create a new tar file from scratch. Looking at the source, line 334, located in the the function that reads the tar file, will read in the data but simply ignore it as to skip through the file quickly. When data is written, it skips files that have no data associated with them, and thus existing files in the archive are ignored. Now, to some extent, this makes sense, since you can't read and write to a file at the same time. But then, there's functions in the API like replace_content that seem to indicate that this package would do so. Again, it's not that this can't handle solely making one or solely reading one, just that doing both, it can't.

This leaves a couple of options. I can read the entire contents at the start and explicitly set that, but this carries the entire tar file around in memory during execution which may not be great. I could wait until the the tie'd object is destroyed, read the data in and as to avoid stamping over data set during execution then write out, but this still requires the code to be in place at some point. Another solution would be to actually just extract the tar to temp space, map hash calls to file operations, then gather everything up at the end, but this moves the problem to disk space, which is not necessarily great either. I could consider rewriting A:T to suit my needs as well, possible, as jc's suggested offsite, using Inline::C and libtar for tar access. But, IMO, save for the first two, the rest are overkill.

I think, for the short term, I'll consider a read-only tie'd class (As I was planning on using, it would only be for reading contents from plug-ins, and thus would have no write ability). There's enough issues with a two-way tar file that it may not be best to think in those terms as yet.

-----------------------------------------------------
Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
"I can see my house from here!"
It's not what you know, but knowing how to find it if you don't know that's important


In reply to Re: Re: Problems with Archive::Tar? by Masem
in thread Problems with Archive::Tar? by Masem

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others surveying the Monastery: (16)
    As of 2014-04-16 17:33 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      April first is:







      Results (433 votes), past polls