@@ -278,7 +278,7 @@ Directory object (Dir)
278
278
----------------------
279
279
280
280
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
282
282
``openFile(mode) ``.
283
283
284
284
The following example shows how it should be used:
@@ -288,21 +288,41 @@ The following example shows how it should be used:
288
288
Dir dir = SPIFFS.openDir("/data");
289
289
while (dir.next()) {
290
290
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
+ }
293
295
}
294
296
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
+ ~~~~~~~~
298
318
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.
301
321
302
322
File object
303
323
-----------
304
324
305
- ``SPIFFS.open `` and ``dir.openFile `` functions return a *File * object.
325
+ ``SPIFFS.open() `` and ``dir.openFile() `` functions return a *File * object.
306
326
This object supports all the functions of *Stream *, so you can use
307
327
``readBytes ``, ``findUntil ``, ``parseInt ``, ``println ``, and all other
308
328
*Stream * methods.
0 commit comments