disk

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 3, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package disk provides disk size utilities and filesystem helpers. Uses stdlib only: filepath.WalkDir, os.Stat, os.UserHomeDir. No third-party libraries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClaudeProjectsDir

func ClaudeProjectsDir() (string, error)

ClaudeProjectsDir returns the path to ~/.claude/projects/. Returns an error if os.UserHomeDir() fails.

func ClaudeProjectsDirForPath

func ClaudeProjectsDirForPath(tomoPath string) (string, error)

ClaudeProjectsDirForPath returns the ~/.claude/projects/<key>/ directory for a tomo path. The key is derived by lowercasing the path and replacing path separators and colons with "-". Returns ("", nil) when the derived directory does not exist (best-effort heuristic).

func EngramDBSize

func EngramDBSize() (int64, error)

EngramDBSize returns the total byte size of the engram database files: ~/.engram/engram.db + engram.db-wal + engram.db-shm. Missing files are silently treated as 0 bytes (partial WAL is normal). Returns (0, nil) if the ~/.engram/ directory does not exist.

func HumanReadable

func HumanReadable(bytes int64) string

HumanReadable formats bytes as a human-readable string. Below 1 KB: "N B" (integer, no decimals). 1 KB and above: "N.NN KB" / "N.NN MB" / "N.NN GB" (2 decimal places). Design R5.5: B / KB / MB / GB units only.

func OpenInExplorer

func OpenInExplorer(path string) error

OpenInExplorer opens Windows Explorer at the given path in a detached process. Uses cmd.exe /c start "" <path> — same pattern as internal/actions/windows.go. Non-blocking: calls Start() not Run().

func SetDiskExecCommand

func SetDiskExecCommand(fn func(name string, arg ...string) *exec.Cmd)

SetDiskExecCommand replaces the exec.Command seam used by OpenInExplorer. Call defer SetDiskExecCommand(exec.Command) in tests to restore.

func WalkSize

func WalkSize(path string) (int64, error)

WalkSize returns the total byte size of all regular files under path. Unreadable entries are skipped silently (no error returned for per-entry failures). Returns an error only if the root path cannot be walked at all.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL