Difference between revisions of "API:DirectoryStream::next"

From Spherical
Jump to: navigation, search
(Add page for DirectoryStream::next())
 
(Note that return value is iterator-like)
 
Line 21: Line 21:
 
=== Return Value ===
 
=== Return Value ===
  
An object with two properties, <tt>.done</tt> and <tt>.value</tt>.  If there are no more entries to retrieve, <tt>.done</tt> is <tt>true</tt> and <tt>.value</tt> is <tt>undefined</tt>.  Otherwise, <tt>.done</tt> is <tt>false</tt> and <tt>.value</tt> is an object describing the directory entry:
+
An object with two properties, <tt>.done</tt> and <tt>.value</tt>, with semantics compatible with the ES2015 iterator protocol.  If there are no more entries to retrieve, <tt>.done</tt> is <tt>true</tt> and <tt>.value</tt> is <tt>undefined</tt>.  Otherwise, <tt>.done</tt> is <tt>false</tt> and <tt>.value</tt> is an object describing the directory entry:
  
 
:{| class="wikitable"
 
:{| class="wikitable"

Latest revision as of 16:32, 17 August 2017


The DirectoryStream::next() method reads the next directory entry from a directory stream.

Usage
dir_entry = dirstream_obj.next();

API Information

Description

DirectoryStream::next() reads the next directory entry from the stream and advances the stream position. The value of DirectoryStream::position determines which entry is read.

Parameters

This method has no parameters.

Return Value

An object with two properties, .done and .value, with semantics compatible with the ES2015 iterator protocol. If there are no more entries to retrieve, .done is true and .value is undefined. Otherwise, .done is false and .value is an object describing the directory entry:

Property Type Description
.fileName string The name of the file or directory, e.g. pig.js. If the entry is a directory, .fileName will end in a slash (/).
.fullPath string The full SphereFS pathname of the file or directory, e.g. @/scripts/pig.js.
.isDirectory boolean true if the entry is a directory, otherwise false.

See Also