Constructor
new TarReader(pathToTarFile)
Creates a new TarReader.
Parameters:
Name | Type | Description |
---|---|---|
pathToTarFile |
string |
This should be the absolute path to the tar file you want to read. |
Members
byteCount :number
byteCount keeps track of the total number of bytes in all files beneath the speficied directory. This value is valid only during list operations, not during read().
dirCount :number
dirCount is the number of directories encountered during a read() or list() operation.
fileCount :number
fileCount is the number of files encountered during a read() or list() operation.
pathToTarFile :string
pathToTarFile is the absolute path to the tar file that this iterator will read.
Methods
(static) description() → {PluginDefinition}
Returns a PluginDefinition object describing this plugin.
list()
The list() method returns information about the contents files and directories inside a tar file. Unlike read(), it does not return a readable stream for any of the files it encounters.
list() emits the events "entry", "error" and "end".
read()
The read() method reads the contents of the tar file. It emits the events "entry", "error" and "end".
The read() method returns the same information as the list() method, plus a readable stream from which you can extract the contents of individual tar files.
Note that read() will not advance to the next entry until you've read the entire stream returned returned by the "entry" event.
Events
end
This indicates that the iterator has passed the last entry in the tar file and there's nothing left to read.
entry :object
The entry event of the read() method includes both info about the tar file (from the header) and a ReadStream object that allows you to read the contents of the entry, if it's a file. Note that you MUST read the stream to the end before TarReader.read() will move to the next tar entry.
Properties:
Name | Type | Description |
---|---|---|
relPath |
string |
The relative path (within the tar file) of the entry. |
stream |
ReadStream |
A stream from which you can read the contents of the entry. |
fileStat |
FileStat |
An object containing a subset info similar to the fs.Stats object, describing the file's size and other attributes. |
entry :object
The entry event of the list() method returns info about the tar entry, but no reader to read the contents of the entry.
Properties:
Name | Type | Description |
---|---|---|
relPath |
string |
The relative path (within the tar file) of the entry. |
fileStat |
FileStat |
An object containing a subset info similar to the fs.Stats object, describing the file's size and other attributes. |
error :Error
Indicates something went wrong while reading the tarfile.