embedfs

Embed static files easily

Pure Nim score 15/100 · tests present · no docs generated

Summary

Latest Version 0.2.0
License MIT
CI Status Failing
Downloads 0
Last Indexed 2026-07-21 05:25

Authors

  • Matt Haggard

Installation

nimble install embedfs
choosenim install embedfs
git clone https://github.com/iffy/nim-embedfs

OS Compatibility

Platform Linux macOS Windows FreeBSD OpenBSD NetBSD Android iOS WASM Embedded
embedfs - - - - - - -

Dependencies

Package Version Optional
nim >= 1.6.10 No

Source

Repository https://github.com/iffy/nim-embedfs
Homepage https://github.com/iffy/nim-embedfs
Registry Source nimble_official

README

embedfs

Embed directories of files in your executable. It's like staticRead/slurp for whole directories.

.github/workflows/tests.yml

Installation

nimble install embedfs

Usage

import embedfs
const data = embedDir("data")
echo data.get("somefile.txt").get()
doAssert data.get("nonexisting.txt").isNone

for filename in data.listDir():
  echo filename

for filename in data.walk():
  echo filename

You can also change from embedding at compile-time (the default) to reading files from disk at runtime for testing purposes with embed = false, because sometimes it's nice to not have to recompile the whole program just to get new assets:

import embedfs
const data = embedDir("data", embed = false)
writeFile("data"/"foo.txt", "foo")
doAssert data.get("foo.txt") == some("foo")
writeFile("data"/"foo.txt", "new value")
doAssert data.get("foo.txt") == some("new value")