Skip to content
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

Added mkdir/rmdir support to file module. #3488

Merged
merged 1 commit into from
Jan 17, 2023

Conversation

jmattsson
Copy link
Member

  • This PR is for the dev branch rather than for the release branch.
  • This PR is compliant with the other contributing guidelines as well (if not, please describe why).
  • I have thoroughly tested my contribution.
  • The code changes are reflected in the documentation at docs/*.

When working with SD cards formatting with FAT, having the ability to create and remove directories become important. This PR exposes the IDF's mkdir and rmdir functions via the file module, since there is no standard Lua interface for it.

const char *name = luaL_checkstring(L, 1);
unsigned mode = luaL_optint(L, 2, 0777);
int ret = mkdir(name, mode);
if (ret != 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You know I'm not a firmware programmer 😉 but I'd write this like so:

if (mkdir(name, mode) != 0) {
  return luaL_error(L, "failed to create directory '%s'; code %d", name, errno);
}
return 0;
  • you use if/else here but only if in file_rmdir (inconsistent style)
  • no need for the local ret variable
  • {} even for single line if blocks, seems consistent with the other code in file.c

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You keep claiming not to be one, yet the quality I've seen from you surpasses that of many a professional firmware programmer I've come across.

All fair points; I've updated accordingly, thanks.

Oh, and when you're ready, let's do the dev-esp32 -> dev-esp32-idf3-final + dev-esp32-idf4 -> dev-esp32 renames. As far as I'm aware the idf4 branch is production ready (or at least I hope so, seeing as we've been shipping devices based off it for a while at $work 😆).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, and when you're ready, let's do the dev-esp32 -> dev-esp32-idf3-final + dev-esp32-idf4 -> dev-esp32 renames.

Oh absolutely, I am not opposed to that. The fact that neither marcelstoer/docker-nodemcu-build#101 nor marcelstoer/nodemcu-custom-build#41 are ready, doesn't mean the progress of this project should be held hostage.

@jmattsson
Copy link
Member Author

Somehow a year has already passed. @marcelstoer I'm going to both merge this and do the discussed branch renaming now; I've dawdled long enough, and I'm going to feel silly working on IDF5 support on a branch named IDF4 :D
Also CC @pjsg a heads-up. I think we're the only active members on ESP32 at the moment?

@jmattsson jmattsson merged commit 55dbcc7 into nodemcu:dev-esp32-idf4 Jan 17, 2023
@jmattsson jmattsson deleted the dev-esp32-idf4-dirfuncs branch January 17, 2023 03:34
@marcelstoer
Copy link
Member

Thanks Johny. Can you also close the "migrate to IDF 4" tickets. IIRC there must be more than one.

I am really out of touch with the development here. Hence, I might need some help with marcelstoer/docker-nodemcu-build#101 and marcelstoer/nodemcu-custom-build#41. Probably won't take long until the support emails start coming in now 😄

@jmattsson
Copy link
Member Author

I don't see any such tickets here. Do you have a link?

@marcelstoer
Copy link
Member

Looks like #3397 is the only one out of those labeled with "ESP32": https://github.com/nodemcu/nodemcu-firmware/issues?q=is%3Aopen+is%3Aissue+label%3AESP32

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

Successfully merging this pull request may close these issues.

3 participants