Kevin Jones - Archive.Tar-0.01

Documentation | Source

NAME

Archive.Tar.File - a subclass for in-memory extracted file from Archive.Tar

SYNOPSIS

  var tar = new Archive.Tar;
  tar.read("/stuff.tar.gz");

  var files = tar.getFiles();
  for (var i=0; i<files.length; i++) {
    alert( files[0].name() + " is in this archive" );
  }

DESCRIPTION

The Archive.Tar.File object is a wrapper around any file within a tar archive. It provides accessor methods for each header field as well as a getContent() method for accessing the file contents.

ACCESSORS

name

The file's name

mode

The file's mode

uid

The user id owning the file

gid

The group id owning the file

size

File size in bytes

mtime

Modification time.

chksum

Checksum field for the tar header

type

File type -- numeric, but comparable to exported constants -- see Archive.Tar's documentation

linkname

If the file is a symlink, the file it's pointing to

magic

Tar magic string -- not useful for most users

version

Tar version string -- not useful for most users

uname

The user name that owns the file

gname

The group name that owns the file

devmajor

Device major number in case of a special file

devminor

Device minor number in case of a special file

prefix

Any directory to prefix to the extraction path, if any

raw

Raw tar header -- not useful for most users

METHODS

tarfile.getContent()

Return the file's contents.

*/

if (typeof(Archive) == 'undefined' || typeof(Archive.Tar) == 'undefined')
    throw new Error("Archive.Tar is required");

Archive.Tar.File = function (header,content) {
    this._hdr = header;
    this._cnt = content;
    return this;
}

Archive.Tar.File.prototype.getContent = function () { return this._cnt };

Archive.Tar.File.prototype.name     = function () { return this._hdr.name };
Archive.Tar.File.prototype.mode     = function () { return this._hdr.mode };
Archive.Tar.File.prototype.uid      = function () { return this._hdr.uid };
Archive.Tar.File.prototype.gid      = function () { return this._hdr.gid };
Archive.Tar.File.prototype.size     = function () { return this._hdr.size };
Archive.Tar.File.prototype.mtime    = function () { return this._hdr.mtime };
Archive.Tar.File.prototype.chksum   = function () { return this._hdr.chksum };
Archive.Tar.File.prototype.type     = function () { return this._hdr.type };
Archive.Tar.File.prototype.linkname = function () { return this._hdr.linkname };
Archive.Tar.File.prototype.type     = function () { return this._hdr.type };
Archive.Tar.File.prototype.magic    = function () { return this._hdr.magic };
Archive.Tar.File.prototype.version  = function () { return this._hdr.version };
Archive.Tar.File.prototype.gname    = function () { return this._hdr.gname };
Archive.Tar.File.prototype.uname    = function () { return this._hdr.uname };
Archive.Tar.File.prototype.devmajor = function () { return this._hdr.devmajor };
Archive.Tar.File.prototype.devminor = function () { return this._hdr.devminor };
Archive.Tar.File.prototype.prefix   = function () { return this._hdr.prefix };

/*