IfExists tests whether path exists, and creates a pipe whose error status reflects the result. If the file doesn't exist, the pipe's error status will be set, and if the file does exist, the pipe will have no error status. This can be used to do some operation only if a given file exists: IfExists
(path string)
| 124 | // |
| 125 | // IfExists("/foo/bar").Exec("/usr/bin/something") |
| 126 | func IfExists(path string) *Pipe { |
| 127 | _, err := os.Stat(path) |
| 128 | if err != nil { |
| 129 | return NewPipe().WithError(err) |
| 130 | } |
| 131 | return NewPipe() |
| 132 | } |
| 133 | |
| 134 | // ListFiles creates a pipe containing the files or directories specified by |
| 135 | // path, one per line. path can be a glob expression, as for [filepath.Match]. |
searching dependent graphs…