FileSystemReader

FileSystemReader

FileSystemReader provides methods for listing and reading the contents of directories on a locally mounted file system. This is used by the bag validator to validate unserialized (i.e. untarred, unzipped, etc.) bags.

Both FileSystemReader and TarReader implement a common interface and emit a common set of events to provide the bag validator with a uniform interface for reading bags packaged in different formats.

See the list() and read() functions below for information about the events they emit.

Constructor

new FileSystemReader(pathToDirectory)

Creates a new FileSystemReader.

Parameters:
Name Type Description
pathToDirectory string

The absolute path to the directory you want to read.

Source:

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().

Source:

dirCount :number

dirCount is the number of directories encountered during a read() or list() operation.

Source:

fileCount :number

fileCount is the number of files encountered during a read() or list() operation.

Source:

pathToDirectory :string

pathToDirectory is the absolute path to the directory you want to read.

Source:

Methods

(static) description() → {PluginDefinition}

Returns a PluginDefinition object describing this plugin.

Source:

list()

The list() method recursively lists the contents of a directory and returns a relative path and an fs.Stat object for each file it encounters.

It emits the events "entry", "error" and "end".

Source:

read()

The read() method recursively lists the contents of a directory and returns an open reader for each file it encounters.

It emits the events "entry", "error" and "end".

Note that read() will not advance to the next entry until you've read the entire stream returned by the "entry" event.

Source:

Events

end

This indicates that the iterator has passed the last entry in the recursive directory tree and there's nothing left to read.

Source:

entry :object

The entry event of the read() method includes both info about a file in the directory 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 or call the stream's close() method before FileSystemReader.read() will move to the next tar entry.

Properties:
Name Type Description
relPath string

The relative path (within pathToDirectory) of the entry.

stream ReadStream

A stream from which you can read the contents of the entry.

fileStat Stats

An fs.Stats object describing the file's size and other attributes.

Source:

entry :object

The entry event of the list() method returns info about a file or directory, including its relative path and an fs.Stats object.

Properties:
Name Type Description
relPath string

The relative path (within pathToDirectory) of the entry.

fileStat Stats

An fs.Stats object describing the file's size and other attributes.

Source:

error :Error

Indicates something went wrong while reading the directory or one of its subdirectories.

Source: