1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00

Fix/update doc for dir object (#5291)

* Fix arg type in Wire to size_t

* Document dir.fileSize() and other nearby doc fixes
This commit is contained in:
Develo 2018-10-29 14:53:50 -03:00 committed by GitHub
parent ef95e05319
commit 8785143bff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -278,7 +278,7 @@ Directory object (Dir)
---------------------- ----------------------
The purpose of *Dir* object is to iterate over files inside a directory. The purpose of *Dir* object is to iterate over files inside a directory.
It provides three methods: ``next()``, ``fileName()``, and It provides the methods: ``next()``, ``fileName()``, ``fileSize()`` , and
``openFile(mode)``. ``openFile(mode)``.
The following example shows how it should be used: The following example shows how it should be used:
@ -288,21 +288,41 @@ The following example shows how it should be used:
Dir dir = SPIFFS.openDir("/data"); Dir dir = SPIFFS.openDir("/data");
while (dir.next()) { while (dir.next()) {
Serial.print(dir.fileName()); Serial.print(dir.fileName());
File f = dir.openFile("r"); if(dir.fileSize()) {
Serial.println(f.size()); File f = dir.openFile("r");
Serial.println(f.size());
}
} }
``dir.next()`` returns true while there are files in the directory to next
iterate over. It must be called before calling ``fileName`` and ~~~~
``openFile`` functions.
``openFile`` method takes *mode* argument which has the same meaning as Returns true while there are files in the directory to
for ``SPIFFS.open`` function. iterate over. It must be called before calling ``fileName()``, ``fileSize()``,
and ``openFile()`` functions.
fileName
~~~~~~~~~
Returns the name of the current file pointed to
by the internal iterator.
fileSize
~~~~~~~~
Returns the size of the current file pointed to
by the internal iterator.
openFile
~~~~~~~~
This method takes *mode* argument which has the same meaning as
for ``SPIFFS.open()`` function.
File object File object
----------- -----------
``SPIFFS.open`` and ``dir.openFile`` functions return a *File* object. ``SPIFFS.open()`` and ``dir.openFile()`` functions return a *File* object.
This object supports all the functions of *Stream*, so you can use This object supports all the functions of *Stream*, so you can use
``readBytes``, ``findUntil``, ``parseInt``, ``println``, and all other ``readBytes``, ``findUntil``, ``parseInt``, ``println``, and all other
*Stream* methods. *Stream* methods.