Skip to content
/ fs Public
forked from babashka/fs

File system utility library for Clojure

License

Notifications You must be signed in to change notification settings

eval/fs

This branch is 52 commits behind babashka/fs:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

8a8bfa6 · Jan 16, 2023
Nov 19, 2021
Nov 16, 2022
May 4, 2022
Mar 24, 2022
Nov 19, 2021
May 4, 2022
Jan 16, 2023
Dec 8, 2022
Jan 16, 2023
May 4, 2022
Jan 16, 2023
Jan 16, 2023
Nov 16, 2020
Oct 7, 2022
Aug 11, 2022
Oct 8, 2022
Feb 23, 2022
Jan 16, 2023

Repository files navigation

babashka.fs

Clojars Project bb built-in

File system utilities. This library can be used on the JVM and is also included in babashka (>= 0.2.9).

Why

Babashka is a scripting utility. It's convenient to have cross platform file system utilities available for scripting. The namespace clojure.java.io already offers a bunch of useful features, but it predates java.nio. The nio package isn't that nice to use from Clojure and this library should help with that.

The main inspirations for this library are clojure.java.io, clj-commons/fs and corasaurus-hex/fs.

API docs

See API.md.

Usage

(require '[babashka.fs :as fs])
(fs/directory? ".") ;;=> true

Examples

The glob function takes a root path and a pattern. The pattern is interpreted as documented here.

(map str (fs/glob "." "**{.clj,cljc}"))

Output:

("project.clj" "test/babashka/fs_test.clj" "src/babashka/fs.cljc")

The function exec-paths returns all entries from PATH as Paths. To search all these directories for an executable, e.g. java, you can combine it with list-dirs which searches files directly in the directories using an (optional) glob pattern:

(str (first (filter fs/executable? (fs/list-dirs (filter fs/exists? (fs/exec-paths)) "java"))))
"/Users/borkdude/.jenv/versions/11.0/bin/java"

For convenience, the above use case is also supported using the which function:

(str (fs/which "java"))
"/Users/borkdude/.jenv/versions/11.0/bin/java"

Test

$ bb test

License

Copyright © 2020-2021 Michiel Borkent

Distributed under the EPL License, same as Clojure. See LICENSE.

About

File system utility library for Clojure

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Clojure 54.2%
  • HTML 35.5%
  • CSS 7.3%
  • JavaScript 2.9%
  • Shell 0.1%