Documentation
¶
Overview ¶
Package dir handles the directories in use by the internal server. Such as the download, extra, and preview directories.
Index ¶
- Constants
- Variables
- func CleanTemp(stale time.Duration) error
- func CreateTemp(pattern string) (*os.File, error)
- func IsTemp(d os.DirEntry) bool
- func MkdirStale(path string) (string, error)
- func MkdirTemp(pattern string) (string, error)
- func Paths(d ...Directory) []string
- func RemoveAll(name string) error
- type Directory
Constants ¶
const Pattern = "df2app"
Variables ¶
Functions ¶
func CleanTemp ¶ added in v1.14.0
CleanTemp removes the temporary directories likely created using MkdirTemp, that are older than the stale time value. An error is returned if a directory cannot be removed.
func CreateTemp ¶ added in v1.14.0
CreateTemp creates a new temporary file using os.CreateTemp. However, no path is required and the new file will be located in a subdirectory created using MkdirTemp.
func IsTemp ¶ added in v1.14.0
IsTemp returns true when the dir entry is likely a temporary directory or file created using MkdirTemp.
func MkdirStale ¶ added in v1.14.0
MkdirStale creates a temporary subdirectory in os.TempDir using the provided path as the basis of the directory name. Unlike MkdirTemp, this func does not apply randomization to the directory name and the result will not always be unique. Allowing the directory to be used as a short-term file cache.
The returned string is the path to an existing or the newly created temporary directory.
func MkdirTemp ¶ added in v1.14.0
MkdirTemp creates a temporary directory at os.TempDir using the provided pattern. The optional pattern should not include a randomizer string "-*".
Example usage on Linux:
path, _ := MkdirTemp("abc")
fmt.Println(path)
Output:
/tmp/df2app-abc-d83gsddb34
func Paths ¶
Paths converts the slice of Directory types to a slice of strings representing the directory paths.
func RemoveAll ¶ added in v1.14.0
RemoveAll removes the named directory. For safety, the directory removal is locked using os.OpenRoot to os.TempDir.
Types ¶
type Directory ¶
type Directory string
Directory is a string type that represents an internal server directory path.