-
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
Add file.stat() to query file/directory attributes. #1724
Conversation
@@ -13,6 +13,14 @@ | |||
|
|||
#define FILE_READ_CHUNK 1024 | |||
|
|||
// use this time/date in absence of a timestamp | |||
#define FILE_TIMEDEF_YEAR 2016 |
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.
Can I recommend using a more common value for the epoch? E.g. the Unix epoch (Jan 1, 1970) or ZigBee (Jan 1, 2000).
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.
Ok, the Unix epoch is used now as default.
lua_pushstring( L, key ); | ||
lua_pushboolean( L, b ); | ||
lua_rawset( L, -3 ); | ||
} |
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.
Instead/for all of the above helpers, why not use lua_setfield()
?
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.
I wasn't aware of this function, changed.
|
||
- `size` file size in bytes | ||
- `name` file name | ||
- `time` table with time stamp information. Default is 2016-06-21 00:00:00 in case time stamps are not supported (on SPIFFS). |
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.
Don't forget this if changing the epoch...
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.
Done.
Wouldn't that make sense for the OO API as well: |
use lua_setfield
Augments to #1321.
dev
branch rather than formaster
.docs/en/*
.New function
file.stat()
retrieves file/directory attributes in a table:Works on both SPIFFS and FatFs, with SPIFFS providing meaningful information only for name and size (other items are present but default).