cacheitem

package
v0.0.0-...-afecb3f Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2024 License: MPL-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package cacheitem is an abstraction over the creation and restoration of a cache

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clean

func Clean(path string) string

Clean is extracted from stdlib and removes `FromSlash` processing of the stdlib version.

Clean returns the shortest path name equivalent to path by purely lexical processing. It applies the following rules iteratively until no further processing can be done:

  1. Replace multiple Separator elements with a single one.
  2. Eliminate each . path name element (the current directory).
  3. Eliminate each inner .. path name element (the parent directory) along with the non-.. element that precedes it.
  4. Eliminate .. elements that begin a rooted path: that is, replace "/.." by "/" at the beginning of a path, assuming Separator is '/'.

The returned path ends in a slash only if it represents a root directory, such as "/" on Unix or `C:\` on Windows.

Finally, any occurrences of slash are replaced by Separator.

If the result of this process is an empty string, Clean returns the string ".".

See also Rob Pike, “Lexical File Names in Plan 9 or Getting Dot-Dot Right,” https://9p.io/sys/doc/lexnames.html

Types

type CacheItem

type CacheItem struct {
	// Path is the location on disk for the CacheItem.
	Path titanpath.AbsoluteSystemPath
	// Anchor is the position on disk at which the CacheItem will be restored.
	Anchor titanpath.AbsoluteSystemPath
	// contains filtered or unexported fields
}

CacheItem is a `tar` utility with a little bit extra.

func Create

Create makes a new CacheItem at the specified path.

func Open

Open returns an existing CacheItem at the specified path.

func (*CacheItem) AddFile

func (ci *CacheItem) AddFile(fsAnchor titanpath.AbsoluteSystemPath, filePath titanpath.AnchoredSystemPath) error

AddFile adds a user-cached item to the tar.

func (*CacheItem) Close

func (ci *CacheItem) Close() error

Close any open pipes

func (*CacheItem) GetSha

func (ci *CacheItem) GetSha() ([]byte, error)

GetSha returns the SHA-512 hash for the CacheItem.

func (*CacheItem) Restore

Restore extracts a cache to a specified disk location.

Jump to

Keyboard shortcuts

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