Documentation
¶
Overview ¶
Package local implements the disk.Disk interface against the host filesystem. It is the default and only backend shipped in v1 (ADR-0008).
A local disk is anchored at a Root directory. All disk paths resolve relative to Root; the disk cannot see or touch anything outside it. Path traversal (".", "..") is rejected by hex/disk before it reaches this driver.
URLs: if Options.URLPrefix is set, URL() returns URLPrefix + "/" + path. If not set, URL returns disk.ErrNotSupported.
Visibility: files are created with FileMode; SetVisibility toggles between FileMode (private) and PublicFileMode (public).
Index ¶
- type Local
- func (l *Local) Copy(ctx context.Context, src, dst string) error
- func (l *Local) Delete(_ context.Context, p string) error
- func (l *Local) DeleteDirectory(_ context.Context, p string) error
- func (l *Local) Exists(_ context.Context, p string) (bool, error)
- func (l *Local) Get(_ context.Context, p string) ([]byte, error)
- func (l *Local) LastModified(_ context.Context, p string) (time.Time, error)
- func (l *Local) List(_ context.Context, prefix string) ([]string, error)
- func (l *Local) MakeDirectory(_ context.Context, p string) error
- func (l *Local) Move(_ context.Context, src, dst string) error
- func (l *Local) Put(_ context.Context, p string, content []byte) error
- func (l *Local) Reader(_ context.Context, p string) (io.ReadCloser, error)
- func (l *Local) Root() string
- func (l *Local) SetVisibility(_ context.Context, p string, v disk.Visibility) error
- func (l *Local) Size(_ context.Context, p string) (int64, error)
- func (l *Local) URL(_ context.Context, p string) (string, error)
- func (l *Local) Visibility(_ context.Context, p string) (disk.Visibility, error)
- func (l *Local) Writer(_ context.Context, p string) (io.WriteCloser, error)
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Local ¶
type Local struct {
// contains filtered or unexported fields
}
Local is a filesystem-backed disk.Disk.
func New ¶
New returns a Local disk rooted at opts.Root. The root directory is created if it does not exist. Returns an error if Root is empty or creation fails.
func (*Local) DeleteDirectory ¶
DeleteDirectory removes a directory tree.
func (*Local) LastModified ¶
LastModified returns the modification time.
func (*Local) MakeDirectory ¶
MakeDirectory creates a directory and any missing parents.
func (*Local) SetVisibility ¶
SetVisibility toggles between FileMode (private) and PublicFileMode (public).
func (*Local) Visibility ¶
Visibility reads the file mode and reports public/private based on the world-readable bit.
type Options ¶
type Options struct {
// Root is the absolute directory this disk is anchored to. Required.
Root string
// URLPrefix is prepended to paths when URL() is called. Optional.
URLPrefix string
// FileMode is the mode used for created files. Defaults to 0o644.
FileMode os.FileMode
// DirMode is the mode used for created directories. Defaults to 0o755.
DirMode os.FileMode
// PublicFileMode is used by SetVisibility(VisibilityPublic). Defaults
// to 0o644. Set higher (e.g. 0o664) if your consumers need a wider
// public bit.
PublicFileMode os.FileMode
}
Options configures a Local disk.