lstat is a simplified abstraction around [os.Lstat] that reports whether the path is a directory or a symlink, using Lstat so that a symlink at the path is not followed.
(path string)
| 238 | // path is a directory or a symlink, using Lstat so that a symlink at the path |
| 239 | // is not followed. |
| 240 | func lstat(path string) (*lstatResult, error) { |
| 241 | info, err := os.Lstat(path) |
| 242 | if err != nil { |
| 243 | return nil, err |
| 244 | } |
| 245 | return &lstatResult{ |
| 246 | isDir: info.IsDir(), |
| 247 | isSymlink: info.Mode()&os.ModeSymlink != 0, |
| 248 | }, nil |
| 249 | } |
| 250 | |
| 251 | // These indirect the file system operations used when writing output, so tests can |
| 252 | // substitute them without touching the real file system. |