xref: /aosp_15_r20/external/bazel-skylib/docs/directory_utils_doc.md (revision bcb5dc7965af6ee42bf2f21341a2ec00233a8c8a)
1*bcb5dc79SHONG Yifan<!-- Generated with Stardoc: http://skydoc.bazel.build -->
2*bcb5dc79SHONG Yifan
3*bcb5dc79SHONG YifanSkylib module containing utility functions related to directories.
4*bcb5dc79SHONG Yifan
5*bcb5dc79SHONG Yifan<a id="directory_glob"></a>
6*bcb5dc79SHONG Yifan
7*bcb5dc79SHONG Yifan## directory_glob
8*bcb5dc79SHONG Yifan
9*bcb5dc79SHONG Yifan<pre>
10*bcb5dc79SHONG Yifandirectory_glob(<a href="#directory_glob-directory">directory</a>, <a href="#directory_glob-include">include</a>, <a href="#directory_glob-allow_empty">allow_empty</a>)
11*bcb5dc79SHONG Yifan</pre>
12*bcb5dc79SHONG Yifan
13*bcb5dc79SHONG Yifannative.glob, but for DirectoryInfo.
14*bcb5dc79SHONG Yifan
15*bcb5dc79SHONG Yifan**PARAMETERS**
16*bcb5dc79SHONG Yifan
17*bcb5dc79SHONG Yifan
18*bcb5dc79SHONG Yifan| Name  | Description | Default Value |
19*bcb5dc79SHONG Yifan| :------------- | :------------- | :------------- |
20*bcb5dc79SHONG Yifan| <a id="directory_glob-directory"></a>directory |  (DirectoryInfo) The directory to look relative from.   |  none |
21*bcb5dc79SHONG Yifan| <a id="directory_glob-include"></a>include |  (List[string]) A list of globs to match.   |  none |
22*bcb5dc79SHONG Yifan| <a id="directory_glob-allow_empty"></a>allow_empty |  (bool) Whether to allow a glob to not match any files.   |  `False` |
23*bcb5dc79SHONG Yifan
24*bcb5dc79SHONG Yifan**RETURNS**
25*bcb5dc79SHONG Yifan
26*bcb5dc79SHONG Yifandepset[File] A set of files that match.
27*bcb5dc79SHONG Yifan
28*bcb5dc79SHONG Yifan
29*bcb5dc79SHONG Yifan<a id="directory_glob_chunk"></a>
30*bcb5dc79SHONG Yifan
31*bcb5dc79SHONG Yifan## directory_glob_chunk
32*bcb5dc79SHONG Yifan
33*bcb5dc79SHONG Yifan<pre>
34*bcb5dc79SHONG Yifandirectory_glob_chunk(<a href="#directory_glob_chunk-directory">directory</a>, <a href="#directory_glob_chunk-chunk">chunk</a>)
35*bcb5dc79SHONG Yifan</pre>
36*bcb5dc79SHONG Yifan
37*bcb5dc79SHONG YifanGiven a directory and a chunk of a glob, returns possible candidates.
38*bcb5dc79SHONG Yifan
39*bcb5dc79SHONG Yifan**PARAMETERS**
40*bcb5dc79SHONG Yifan
41*bcb5dc79SHONG Yifan
42*bcb5dc79SHONG Yifan| Name  | Description | Default Value |
43*bcb5dc79SHONG Yifan| :------------- | :------------- | :------------- |
44*bcb5dc79SHONG Yifan| <a id="directory_glob_chunk-directory"></a>directory |  (DirectoryInfo) The directory to look relative from.   |  none |
45*bcb5dc79SHONG Yifan| <a id="directory_glob_chunk-chunk"></a>chunk |  (string) A chunk of a glob to look at.   |  none |
46*bcb5dc79SHONG Yifan
47*bcb5dc79SHONG Yifan**RETURNS**
48*bcb5dc79SHONG Yifan
49*bcb5dc79SHONG YifanList[Either[DirectoryInfo, File]]] The candidate next entries for the chunk.
50*bcb5dc79SHONG Yifan
51*bcb5dc79SHONG Yifan
52*bcb5dc79SHONG Yifan<a id="directory_single_glob"></a>
53*bcb5dc79SHONG Yifan
54*bcb5dc79SHONG Yifan## directory_single_glob
55*bcb5dc79SHONG Yifan
56*bcb5dc79SHONG Yifan<pre>
57*bcb5dc79SHONG Yifandirectory_single_glob(<a href="#directory_single_glob-directory">directory</a>, <a href="#directory_single_glob-glob">glob</a>)
58*bcb5dc79SHONG Yifan</pre>
59*bcb5dc79SHONG Yifan
60*bcb5dc79SHONG YifanCalculates all files that are matched by a glob on a directory.
61*bcb5dc79SHONG Yifan
62*bcb5dc79SHONG Yifan**PARAMETERS**
63*bcb5dc79SHONG Yifan
64*bcb5dc79SHONG Yifan
65*bcb5dc79SHONG Yifan| Name  | Description | Default Value |
66*bcb5dc79SHONG Yifan| :------------- | :------------- | :------------- |
67*bcb5dc79SHONG Yifan| <a id="directory_single_glob-directory"></a>directory |  (DirectoryInfo) The directory to look relative from.   |  none |
68*bcb5dc79SHONG Yifan| <a id="directory_single_glob-glob"></a>glob |  (string) A glob to match.   |  none |
69*bcb5dc79SHONG Yifan
70*bcb5dc79SHONG Yifan**RETURNS**
71*bcb5dc79SHONG Yifan
72*bcb5dc79SHONG YifanList[File] A list of files that match.
73*bcb5dc79SHONG Yifan
74*bcb5dc79SHONG Yifan
75*bcb5dc79SHONG Yifan<a id="get_child"></a>
76*bcb5dc79SHONG Yifan
77*bcb5dc79SHONG Yifan## get_child
78*bcb5dc79SHONG Yifan
79*bcb5dc79SHONG Yifan<pre>
80*bcb5dc79SHONG Yifanget_child(<a href="#get_child-directory">directory</a>, <a href="#get_child-name">name</a>, <a href="#get_child-require_dir">require_dir</a>, <a href="#get_child-require_file">require_file</a>)
81*bcb5dc79SHONG Yifan</pre>
82*bcb5dc79SHONG Yifan
83*bcb5dc79SHONG YifanGets the direct child of a directory.
84*bcb5dc79SHONG Yifan
85*bcb5dc79SHONG Yifan**PARAMETERS**
86*bcb5dc79SHONG Yifan
87*bcb5dc79SHONG Yifan
88*bcb5dc79SHONG Yifan| Name  | Description | Default Value |
89*bcb5dc79SHONG Yifan| :------------- | :------------- | :------------- |
90*bcb5dc79SHONG Yifan| <a id="get_child-directory"></a>directory |  (DirectoryInfo) The directory to look within.   |  none |
91*bcb5dc79SHONG Yifan| <a id="get_child-name"></a>name |  (string) The name of the directory/file to look for.   |  none |
92*bcb5dc79SHONG Yifan| <a id="get_child-require_dir"></a>require_dir |  (bool) If true, throws an error if the value is not a directory.   |  `False` |
93*bcb5dc79SHONG Yifan| <a id="get_child-require_file"></a>require_file |  (bool) If true, throws an error if the value is not a file.   |  `False` |
94*bcb5dc79SHONG Yifan
95*bcb5dc79SHONG Yifan**RETURNS**
96*bcb5dc79SHONG Yifan
97*bcb5dc79SHONG Yifan(File|DirectoryInfo) The content contained within.
98*bcb5dc79SHONG Yifan
99*bcb5dc79SHONG Yifan
100*bcb5dc79SHONG Yifan<a id="get_relative"></a>
101*bcb5dc79SHONG Yifan
102*bcb5dc79SHONG Yifan## get_relative
103*bcb5dc79SHONG Yifan
104*bcb5dc79SHONG Yifan<pre>
105*bcb5dc79SHONG Yifanget_relative(<a href="#get_relative-directory">directory</a>, <a href="#get_relative-path">path</a>, <a href="#get_relative-require_dir">require_dir</a>, <a href="#get_relative-require_file">require_file</a>)
106*bcb5dc79SHONG Yifan</pre>
107*bcb5dc79SHONG Yifan
108*bcb5dc79SHONG YifanGets a subdirectory contained within a tree of another directory.
109*bcb5dc79SHONG Yifan
110*bcb5dc79SHONG Yifan**PARAMETERS**
111*bcb5dc79SHONG Yifan
112*bcb5dc79SHONG Yifan
113*bcb5dc79SHONG Yifan| Name  | Description | Default Value |
114*bcb5dc79SHONG Yifan| :------------- | :------------- | :------------- |
115*bcb5dc79SHONG Yifan| <a id="get_relative-directory"></a>directory |  (DirectoryInfo) The directory to look within.   |  none |
116*bcb5dc79SHONG Yifan| <a id="get_relative-path"></a>path |  (string) The path of the directory to look for within it.   |  none |
117*bcb5dc79SHONG Yifan| <a id="get_relative-require_dir"></a>require_dir |  (bool) If true, throws an error if the value is not a directory.   |  `False` |
118*bcb5dc79SHONG Yifan| <a id="get_relative-require_file"></a>require_file |  (bool) If true, throws an error if the value is not a file.   |  `False` |
119*bcb5dc79SHONG Yifan
120*bcb5dc79SHONG Yifan**RETURNS**
121*bcb5dc79SHONG Yifan
122*bcb5dc79SHONG Yifan(File|DirectoryInfo) The directory contained within.
123*bcb5dc79SHONG Yifan
124*bcb5dc79SHONG Yifan
125*bcb5dc79SHONG Yifan<a id="transitive_entries"></a>
126*bcb5dc79SHONG Yifan
127*bcb5dc79SHONG Yifan## transitive_entries
128*bcb5dc79SHONG Yifan
129*bcb5dc79SHONG Yifan<pre>
130*bcb5dc79SHONG Yifantransitive_entries(<a href="#transitive_entries-directory">directory</a>)
131*bcb5dc79SHONG Yifan</pre>
132*bcb5dc79SHONG Yifan
133*bcb5dc79SHONG YifanReturns the files and directories contained within a directory transitively.
134*bcb5dc79SHONG Yifan
135*bcb5dc79SHONG Yifan**PARAMETERS**
136*bcb5dc79SHONG Yifan
137*bcb5dc79SHONG Yifan
138*bcb5dc79SHONG Yifan| Name  | Description | Default Value |
139*bcb5dc79SHONG Yifan| :------------- | :------------- | :------------- |
140*bcb5dc79SHONG Yifan| <a id="transitive_entries-directory"></a>directory |  (DirectoryInfo) The directory to look at   |  none |
141*bcb5dc79SHONG Yifan
142*bcb5dc79SHONG Yifan**RETURNS**
143*bcb5dc79SHONG Yifan
144*bcb5dc79SHONG YifanList[Either[DirectoryInfo, File]] The entries contained within.
145*bcb5dc79SHONG Yifan
146*bcb5dc79SHONG Yifan
147