Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update create-temp* docs #129

Merged
merged 1 commit into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,15 @@ Create a soft link from path to target.
``` clojure

(create-temp-dir)
(create-temp-dir {:keys [:prefix :dir :posix-file-permissions], :as opts})
(create-temp-dir {:keys [:dir :prefix :posix-file-permissions], :as opts})
```

Creates a temporary directory using Files#createDirectories.

`(create-temp-dir)`: creates temp dir with random prefix.
`(create-temp-dir {:keys [:prefix :dir :posix-file-permissions]})`:
- `(create-temp-dir)`: creates temp dir with random prefix.

create temp dir in dir path with prefix. If prefix is not provided, a random one
- `(create-temp-dir {:keys [:dir :prefix :posix-file-permissions]})`:
create temp dir in dir 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)`.
File permissions can be specified with an `:posix-file-permissions` option.
String format for posix file permissions is described in the [`str->posix`](#babashka.fs/str->posix) docstring.
Expand All @@ -247,8 +247,8 @@ 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,
- `(create-temp-dir {:keys [:dir :prefix :suffix :posix-file-permissions]})`:
create temp file in dir 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`](#babashka.fs/str->posix) docstring.
Expand Down
12 changes: 6 additions & 6 deletions src/babashka/fs.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -506,18 +506,18 @@
(defn create-temp-dir
"Creates a temporary directory using Files#createDirectories.

`(create-temp-dir)`: creates temp dir with random prefix.
`(create-temp-dir {:keys [:prefix :dir :posix-file-permissions]})`:
- `(create-temp-dir)`: creates temp dir with random prefix.

create temp dir in dir path with prefix. If prefix is not provided, a random one
- `(create-temp-dir {:keys [:dir :prefix :posix-file-permissions]})`:
create temp dir in dir 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)`.
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))
(make-array FileAttribute 0)))
([{:keys [:prefix :dir :posix-file-permissions] :as opts}]
([{:keys [:dir :prefix :posix-file-permissions] :as opts}]
(let [attrs (posix->attrs posix-file-permissions)
prefix (or prefix (str (java.util.UUID/randomUUID)))
dir (or dir (:path opts))]
Expand All @@ -535,8 +535,8 @@

- `(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,
- `(create-temp-dir {:keys [:dir :prefix :suffix :posix-file-permissions]})`:
create temp file in dir 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."
Expand Down
Loading