Skip to content

Commit 8785143

Browse files
authored
Fix/update doc for dir object (#5291)
* Fix arg type in Wire to size_t * Document dir.fileSize() and other nearby doc fixes
1 parent ef95e05 commit 8785143

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed

Diff for: doc/filesystem.rst

+29-9
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ Directory object (Dir)
278278
----------------------
279279

280280
The purpose of *Dir* object is to iterate over files inside a directory.
281-
It provides three methods: ``next()``, ``fileName()``, and
281+
It provides the methods: ``next()``, ``fileName()``, ``fileSize()`` , and
282282
``openFile(mode)``.
283283

284284
The following example shows how it should be used:
@@ -288,21 +288,41 @@ The following example shows how it should be used:
288288
Dir dir = SPIFFS.openDir("/data");
289289
while (dir.next()) {
290290
Serial.print(dir.fileName());
291-
File f = dir.openFile("r");
292-
Serial.println(f.size());
291+
if(dir.fileSize()) {
292+
File f = dir.openFile("r");
293+
Serial.println(f.size());
294+
}
293295
}
294296
295-
``dir.next()`` returns true while there are files in the directory to
296-
iterate over. It must be called before calling ``fileName`` and
297-
``openFile`` functions.
297+
next
298+
~~~~
299+
300+
Returns true while there are files in the directory to
301+
iterate over. It must be called before calling ``fileName()``, ``fileSize()``,
302+
and ``openFile()`` functions.
303+
304+
fileName
305+
~~~~~~~~~
306+
307+
Returns the name of the current file pointed to
308+
by the internal iterator.
309+
310+
fileSize
311+
~~~~~~~~
312+
313+
Returns the size of the current file pointed to
314+
by the internal iterator.
315+
316+
openFile
317+
~~~~~~~~
298318

299-
``openFile`` method takes *mode* argument which has the same meaning as
300-
for ``SPIFFS.open`` function.
319+
This method takes *mode* argument which has the same meaning as
320+
for ``SPIFFS.open()`` function.
301321

302322
File object
303323
-----------
304324

305-
``SPIFFS.open`` and ``dir.openFile`` functions return a *File* object.
325+
``SPIFFS.open()`` and ``dir.openFile()`` functions return a *File* object.
306326
This object supports all the functions of *Stream*, so you can use
307327
``readBytes``, ``findUntil``, ``parseInt``, ``println``, and all other
308328
*Stream* methods.

0 commit comments

Comments
 (0)