Scandir (scandir v0.1.0)

Copy Markdown

Incremental, non-recursive directory enumeration with raw binary names.

Summary

Functions

Closes a cursor. Closing an already closed cursor succeeds.

The largest accepted visit budget for next/2.

Visits up to max_visited entries, including skipped . and ...

Opens a directory by its non-empty, NUL-free OS path. Start :scandir first.

Types

cursor()

@opaque cursor()

kind()

@type kind() :: :directory | :regular | :symlink | :unknown | :other

reason()

@type reason() ::
  :badarg
  | :busy
  | :closed
  | :enoent
  | :enotdir
  | :eacces
  | :eperm
  | :emfile
  | :enfile
  | :enomem
  | :enametoolong
  | :eloop
  | :eintr
  | :eio

Functions

close(cursor)

@spec close(cursor()) :: :ok | {:error, reason()}

Closes a cursor. Closing an already closed cursor succeeds.

max_batch()

@spec max_batch() :: 128

The largest accepted visit budget for next/2.

next(cursor, max_visited)

@spec next(cursor(), pos_integer()) ::
  {:ok, [{binary(), kind()}], :more | :eof} | {:error, reason()}

Visits up to max_visited entries, including skipped . and ...

open(path)

@spec open(binary()) :: {:ok, cursor()} | {:error, reason()}

Opens a directory by its non-empty, NUL-free OS path. Start :scandir first.