From 448208c1b40587bcf2840efc844f15a38f3a352f Mon Sep 17 00:00:00 2001 From: Teodor Heggelund Date: Sat, 13 Apr 2024 10:51:16 +0200 Subject: [PATCH 1/3] fs/create-file: Add :posix-file-permissions info --- src/babashka/fs.cljc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/babashka/fs.cljc b/src/babashka/fs.cljc index 97dcc44..594edd4 100644 --- a/src/babashka/fs.cljc +++ b/src/babashka/fs.cljc @@ -614,7 +614,9 @@ :continue)})))) (defn create-file - "Creates empty file using `Files#createFile`." + "Creates empty file using `Files#createFile`. + + The `:posix-file-permissions` option is a string like `\"rwx------\"`." ([path] (create-file path nil)) ([path {:keys [:posix-file-permissions]}] From c6dbc3d68b475791192ac3be9e6e729d277d7697 Mon Sep 17 00:00:00 2001 From: Teodor Heggelund Date: Sat, 13 Apr 2024 11:30:23 +0200 Subject: [PATCH 2/3] Refer to `str->posix` for file permission strings --- src/babashka/fs.cljc | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/babashka/fs.cljc b/src/babashka/fs.cljc index 594edd4..2a21b53 100644 --- a/src/babashka/fs.cljc +++ b/src/babashka/fs.cljc @@ -384,7 +384,9 @@ (PosixFilePermissions/toString p)) (defn str->posix - "Converts a string to a set of PosixFilePermission." + "Converts a string to a set of PosixFilePermission. + + `s` is a string like `\"rwx------\"`." [s] (PosixFilePermissions/fromString s)) @@ -508,7 +510,9 @@ `(create-temp-dir {:keys [:prefix :dir :posix-file-permissions]})`: create temp dir in dir path with prefix. If prefix is not provided, a random one - is generated. If path is not provided, the directory is created as if called with `(create-temp-dir)`. The `:posix-file-permissions` option is a string like `\"rwx------\"`." + is generated. If path is not provided, the directory is created as if called with `(create-temp-dir)`. + File permissions can be specified with an `:posix-file-permissions` option. + String format for posix file permissions is described in the `str->posix` docstring." ([] (Files/createTempDirectory (str (java.util.UUID/randomUUID)) @@ -530,10 +534,12 @@ "Creates an empty temporary file using Files#createTempFile. - `(create-temp-file)`: creates temp file with random prefix and suffix. - - `(create-temp-dir {:keys [:prefix :suffix :path :posix-file-permissions]})`: create - temp file in path with prefix. If prefix and suffix are not - provided, random ones are generated. The `:posix-file-permissions` - option is a string like `\"rwx------\"`." + + - `(create-temp-dir {:keys [:prefix :suffix :path :posix-file-permissions]})`: + create temp file in path with prefix. If prefix and suffix are not provided, + random ones are generated. + File permissions can be specified with an `:posix-file-permissions` option. + String format for posix file permissions is described in the `str->posix` docstring." ([] (Files/createTempFile (str (java.util.UUID/randomUUID)) @@ -616,7 +622,8 @@ (defn create-file "Creates empty file using `Files#createFile`. - The `:posix-file-permissions` option is a string like `\"rwx------\"`." + File permissions can be specified with an `:posix-file-permissions` option. + String format for posix file permissions is described in the `str->posix` docstring." ([path] (create-file path nil)) ([path {:keys [:posix-file-permissions]}] From ac33a8e9f425508e78e5a8f0eef15c5d41c51ae3 Mon Sep 17 00:00:00 2001 From: Teodor Heggelund Date: Sat, 13 Apr 2024 11:34:57 +0200 Subject: [PATCH 3/3] add CHANGELOG entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27af8e3..b284f3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ Babashka [fs](https://github.com/babashka/fs): file system utility library for C ## Unreleased - [#122](https://github.com/babashka/fs/issues/122): `fs/copy-tree`: fix copying read-only directories with children ([@sohalt](https://github.com/sohalt)) +- [#127](https://github.com/babashka/fs/issues/127): Inconsistent documentation for the `:posix-file-permissions` options ([@teodorlu](https://github.com/teodorlu)) ## v0.5.20 (2023-12-21)