{"id":28816842,"url":"https://github.com/babashka/fs","last_synced_at":"2026-02-05T17:01:32.105Z","repository":{"id":40479492,"uuid":"313251215","full_name":"babashka/fs","owner":"babashka","description":"File system utility library for Clojure","archived":false,"fork":false,"pushed_at":"2025-06-07T12:31:58.000Z","size":408,"stargazers_count":186,"open_issues_count":6,"forks_count":46,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-06-08T22:13:45.265Z","etag":null,"topics":["clojure","java-nio"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/babashka.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-11-16T09:30:24.000Z","updated_at":"2025-06-07T12:29:32.000Z","dependencies_parsed_at":"2024-12-24T14:06:17.211Z","dependency_job_id":"ac6703f8-b7d7-41ff-93ec-f7b0a8825666","html_url":"https://github.com/babashka/fs","commit_stats":{"total_commits":315,"total_committers":21,"mean_commits":15.0,"dds":0.08253968253968258,"last_synced_commit":"6ac97223ce721f122671f8a28bba0f1e7f91cb18"},"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"purl":"pkg:github/babashka/fs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babashka%2Ffs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babashka%2Ffs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babashka%2Ffs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babashka%2Ffs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/babashka","download_url":"https://codeload.github.com/babashka/fs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babashka%2Ffs/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260089782,"owners_count":22957149,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clojure","java-nio"],"created_at":"2025-06-18T17:07:21.105Z","updated_at":"2026-02-05T17:01:32.089Z","avatar_url":"https://github.com/babashka.png","language":"Clojure","readme":"# babashka.fs\n\n[![Clojars Project](https://img.shields.io/clojars/v/babashka/fs.svg)](https://clojars.org/babashka/fs) [![ci](https://github.com/babashka/fs/actions/workflows/ci.yml/badge.svg)](https://github.com/babashka/fs/actions/workflows/ci.yml)\n[![bb built-in](https://raw.githubusercontent.com/babashka/babashka/master/logo/built-in-badge.svg)](https://book.babashka.org#badges)\n\nFile system utilities. This library can used from:\n- [Clojure on the JVM](https://www.clojure.org/guides/install_clojure) - we support Clojure 1.10.3 and above on Java 11 and above.\n- [babashka](https://github.com/babashka/babashka) - it has been a built-in library since babashka v0.2.9.\n\n## Why\n\nBabashka is a scripting utility. It's convenient to have cross platform file\nsystem utilities available for scripting. The namespace `clojure.java.io`\nalready offers a bunch of useful features, but it predates `java.nio`. The nio\npackage isn't that nice to use from Clojure and this library should help with\nthat.\n\nThe main inspirations for this library are\n[clojure.java.io](https://clojure.github.io/clojure/clojure.java.io-api.html),\n[clj-commons/fs](https://github.com/clj-commons/fs) and\n[corasaurus-hex/fs](https://github.com/corasaurus-hex/fs/blob/master/src/corasaurus_hex/fs.clj).\n\n## API docs\n\nSee [API.md](API.md).\n\n## Usage\n\n``` clojure\n(require '[babashka.fs :as fs])\n(fs/directory? \".\") ;;=\u003e true\n```\n\n## Examples\n\nThe `glob` function takes a root path and a pattern. The pattern is interpreted\nas documented\n[here](https://docs.oracle.com/javase/7/docs/api/java/nio/file/FileSystem.html#getPathMatcher(java.lang.String)).\n\n``` clojure\n(map str (fs/glob \".\" \"**{.clj,cljc}\"))\n```\n\nOutput:\n\n``` clojure\n(\"project.clj\" \"test/babashka/fs_test.clj\" \"src/babashka/fs.cljc\")\n```\n\nThe function `exec-paths` returns all entries from `PATH` as `Path`s. To search\nall these directories for an executable, e.g. `java`, you can combine it with\n`list-dirs` which searches files directly in the directories using an (optional)\nglob pattern:\n\n``` clojure\n(str (first (filter fs/executable? (fs/list-dirs (filter fs/exists? (fs/exec-paths)) \"java\"))))\n\"/Users/borkdude/.jenv/versions/11.0/bin/java\"\n```\n\nFor convenience, the above use case is also supported using the `which` function:\n\n``` clojure\n(str (fs/which \"java\"))\n\"/Users/borkdude/.jenv/versions/11.0/bin/java\"\n```\n\n## Notes \n\n### File Systems \u0026 OSes\nBehaviour can vary on different file systems and OSes.\nIf you uncover some interesting nuance, please let us know. \n\n### Empty String Paths\nThe underlying JDK file APIs (and, by extension, babashka.fs) typically consider an empty-string path `\"\"` to be the current working directory. This means that `(fs/list-dir \"\")` is functionally equivalent to `(fs/list-dir \".\")`.\n\n\u003c!-- note: linked from docstring --\u003e\n### creation-time\nDepending on which OS and JDK version you are running, `creation-time` might return unexpected results.\nAs of this writing, our testing has revealed: \n- Windows - returns creation time as expected\n- macOS \n  - after Java 17 returns creation time as expected\n  - otherwise returns modified time\n- Linux \n  - before Java 17 returns modified time\n  - otherwise returns creation time\n\nSee [JDK-8316304](https://bugs.openjdk.org/browse/JDK-8316304).\n\n\u003c!-- note: linked from docstring --\u003e\n### set-creation-time\nDepending on which OS and JDK version you are running, `set-creation-time` might not do what you would expect. \nAs of this writing, our testing has revealed:\n- Windows - sets creation time as expected\n- macOS\n  - after Java 17 sets creation time as expected\n  - otherwise has no effect\n- Linux - seems to have no effect\n\nSee [JDK-8151430](https://bugs.openjdk.org/browse/JDK-8151430)\n\n\u003c!-- note: linked from docstring --\u003e\n### :nofollow-links\nMany babashka.fs functions accept the `:nofollow-links` option.\nThese functions will follow symbolic links unless you pass in `{:nofollow-links true}`.\n\n\u003c!-- note: linked from docstring --\u003e\n### :follow-links\nSome babashka.fs functions accept the `:follow-links` option.\nThese functions will _not_ follow symbolic links unless you pass in `{:follow-links true}`.\n\n## Test \u0026 Dev\n\nTo run all tests\n```\n$ bb test\n```\n\nYou can also use [cognitect test-runner](https://github.com/cognitect-labs/test-runner?tab=readme-ov-file#invoke-with-clojure--m-clojuremain) options, for example, to run a single test:\n```\nbb test --var babashka.fs-test/walk-test\n```\n\n\u003e [!NOTE]\n\u003e To allow us to contrive isolated file system scenarios, tests are always run from the scratch current working directory `./target/test-cwd`.\n\nTo fire up a REPL when working on these tests, run:\n\n```\nbb dev\n```\n\n\u003e [!TIP]\n\u003e The `.nrepl-port` file will be generated under `./target/test-cwd/`, so you'll have to type the REPL port in manually when connecting.\n\n### API Docs\nThis project generates API docs with quickdoc, to regenerate `API.md`:\n```\nshell quickdoc\n```\n\n## License\n\nCopyright © 2020-2025 Michiel Borkent\n\nDistributed under the EPL License, same as Clojure. See LICENSE.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbabashka%2Ffs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbabashka%2Ffs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbabashka%2Ffs/lists"}