(sigil resources)
(sigil resources) - Unified resource resolution for Sigil
Provides access to library, documentation, and asset files with automatic resolution across project builds, bundled archives, and filesystem.
Resolution order:
- Project build output (if package.sgl found in cwd or parents)
- Bundled archive (if running from a bundled executable)
- Executable-relative (assets/ folder next to binary, for 'assets only)
- Filesystem (library-paths for 'lib only)
Resource categories determine the base path:
- 'lib -> project: build/dev/lib/ | bundle: lib/ | system: library-paths
- 'docs -> project: docs/ | bundle: docs/
- 'assets -> project: assets/ | bundle: assets/ | exe-relative: assets/
Example:
(import (sigil resources)) ;; Read module JSON docs (read-resource 'lib "sigil/string.json") ;; Read language reference markdown (read-resource 'docs "reference/language/syntax.md") ;; Read an asset file (read-resource-bytes 'assets "images/logo.png")
Exports
clear-resource-cacheprocedureClear the resource resolution cache.
Use this if you change directories or modify project structure.
project-rootprocedureGet the project root directory, or #f if not in a project.
A project is detected by finding package.sgl in the current directory or any parent directory.
in-project?procedureCheck if currently running within a Sigil project.
resource-contextprocedureGet the current resource resolution context.
Returns 'project if resources are being loaded from a project, 'bundle if from a bundled executable, or 'system for filesystem.
resource-exists?procedureCheck if a resource exists.
Category is one of: 'lib, 'docs, 'assets Path is relative within that category (e.g., "sigil/string.json")
read-resourceprocedureRead a resource as a string.
Returns the file contents as a string, or #f if not found. Category is one of: 'lib, 'docs, 'assets
read-resource-bytesprocedureRead a resource as a bytevector.
Returns the file contents as a bytevector, or #f if not found. Useful for binary assets like images.