-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
File LFS Lua module initial commit #3332
Conversation
e3c69df
to
5bc0282
Compare
I like this -- I built something similar (though not so general purpose) for an application that I am working on. This is definitely a better approach! |
@vsky279 could you please not force push? We can squash the commits when merging and the reviewer will have to read everything over again and again. |
Sure, no problem. So I will pile up commits that we squash once ready to be merged. |
I'm delighted to see |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also review my comments in #3329
I feel that a file enhancement should work as usual and throw errors where normal operation can not be guaranteed.
Given the following code
if file.exists("myfile") then file.rename("myfile", "myotherfile") end
print(file.getcontents("myotherfile"))
should work, regardless of myfile being in SPIFFS or LFS.
An alternative would be to throw a meaningful error that the operation is not possible.
Atm copy from a non existing file throws an error (I hope) but with puzzeling message.
Maybe some code to smoothly access the resource like a file might be more useful without blending with file.
Thanks Gregor for all these comments!
I'm sorry I missed these ones.
I suggest the following LFS file behavior:
We already have
Renaming non existing file returns
:thumbsup: file.open("index.html")
print(file.readline()) Oups. I didn't know this approach is still possible. Implemented. |
36192c2
to
953f49a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the long delay.
Now again reviewed and tested and found some issues but then we should be done I think.
Gregor, thanks for this in-deep review. 👍 |
I can't find anywhere what is the limitation for the string length in LFS. |
Looking forward to this working. Will use it in my current project to speed up startup. |
Can we merge this? I think everything has been adressed. |
Yes. Sorry for the delay |
* File LFS module initial commit * LFS file module update #1 * LFS file module update #2 - doc update and file.stat() returning read only attribute * Implementing file.list() * Fine-tuning `file_lfs` module * Adding `file_lfs` to mkdocs.yml * Implementing file.list() update #1 * Fine-tuning * Fine-tuning #2
Fixes #3329.
Make sure all boxes are checked (add x inside the brackets) when you submit your contribution, remove this sentence before doing so.
dev
branch rather than for therelease
branch.docs/*
.Support for arbitrary files stored in LFS
Usage
The module is intended to overlay standard
file
module. If file is present in SPIFFS then this version is preferred. If it is not present then read only access (of course) to the file in LFS is provided.The following functions for LFS files are supported:
file.exists()
file.open()
file.getcontents()
file.read()
,file.obj:read()
file.readline()
,file.obj:readline()
file.seek()
,file.obj:seek()
Other functions are just passed-through to the standard
file
module.When file is embedded in LFS, no standard userdata file structure is created. Instead a Lua object is created.
Example
Also test file for the testing framework (#2983) is provided.