{ } qjs-modules

directory

Source: quickjs-directory.c — module export: Directory (plus static constants)

Iterates directory entries (a wrapper over opendir/readdir). The object is itself an iterator.

Constructor

new Directory()                       // empty iteration until open() or adopt()
new Directory(path [, flags [, mask]])
new Directory(fd [, flags [, mask]])  // adopts an open descriptor
new Directory(null)                   // same as no argument
new Directory(path, { flags, mask, recursive })
new Directory({ path | fd, flags, mask, recursive })

Directory.length is 1. Without a path or fd, next() returns { done: true } at once instead of throwing.

Methods

MethodArgsDescription
open(path)1Opens path for reading.
adopt(fd)1Wraps an already-open directory handle.
close()0Closes the directory.
valueOf()0Returns the underlying handle/descriptor.
next()0Returns the next entry (iterator protocol).
return()0Ends iteration.
throw(exception)1Injects an exception into the iteration.
[Symbol.iterator]()0Returns the directory iterator.

Static constants

Entry-shape flags: NAME, TYPE, BOTH — control whether next() yields the name, the type, or both.

Entry types: TYPE_BLK, TYPE_CHR, TYPE_DIR, TYPE_FIFO, TYPE_LNK, TYPE_REG, TYPE_SOCK, TYPE_MASK.

Export list

Generated by utilities/doc-api.js from the directory dump of utilities/api-surface.sh: 77 members. Edit the text above this block, not the block.

Values: BOTH = 3, NAME = 1, TYPE = 2, TYPE_BLK = 8, TYPE_CHR = 16, TYPE_DIR = 2, TYPE_FIFO = 32, TYPE_LNK = 4, TYPE_MASK = 127, TYPE_REG = 1, TYPE_SOCK = 64

Directory

class, constructible

  • static values: BOTH = 3, NAME = 1, TYPE = 2, TYPE_BLK = 8, TYPE_CHR = 16, TYPE_DIR = 2, TYPE_FIFO = 32, TYPE_LNK = 4, TYPE_MASK = 127, TYPE_REG = 1, TYPE_SOCK = 64
  • methods: adopt(), close(), next(), open(), return(), throw(), valueOf(), [Symbol.iterator]()
  • properties: BOTH = 3, NAME = 1, TYPE = 2, TYPE_BLK = 8, TYPE_CHR = 16, TYPE_DIR = 2, TYPE_FIFO = 32, TYPE_LNK = 4, TYPE_MASK = 127, TYPE_REG = 1, TYPE_SOCK = 64, [Symbol.toStringTag]

default

class, constructible

  • static values: BOTH = 3, NAME = 1, TYPE = 2, TYPE_BLK = 8, TYPE_CHR = 16, TYPE_DIR = 2, TYPE_FIFO = 32, TYPE_LNK = 4, TYPE_MASK = 127, TYPE_REG = 1, TYPE_SOCK = 64
  • methods: adopt(), close(), next(), open(), return(), throw(), valueOf(), [Symbol.iterator]()
  • properties: BOTH = 3, NAME = 1, TYPE = 2, TYPE_BLK = 8, TYPE_CHR = 16, TYPE_DIR = 2, TYPE_FIFO = 32, TYPE_LNK = 4, TYPE_MASK = 127, TYPE_REG = 1, TYPE_SOCK = 64, [Symbol.toStringTag]