Skip to content

SD open(): behavior on missing path on write #5019

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
fabianoriccardi opened this issue Apr 6, 2021 · 9 comments · Fixed by #5721
Closed

SD open(): behavior on missing path on write #5019

fabianoriccardi opened this issue Apr 6, 2021 · 9 comments · Fixed by #5721
Assignees

Comments

@fabianoriccardi
Copy link

Hi,

I had noted that SD.open(/path/to/file/, "w") does not create the path to file if missing. I think this behavior is intuitive if you know the underlying implementation fopen, which does not create missing folders. However, I was used to ESP8266 Arduino core (SDFS and SPIFFS), and the common behavior creates any missing path.
Is this an intended behavior or a bug? Is there a parameter to force automatic creation of missing path?

IMHO, create missing path is very intuitive and more suitable for Arduino users.

@stale
Copy link

stale bot commented Jun 18, 2021

[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: Stale Issue is stale stage (outdated/stuck) label Jun 18, 2021
@stale
Copy link

stale bot commented Jul 11, 2021

[STALE_DEL] This stale issue has been automatically closed. Thank you for your contributions.

@stale stale bot closed this as completed Jul 11, 2021
@Villaquiranm
Copy link

Hello @me-no-dev this is marked as closed, but it is still in the To-Do (Seeking Contributors) list.

Do you want someone working on this or this is actually the expected behavior ?

@me-no-dev
Copy link
Member

@Villaquiranm seems that Stale BOT closed it. Surely needs work though :)

@me-no-dev me-no-dev reopened this Sep 1, 2021
@stale
Copy link

stale bot commented Sep 1, 2021

[STALE_CLR] This issue has been removed from the stale queue. Please ensure activity to keep it openin the future.

1 similar comment
@stale
Copy link

stale bot commented Sep 1, 2021

[STALE_CLR] This issue has been removed from the stale queue. Please ensure activity to keep it openin the future.

@stale stale bot removed the Status: Stale Issue is stale stage (outdated/stuck) label Sep 1, 2021
@Villaquiranm
Copy link

Great @me-no-dev thanks a lot for your response, I would like to start working on this (maybe I'll need some mentoring). For the moment I will try to reproduce, understand the code on the library, and compare it to the ESP8266 Arduino core that the author mentioned.

Just to check
desired behavior: to create all the folders on the path if there are not already present ?

@P-R-O-C-H-Y
Copy link
Member

Hello @Villaquiranm and @fabianoriccardi,
in the official Arduino reference of the SD library there is this description of SD.Open().

"Opens a file on the SD card. If the file is opened for writing, it will be created if it doesn't already exist (but the directory containing it must already exist)."

It will create a file if not exist but the directory must already exist.
I checked it and it is acting exactly same as written in Arduino reference and we should stay with the same behavior as the Arduino lib.

Link: https://www.arduino.cc/en/Reference/SDopen

@VojtechBartoska
Copy link
Contributor

@fabianoriccardi PTAL, Is the answer above sufficient?

me-no-dev pushed a commit that referenced this issue Oct 1, 2021
* SD.open() new feature for creating all folders in path

This PR adds to the SD.open() function option to create all folders to the file.

SD.open(const char* path, const char* mode, const bool create)

Default value of create is false.
When true folders are created.

From issue #5019

* Update vfs_api.cpp

memccpy -> memcpy

* File f = open() edit

added false for create
me-no-dev pushed a commit that referenced this issue Oct 9, 2021
* SD.open() new feature for creating all folders in path

This PR adds to the SD.open() function option to create all folders to the file.

SD.open(const char* path, const char* mode, const bool create)

Default value of create is false.
When true folders are created.

From issue #5019

* Update vfs_api.cpp

memccpy -> memcpy

* SD_MMC deinit fix

Wrong deinit function was called.
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

Successfully merging a pull request may close this issue.

5 participants