Skip to content

Files created without leading / in filename are nowhere #4748

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
5 of 6 tasks
borisneubert opened this issue May 20, 2018 · 1 comment
Closed
5 of 6 tasks

Files created without leading / in filename are nowhere #4748

borisneubert opened this issue May 20, 2018 · 1 comment

Comments

@borisneubert
Copy link

borisneubert commented May 20, 2018

Basic Infos

  • This issue complies with the issue POLICY doc.
  • I have read the documentation at readthedocs and the issue is not addressed there.
  • I have tested that the issue is present in current master branch (aka latest git).
  • I have searched the issue tracker for a similar issue.
  • If there is a stack dump, I have decoded it.
  • I have filled out all fields below.

Platform

  • Hardware: ESP8266 (NodeMCU 4M)
  • Core Version: latest, 2.4.1
  • Development Env: Platformio
  • Operating System: Ubuntu

Settings in IDE

  • Module: Wemos D1 mini
  • Flash Mode: dio
  • Flash Size: 4MB
  • lwip Variant:
  • Reset Method:
  • Flash Frequency: 40Mhz
  • CPU Frequency: 80Mhz
  • Upload Using: SERIAL
  • Upload Speed: 921600

Problem Description

The documentation states that a filename needs to start with a slash but this is not quite obvious. Trying to open a file for writing whose filename has no leading slash is successful. I can even write to the file, close it and determine its size afterwards. It only does not show up in a directory listing.

Either opening a file whose filename does not start with a leading slash should fail in the first place or the leading slash should be implicitely added.

Code Snippet

String filename= "bar.txt";
File file= SPIFFS.open(filename, "w");
file.write((uint8_t*)buffer, 8);
file.close();
@earlephilhower
Copy link
Collaborator

Just did a test and files created without a slash are present in directory lists.

SPIFFS does not have directories, and "openDir(x)" matches the string sent in. A "/" is just another character, not a directory separator.

So a file created as "bar.txt" will not be present in a openDir("/"); listing, but is present if you do openDir("");. If you open("bar.txt", "r"); it opens just fine, too.

Closing as working-as-SPIFFS-is-designed. For real directories, look at the LittleFS or SDFS PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants