[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Extracting indiviual files or directories from XYZ.tar.xz - Possible?



Length of a file can change while tar is backing it up, tar generally
handles this,
though it may complain/warn about it.
And to the compression formats, it's just a stream of data,
they know nothing about tar.  So, the blocks of compressed data may
have part of one large file, or maybe thousands of files.  The compression
formats generally don't know or care when it comes to tar archive or the like,
so there's not really much info they could provide to tar about what's within
... for the most part all they really know is its data, and perhaps
also bits like
how long the block is compressed, and uncompressed, and perhaps some
hash of that data or the like.

On Sat, Aug 9, 2025 at 2:47 PM Nicolas George <george@nsup.org> wrote:
>
> Michael Paoli (HE12025-08-09):
> > I don't think there's any tar format that has an "index" or the like,
> > it's generally just a tar header,
>
> There is no global tar header.
>
> >                                   then for each file (of any type),
> > specific header for that, and any associated data,
>
> Yes.
>
> >                                                    and I think there's
> > also some type of end marker or the like, perhaps with a bit of metadata
> > at the end too.
>
> Only padding of 0 until the next multiple of 512 octets.
>
> >                  And there may be some type of marker or the like at
> > the end of the archive too.
>
> Again, only more padding of 0.
>
> >                               But I think that's basically it.
>
> Yes.
>
> >                          So, even if tar is requested to restore a single file,
> > and has gotten to the point in archive where it's extracted that file,
> > that doesn't mean it can quit at that point.
>
> It could observe: hey, decompression library says there is a new block,
> 100K compressed, 5M uncompressed; I am 2M into a 10M file I do not want
> to extract, let me skip that block, 100K of compressed input, I am now
> 7M into that file I do not need to extract.
>
> But as I said, it does not do that, and that would be useless because xz
> files do not have block in practice.


Reply to: