Adding kumo.fs.stat to get file/dir meta data#497
Merged
wez merged 5 commits intoKumoCorp:mainfrom Apr 4, 2026
Merged
Conversation
wez
reviewed
Mar 31, 2026
wez
reviewed
Apr 2, 2026
Collaborator
wez
left a comment
There was a problem hiding this comment.
Looking good! A couple of small changes and I think we're there!
Comment on lines
+46
to
+47
| let atime_secs = this.0.atime(); | ||
| system_time_to_lua_time(lua, Some(atime_secs)) |
Collaborator
There was a problem hiding this comment.
A couple of things for these time accessors:
- We have the nanosecond component available and we can feed that into chrono to get sub-second precision
- We don't need an Option around either seconds or nanoseconds
- There's an unwrap that we should avoid in case someone manages to put complete nonsense into time fields (eg: might happen if the fs is corrupt, but might also be possible if someone gets creative)
Something like this:
Suggested change
| let atime_secs = this.0.atime(); | |
| system_time_to_lua_time(lua, Some(atime_secs)) | |
| let secs = this.0.atime(); | |
| let nsec = this.0.atime_nsec(); | |
| let dt = DateTime::<Utc>::from_timestamp(secs, nsec) | |
| .map_err(mlua::Error::external)?; | |
| Ok(Time::from(dt)) |
which you can also turn into a little macro for the 3 different timestamps or amend the system_time_to_lua_time helper function accordingly.
|
|
||
| ```lua | ||
| kumo.fs.metadata_for_path(path) | ||
| kumo.fs.symlink_metadata_for_path(path) |
Collaborator
There was a problem hiding this comment.
I'd appreciate having a separate doc page for symlink_metadata_for_path to make the search experience (potentially!) better, but it needn't copy the full text from here; it can have a stub paragraph below its synopsis and other metadata that says something like:
This function behaves exactly like [metadata_for_path](metadata_for_path.md),
except that it does not follow symbolic links and instead returns information
about the symbolic link itself.
Collaborator
|
Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I personally wanted to get the last modified time of a file for the function i'm working on.
other attributes aren't necessarily required, but adding them as it may help others.