Constructor
new FileSystemReader(pathToDirectory)
Creates a new FileSystemReader.
Parameters:
Name | Type | Description |
---|---|---|
pathToDirectory |
string |
The absolute path to the directory 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.
pathToDirectory :string
pathToDirectory is the absolute path to the directory you want to read.
Methods
(static) description() → {PluginDefinition}
Returns a PluginDefinition object describing this plugin.
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".
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.
Events
end
This indicates that the iterator has passed the last entry in the recursive directory tree and there's nothing left to read.
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. |
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. |
error :Error
Indicates something went wrong while reading the directory or one of its subdirectories.