Module org.hsqldb
Package org.hsqldb.lib.tar

## Class TarReader

- java.lang.Object
- - org.hsqldb.lib.tar.TarReader

-     public class TarReader
      extends java.lang.Object

  Reads a Tar file for reporting or extraction. N.b. this is not a Reader in the `java.io.Reader` sense, but in the sense of differentiating `tar x` and `tar t` from `tar c`.

  SECURITY NOTE Due to pitiful lack of support for file security in Java before version 1.6, this class will only explicitly set permissions if it is compiled for Java 1.6. If it was not, and if your tar entries contain private data in files with 0400 or similar, be aware that they will be extracted with privs such that they can be ready by anybody.

  Author:
    Blaine Simpson (blaine dot simpson at admc dot com)

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static int` | `EXTRACT_MODE` | EXTRACT_MODE refuses to overwrite existing files.
    `static int` | `LIST_MODE` |
    `static int` | `OVERWRITE_MODE` | OVERWRITE_MODE is just EXTRACT_MODE where we will silently overwrite existing files upon extraction.

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `TarReader​(java.io.File inFile, int mode, java.lang.String[] patternStrings, java.lang.Integer readBufferBlocks, java.io.File inDir)` | Compression is determined directly by the suffix of the file name in the specified path.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `read()` |

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### LIST_MODE

          public static final int LIST_MODE

      See Also:
        Constant Field Values

    - #### EXTRACT_MODE

          public static final int EXTRACT_MODE

      EXTRACT_MODE refuses to overwrite existing files.
      See Also:
        Constant Field Values

    - #### OVERWRITE_MODE

          public static final int OVERWRITE_MODE

      OVERWRITE_MODE is just EXTRACT_MODE where we will silently overwrite existing files upon extraction.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### TarReader

          public TarReader​(java.io.File inFile,
                           int mode,
                           java.lang.String[] patternStrings,
                           java.lang.Integer readBufferBlocks,
                           java.io.File inDir)
                    throws java.io.IOException

      Compression is determined directly by the suffix of the file name in the specified path.
      Parameters:
        `inFile` - Absolute or relative (from user.dir) path to tar file to be read. Suffix may indicate a compression method.
        `mode` - Whether to list, extract-without-overwrite, or extract-with-overwrite.
        `patternStrings` - List of regular expressions to match against tar entry names. If null, all entries will be listed or extracted. If non-null, then only entries with names which match will be extracted or listed.
        `readBufferBlocks` - Null will use default tar value.
        `inDir` - Directory that RELATIVE entries will be extracted relative to. Defaults to current directory (user.dir). Only used for extract modes and relative file entries.
      Throws:
        `java.lang.IllegalArgumentException` - if any given pattern is an invalid regular expression. Don't have to worry about this if you call with null 'patterns' param.
        `java.io.IOException`
      See Also:
        `Pattern`

  - ### Method Detail

    - #### read

          public void read()
                    throws java.io.IOException,
                           TarMalformatException

      Throws:
        `java.io.IOException`
        `TarMalformatException`