SORTIE Java Interface  1
Static Public Member Functions | List of all members
sortie.fileops.Tarball Class Reference

Functions for working with tarballs (.gz.tar files). More...

Static Public Member Functions

static String extractTarball (String sTarball, String sTempRoot) throws ModelException
 Extracts a tarball's entries into the designated temp folder. More...
 
static String extractTarballNoPath (String sTarball, String sTempRoot) throws ModelException
 Extracts a tarball's entries into the designated temp folder. More...
 
static InputStream getUnzipFileStream (String sFileToGet) throws ModelException
 This converts a gzipped file to an uncompressed file stream. More...
 
static void makeTarball (String sTarball, String[] p_sFiles) throws ModelException
 Creates a tarball from a set of files. More...
 
static String unzipFile (String sFile) throws ModelException
 Unzips a file. More...
 
static String zipFile (String sFile) throws ModelException
 Zips a file. More...
 
static String extractTarballFile (String sTarball, String sFileName) throws ModelException
 Extracts a file from .gz.tar land to plaintext. More...
 
static String extractTarballFileToPath (String sTarball, String sFileName, String sDestinationPath) throws ModelException
 Extracts a file from .gz.tar land to plaintext. More...
 
static void cleanUp (String sTarball, String sTempDir, String sTempRoot) throws ModelException
 Deletes all files from the tarball in the temp folder. More...
 
static String [] getTarballEntries (String sTarball) throws ModelException
 Gets a list of file entries in the tarball. More...
 

Detailed Description

Functions for working with tarballs (.gz.tar files).

Copyright: Copyright (c) Charles D. Canham 2003

Company: Cary Institute of Ecosystem Studies

Author
Lora E. Murphy
Version
1.0


Edit history:
---------------—
April 28, 2004: Submitted in beta version (LEM)
October 1, 2007: Improvements to use cross-system files
October 26, 2007: Updated to be able to work around the @longlink naming problem - the inability of older versions of TAR (such as ours) to handle long filenames (LEM)
February 4, 2008: Updated to conform to Java 6 compliance (LEM)\
February 22, 2011: Corrected a bug relating to opening files without an associated path (LEM)

Member Function Documentation

◆ cleanUp()

static void sortie.fileops.Tarball.cleanUp ( String  sTarball,
String  sTempDir,
String  sTempRoot 
) throws ModelException
static

Deletes all files from the tarball in the temp folder.

Parameters
sTarballTarball with the files to delete.
sTempDirDirectory from which files should be cleaned
sTempRootTemp directory root

◆ extractTarball()

static String sortie.fileops.Tarball.extractTarball ( String  sTarball,
String  sTempRoot 
) throws ModelException
static

Extracts a tarball's entries into the designated temp folder.

If there is file info in the tar archive, they automatically get put in a sub folder of the root directory.

Parameters
sTarballTarball to extract
sTempRootTemp root directory
Returns
File where the files were extracted to.
Exceptions
ModelExceptionwraps IOExceptions.

◆ extractTarballFile()

static String sortie.fileops.Tarball.extractTarballFile ( String  sTarball,
String  sFileName 
) throws ModelException
static

Extracts a file from .gz.tar land to plaintext.

The file will be placed in the same directory as the tarball.

Parameters
sTarballTarball in which the file is.
sFileNameName of file to extract, with no path information and with no .gz or .tar extension (but with its plaintext extension).
Returns
The full filename and path of the extracted file, or null if the file was not found in the tarball.
Exceptions
ModelExceptionif the file is bad.

◆ extractTarballFileToPath()

static String sortie.fileops.Tarball.extractTarballFileToPath ( String  sTarball,
String  sFileName,
String  sDestinationPath 
) throws ModelException
static

Extracts a file from .gz.tar land to plaintext.

The file will be placed in the chosen directory.

Parameters
sTarballTarball in which the file is.
sFileNameName of file to extract.
sDestinationPathPath to extract to.
Returns
The full filename and path of the extracted file, or null if the file was not found in the tarball.
Exceptions
ModelExceptionif the file is bad.

◆ extractTarballNoPath()

static String sortie.fileops.Tarball.extractTarballNoPath ( String  sTarball,
String  sTempRoot 
) throws ModelException
static

Extracts a tarball's entries into the designated temp folder.

If there is file info in the tar archive, they automatically get put in a sub folder of the root directory.

Parameters
sTarballTarball to extract
sTempRootTemp root directory
Returns
File where the files were extracted to.
Exceptions
ModelExceptionwraps IOExceptions.

◆ getTarballEntries()

static String [] sortie.fileops.Tarball.getTarballEntries ( String  sTarball) throws ModelException
static

Gets a list of file entries in the tarball.

The list is of the core XML files, with no paths attached.

Parameters
sTarballTarball for which to get entries.
Returns
An array of filenames in the tarball, no path info, no .gz extension, or null if the tarball is empty.
Exceptions
ModelExceptionif there is a problem reading the file.

◆ getUnzipFileStream()

static InputStream sortie.fileops.Tarball.getUnzipFileStream ( String  sFileToGet) throws ModelException
static

This converts a gzipped file to an uncompressed file stream.

Parameters
sFileToGet- the file to uncompress.
Returns
- InputStream - the uncompressed file stream
Exceptions
ModelExceptionif the file is not found, or wrapping another exception.

◆ makeTarball()

static void sortie.fileops.Tarball.makeTarball ( String  sTarball,
String []  p_sFiles 
) throws ModelException
static

Creates a tarball from a set of files.

Parameters
sTarballTarball to create
p_sFilesFiles to put into the tarball
Exceptions
ModelException

◆ unzipFile()

static String sortie.fileops.Tarball.unzipFile ( String  sFile) throws ModelException
static

Unzips a file.

As with gzip, this will delete the original file.

Parameters
sFileFile to unzip.
Returns
Path and file name of unzipped file.
Exceptions
ModelExceptionIf there is a problem writing the file.

◆ zipFile()

static String sortie.fileops.Tarball.zipFile ( String  sFile) throws ModelException
static

Zips a file.

As with gzip, this will delete the original file.

Parameters
sFileFile to zip.
Returns
File name of the zipped file.
Exceptions
ModelExceptionIf something goes wrong in the zipping.

The documentation for this class was generated from the following file: