package listing

import "time"

// FileInfo matches Caddy's browse JSON output exactly (with one ZDDC-
// specific extension: Virtual). The archive browser (source.js) expects
// this exact shape.
type FileInfo struct {
	Name      string    `json:"name"` // filename; directories have a trailing "/"
	Size      int64     `json:"size"`
	URL       string    `json:"url"` // relative URL to the item
	ModTime   time.Time `json:"mod_time"`
	Mode      uint32    `json:"mode"`
	IsDir     bool      `json:"is_dir"`
	IsSymlink bool      `json:"is_symlink"` // always false — no real symlinks served

	// Virtual marks an entry that doesn't exist on disk yet but is
	// surfaced in listings as a synthetic affordance — e.g. the per-user
	// <viewer-email>/ entry under working/. A first write to a virtual
	// path materialises a real folder (with auto-own .zddc); subsequent
	// listings drop the synthetic entry. Clients can use this flag to
	// render the entry differently (placeholder badge, drop-target hint).
	Virtual bool `json:"virtual,omitempty"`

	// DisplayName is the human-friendly label rendered by clients in
	// place of Name when set. Sourced from the directory's .zddc
	// `display:` map (matched case-insensitively on the on-disk
	// basename). Empty = render Name. Never empty for an explicit
	// override — clients shouldn't infer a default from absence here.
	DisplayName string `json:"display_name,omitempty"`
}
