hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit bcfd87bd0abaf17fa9f2842304fdbd2c74badbd7
parent 0336ba372f1dcfa3319433346dcfcb63328d3f4d
Author: Drew DeVault <sir@cmpwn.com>
Date:   Wed, 24 Feb 2021 11:39:47 -0500

fs: add mode_perm, mode_type

Diffstat:
Mfs/util.ha | 8+++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/fs/util.ha b/fs/util.ha @@ -8,11 +8,17 @@ export fn errstr(err: error) const str = match (err) { }; // Converts a mode into a Unix-like mode string (e.g. "-rw-r--r--") -export fn modestr(mode: mode) const str = { +export fn mode_str(m: mode) const str = { // TODO: blocked on bufio::fixed abort(); }; +// Returns the permission bits of a file mode. +export fn mode_perm(m: mode) mode = (m: uint & 0o777u): mode; + +// Returns the type bits of a file mode. +export fn mode_type(m: mode) mode = (m: uint & ~0o777u): mode; + // Returns true if this item is a regular file. export fn is_file(mode: mode) bool = mode & mode::REG == mode::REG;