2
0
Fork 0
mirror of https://github.com/bazelbuild/bazel-skylib synced 2024-11-27 05:43:25 +00:00
bazel-skylib/docs/directory_utils_doc.md

4.6 KiB
Executable file

Skylib module containing utility functions related to directories.

directory_glob

directory_glob(directory, include, allow_empty)

native.glob, but for DirectoryInfo.

PARAMETERS

Name Description Default Value
directory (DirectoryInfo) The directory to look relative from. none
include (List[string]) A list of globs to match. none
allow_empty (bool) Whether to allow a glob to not match any files. False

RETURNS

depset[File] A set of files that match.

directory_glob_chunk

directory_glob_chunk(directory, chunk)

Given a directory and a chunk of a glob, returns possible candidates.

PARAMETERS

Name Description Default Value
directory (DirectoryInfo) The directory to look relative from. none
chunk (string) A chunk of a glob to look at. none

RETURNS

List[Either[DirectoryInfo, File]]] The candidate next entries for the chunk.

directory_single_glob

directory_single_glob(directory, glob)

Calculates all files that are matched by a glob on a directory.

PARAMETERS

Name Description Default Value
directory (DirectoryInfo) The directory to look relative from. none
glob (string) A glob to match. none

RETURNS

List[File] A list of files that match.

get_child

get_child(directory, name, require_dir, require_file)

Gets the direct child of a directory.

PARAMETERS

Name Description Default Value
directory (DirectoryInfo) The directory to look within. none
name (string) The name of the directory/file to look for. none
require_dir (bool) If true, throws an error if the value is not a directory. False
require_file (bool) If true, throws an error if the value is not a file. False

RETURNS

(File|DirectoryInfo) The content contained within.

get_relative

get_relative(directory, path, require_dir, require_file)

Gets a subdirectory contained within a tree of another directory.

PARAMETERS

Name Description Default Value
directory (DirectoryInfo) The directory to look within. none
path (string) The path of the directory to look for within it. none
require_dir (bool) If true, throws an error if the value is not a directory. False
require_file (bool) If true, throws an error if the value is not a file. False

RETURNS

(File|DirectoryInfo) The directory contained within.

transitive_entries

transitive_entries(directory)

Returns the files and directories contained within a directory transitively.

PARAMETERS

Name Description Default Value
directory (DirectoryInfo) The directory to look at none

RETURNS

List[Either[DirectoryInfo, File]] The entries contained within.