Documentation
¶
Overview ¶
Package dirent decides whether an entry a reader lists is a folder to go into, links included.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Each ¶
Each gives f each entry of dir as Stats has it, in the order the system lists them, with nothing made for an entry: name is valid only during the call, and f copies what it keeps of it. f returning false stops the listing. ok is false where Stats' is: the system has no such listing, or the folder or an entry couldn't be read (some entries may have been given f by then).
func Forget ¶
func Forget()
Forget lets go of every listing kept for the next Stats, and the room kept for them: once the session folders go unread, the listings and their names were held for the life of the process (~4 MB for a real history). A listing given back later is kept again.
func IsFolder ¶
IsFolder is whether e, an entry listed in dir, is a folder to read into: a folder of its own, or a link that leads to one. os.ReadDir reports a symlink as ModeSymlink and, on Windows, a junction as ModeIrregular (Go 1.23 and later), and neither as IsDir, so a reader that goes into only IsDir() entries, or IsDir() and ModeSymlink ones, walks past a folder kept on another drive with a junction left where it was (#2268). Such an entry is followed with os.Stat. A link to a file, a broken link and anything else irregular are no folder.
It follows only the entry it is asked about. A reader that recurses on it must keep its own record of the folders it has been in.
func Watch ¶
func Watch(dir string)
Watch has dir and everything under it watched for changes, where the system can, and waits until every change made before the call is heard: a reader calls it before each read of dir's folders, and Stats of a folder in it then skips listing one that hasn't changed. A Stats with no Watch of its root in the last trustFor reads its folder.
func WatchSince ¶
WatchSince is Watch, waiting only until every change made before mark is heard: a probe begun after mark, its own or another's, vouches for them. A Sessions poll watches each Claude Code and Codex folder in turn, and each Watch wrote, waited on and removed a probe of its own, ~1/6 of the poll's CPU (#2278); the poll marks once, and its first probe does for every folder after.
Types ¶
type Listing ¶ added in v0.1.1664
type Listing []Entry
Listing is a folder's entries in name order. It is a slice, not a map: every 15 s Sessions poll lists every Codex day folder and Claude Code project again, and a map of each folder's entries was ~90 MB of the 2.3 GB eight polls allocated.
func Stats ¶ added in v0.1.1651
Stats is each entry of dir in name order, as os.Lstat gives it, read in a few calls for the whole folder where the system has them (getattrlistbulk on macOS), rather than one per entry. ok is false where the system has none or the folder couldn't be read, and the caller asks after each entry itself.
A caller done reading the listing gives it back (Done) for the next.
type Stat ¶ added in v0.1.1651
Stat is what a folder's listing says of one entry: its kind (Mode's type bits, 0 for a regular file), and a regular file's size and modification time, as os.Lstat gives them. Mod is unix nanoseconds, not a time.Time: what is kept of a history's listings is ~130k entries, and its 24 bytes made an entry 56 bytes where it is now 40 (#2278).