stat
The operating system call, and matching command, that reports a file's details such as size, mode and modification time without opening it.
In more detail
It answers questions such as does this path exist and how big is it. A missing file and an unreadable file produce different errors, which careful tools handle differently.
Examples
info, err := os.Stat("probe.conf")Go: info, err := os.Stat(path); errors.Is(err, os.ErrNotExist)Related terms
- os.FileInfo — The Go interface describing a file, returned by os.Stat and f.Stat, with methods such as Name, Size and Mode.
- os.ErrNotExist — The sentinel error Go file functions return, wrapped, when a file or folder does not exist.
- file permissions — Rules on each file saying which user and group own it and who may read, write or run it.
- system call — A request a program makes to the kernel, such as open this file or start a new process.
- Dirent — The object Node.js uses for one directory entry, with its name and methods such as isFile() and isDirectory().
Taught in
- Files and the os Package — Concurrent Systems Programming with Go
- Directory Traversal: Recursive Readdir & fs.watch — Node.js Internals & Backend Services