files

package
v1.13.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 11, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package files provides file I/O primitives.

Textual File I/O (R7RS 6.13.1)

  • open-input-file, open-output-file
  • call-with-input-file, call-with-output-file
  • with-input-from-file, with-output-to-file

Binary File I/O

  • open-binary-input-file, open-binary-output-file

File Predicates

  • file-exists?, delete-file

Directory Operations (SRFI-170)

  • create-directory, delete-directory, directory-files
  • current-directory, set-current-directory!

Use Extension or AddToRegistry to register all primitives.

Package files provides file I/O primitives.

Index

Constants

This section is empty.

Variables

View Source
var AddToRegistry = Builder.AddToRegistry

AddToRegistry registers all file primitives.

View Source
var Builder = registry.NewRegistryBuilder(addPrimitives, addMacros)

Builder aggregates all file registration functions.

View Source
var Extension = registry.NewDescribedExtension("files",
	"Filesystem operations: file I/O, directory traversal, temporary files.",
	AddToRegistry)

Extension is the file I/O extension.

Functions

func PrimCallWithInputFile

func PrimCallWithInputFile(cc machine.CallContext) error

PrimCallWithInputFile implements the call-with-input-file primitive.

func PrimCallWithOutputFile

func PrimCallWithOutputFile(cc machine.CallContext) error

PrimCallWithOutputFile implements the call-with-output-file primitive.

func PrimCreateDirectory added in v1.9.1

func PrimCreateDirectory(mc machine.CallContext) error

PrimCreateDirectory implements the (create-directory) primitive. Creates a single directory level. Errors if it already exists or the parent is missing (no recursive mkdir -p behavior).

func PrimCurrentDirectory added in v1.9.1

func PrimCurrentDirectory(mc machine.CallContext) error

PrimCurrentDirectory implements the (current-directory) primitive. Returns the current working directory as a string.

func PrimDeleteDirectory added in v1.9.1

func PrimDeleteDirectory(mc machine.CallContext) error

PrimDeleteDirectory implements the (delete-directory) primitive. Removes an empty directory. Errors if not empty, nonexistent, or not a directory.

func PrimDeleteFile

func PrimDeleteFile(mc machine.CallContext) error

PrimDeleteFile implements the (delete-file) primitive. Deletes a file from the filesystem.

func PrimDirectoryFiles added in v1.9.1

func PrimDirectoryFiles(mc machine.CallContext) error

PrimDirectoryFiles implements the (directory-files) primitive. Returns a list of filename strings in the directory, excluding "." and "..". Names are filenames only (not full paths).

func PrimFileExistsQ

func PrimFileExistsQ(mc machine.CallContext) error

PrimFileExistsQ implements the (file-exists?) primitive. Returns #t if file exists.

func PrimOpenBinaryInputFile

func PrimOpenBinaryInputFile(mc machine.CallContext) error

PrimOpenBinaryInputFile implements the open-binary-input-file primitive (R7RS). Opens a file for binary reading and returns a binary input port.

func PrimOpenBinaryOutputFile

func PrimOpenBinaryOutputFile(mc machine.CallContext) error

PrimOpenBinaryOutputFile implements the open-binary-output-file primitive (R7RS). Opens a file for binary writing and returns a binary output port.

func PrimOpenInputFile

func PrimOpenInputFile(mc machine.CallContext) error

PrimOpenInputFile implements the open-input-file primitive. Opens a file for reading and returns an input port.

func PrimOpenOutputFile

func PrimOpenOutputFile(mc machine.CallContext) error

PrimOpenOutputFile implements the open-output-file primitive. Opens a file for writing and returns an output port.

func PrimSetCurrentDirectory added in v1.9.1

func PrimSetCurrentDirectory(mc machine.CallContext) error

PrimSetCurrentDirectory implements the (set-current-directory!) primitive.

WARNING: os.Chdir is process-global. Multiple engines in the same Go process share a single working directory. Concurrent calls from different goroutines race on the same OS state. This is inherent to POSIX — there is no per-thread working directory.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL