summaryrefslogtreecommitdiff
path: root/filesystem-posix.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2021-02-13 15:47:30 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2021-02-13 15:47:30 -0500
commite9357bfd982b37672ed9c319956af32bf3db7856 (patch)
treeebc8d3d514725b9402f8316f92aafe2fe14fb22c /filesystem-posix.c
parentcdca3cc10dceda9580b2d87c2105c0654aa084fc (diff)
view-only mode
Diffstat (limited to 'filesystem-posix.c')
-rw-r--r--filesystem-posix.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/filesystem-posix.c b/filesystem-posix.c
index ebf1407..8af0bf2 100644
--- a/filesystem-posix.c
+++ b/filesystem-posix.c
@@ -16,6 +16,14 @@ FsType fs_path_type(char const *path) {
return FS_OTHER;
}
+FsPermission fs_path_permission(char const *path) {
+ int bits = access(path, R_OK | W_OK);
+ FsPermission perm = 0;
+ if (!(bits & R_OK)) perm |= FS_PERMISSION_READ;
+ if (!(bits & W_OK)) perm |= FS_PERMISSION_WRITE;
+ return perm;
+}
+
bool fs_file_exists(char const *path) {
return fs_path_type(path) == FS_FILE;
}