Skip to content

Unable to get file size within a search loop #19

@nigeljohnson73

Description

@nigeljohnson73

Subject of the issue

As well as the file names, I want to see the file sizes (so I can delete them if they are zero, but one thing at a time). Using example 7 and adding this inside the while loop (and nothing else)

long sizeOfFile = myLog.size(fileName);

Crashes the logger and you need a restart.

Your workbench

  • What development board or microcontroller are you using? Feather S3 8M Flash no PSRAM
  • What version of hardware or breakout board are you using?Qwiic OpenLog version 3.1
  • How is the breakout board wired to your microcontroller? QWIIC
  • How is everything being powered? USB
  • Are there any additional details that may help us help you? Don't think so

Steps to reproduce

Get example 7 working. Then add the line above in the while loop. It should look more like this:

  String fileName = myLog.getNextDirectoryItem();
  while (fileName != "") //getNextDirectoryItem() will return "" when we've hit the end of the directory
  {
    long sizeOfFile = myLog.size(fileName); // <<<<--- here we are
    Serial.println(fileName);
    fileName = myLog.getNextDirectoryItem();
  }
  Serial.println(F("Done!"));

Expected behavior

I would expect to get the file size back and be able to continue with the while loop

Actual behavior

Before the update:

OpenLog Read Directory Test
List of things in this directory:
config.txt
LOG00259.TXT
20220708/
LOG00244.TXT
LOG00245.TXT
LOG00246.TXT
LOG00247.TXT
LOG00248.TXT
LOG00249.TXT
LOG00250.TXT
LOG00251.TXT
LOG00252.TXT
... etc

After the update:

OpenLog Read Directory Test
List of things in this directory:
config.txt
�⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮
Done!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions