Skip to content

os: add os.stat() and helpers - #20739

Merged
spytheman merged 6 commits into
vlang:masterfrom
syrmel:master
Feb 7, 2024
Merged

spytheman merged 6 commits into
vlang:masterfrom
syrmel:master

Conversation

@syrmel

@syrmel syrmel commented Feb 6, 2024

Copy link
Copy Markdown
Member

Adds a platform-agnostic Stat struct and os.stat() function to provide stat() functionality as it is found in other languages and to make it possible to simplify other functions within os like file_size() by consistently using Stat.

Helper functions for the Stat struct have been added to make working with stat info dev-friendly, specifically get_{a|c|m}time() to return a Time struct instead of just the unix epoch and get_filetype() and get_mode() which use existing os structs (FileType, FilePermissions, and FileMode).

Handling of stat-related info is quite different in Windows than in *nix; the required C code has been split up accordingly.

@spytheman spytheman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Excellent work.

@spytheman
spytheman merged commit 205f2dd into vlang:master Feb 7, 2024
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 this pull request may close these issues.

2 participants