std/dir
import std/dir to use it. Source: src/std/dir.iyi at v0.18.0.
Provides opening, reading entries, creating, deleting, traversing, changing current working directory, and globbing without external C libraries.
Dirclass
pub class Dir
def self.[](patterns : String | Array(String)) : Array(String)
protected def self.c_str(str : String) : ::Pointer(UInt8)
def self.cd(path : String | Path) : String
def self.cd(path : String | Path, &block : (-> Nil)) : Nil
def children : Array(String)
def self.children(dirname : String | Path) : Array(String)
def close : Nil
def closed? : Bool
# One implementation, in the prelude: `Path#expand` needs the same
# answer and cannot import this module (`std/dir` imports `std/path`),
# so the platform arms live beside `Program.args` and `Program.env`,
# which are the process's other facts.
def self.current : String
def self.current=(path : String | Path) : String
def self.delete(path : String | Path) : Nil
def self.delete?(path : String | Path) : Bool
def each(&block : (String -> Nil)) : Nil
def self.each(dirname : String | Path, &block : (String -> Nil)) : Nil
def each_child(&block : (String -> Nil)) : Nil
def self.each_child(dirname : String | Path, &block : (String -> Nil)) : Nil
def self.empty?(path : String | Path) : Bool
def entries : Array(String)
def self.entries(dirname : String | Path) : Array(String)
def self.exists?(path : String | Path) : Bool
# The search pattern FindFirstFileW is opened with: the directory, wide,
# with a separator and a `*` behind it. The directory is converted on its
# own and the wildcard appended to the result, not converted with it,
# because a long path's conversion runs through `GetFullPathNameW` and
# that is a path normaliser rather than a pattern one — the `\\?\` prefix
# it produces is what a long directory needs here, and a `*` is no
# business of its. A null pointer is the conversion having failed, which
# the callers read as the directory not opening.
protected def self.find_pattern(dir_path : String) : ::Pointer(UInt16)
def self.glob(patterns : String | Array(String)) : Array(String)
def self.glob(patterns : String | Array(String), &block : (String -> Nil)) : Nil
def initialize(path : String | Path)
def inspect : String
def self.mkdir(path : String | Path, mode : Int32 = 511) : Nil
def self.mkdir_p(path : String | Path, mode : Int32 = 511) : Nil
def self.open(path : String | Path) : Dir
def self.open(path : String | Path, &block : (Dir -> Nil)) : Nil
def path : String
def read : String | ::Nil
def rewind : self
def self.rmdir(path : String | Path) : Nil
def self.tempdir : String
def to_s : String
# One trailing separator off, as Crystal's `Dir.tempdir` answers: darwin
# sets TMPDIR to `/var/folders/.../T/`, and every path joined onto it had
# two separators and a `dirname` that was not the directory it came from.
# The root alone is left as it is - and on Windows a drive's root is
# `C:\`, whose separator is the root: without it `C:` is the current
# directory on that drive, and a TMP of `C:\` answered the directory
# the program happened to be in.
def self.without_trailing_separator(dir : String) : String
end
Dir: directory stream and filesystem directory operations.