files

package
v1.4.4 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package files hosts the interfaces that pina-golada uses to represent a virtual file system to de-couple the application from the host file system after an initial read.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadFromDisk

func LoadFromDisk(directory Directory, path string) (e error)

LoadFromDisk loads the content of the paths into the directory recursively

func WalkDirectoryTree added in v1.2.6

func WalkDirectoryTree(directory Directory, consumer func(d Directory))

WalkDirectoryTree walks over each sub directory found in the directory, excluding the passed directory

func WalkFileTree

func WalkFileTree(directory Directory, consumer func(file File))

WalkFileTree iterates over each and every file instance found in the directory

func WriteToDisk added in v1.1.0

func WriteToDisk(directory Directory, path string, overwrite bool) (e error)

WriteToDisk writes a directory to the given path Overwriting or skipping an existing file based on the bool

Types

type Directory

type Directory interface {
	Name() (name paths.Path)
	AbsolutePath() (path paths.Path)

	WithPermission(permission os.FileMode) Directory
	PermissionSet() os.FileMode

	Files() (files []File)
	File(path paths.Path) (file File)
	NewFile(path paths.Path) (newFile File)
	DeleteFile(path paths.Path)

	Directories() (directories []Directory)
	Directory(path paths.Path) (directory Directory)
	NewDirectory(path paths.Path) (newDirectory Directory)
	DeleteDirectory(path paths.Path)

	Parent() (parentDirectory Directory)
	AsRoot() (rootDirectory Directory)
}

Directory represents a virtual directory containing files.

Name return the name of the directory excluding the paths it is in

Files returns the list of all files in the given directory

File returns the file for the given name or nil

NewFile creates a new File in the directory and returns the new instance

Delete deletes the file stored under the given name

Directories returns the directories stored under this directory

Directory returns the directory with the given name or nil

NewDirectory creates a new directory

DeleteDirectory deletes a directory

Parent returns the directory this directory is found in

AsRoot creates a deep copy of the current directory, but with the current directory as it's root

func NewRootDirectory

func NewRootDirectory() Directory

NewRootDirectory returns a new root directory

type File

type File interface {
	Name() (name paths.Path)
	AbsolutePath() (path paths.Path)

	WithPermission(set os.FileMode) File
	PermissionSet() os.FileMode

	CopyContent(writer io.Writer) (e error)
	Write(reader io.Reader) (e error)
	WriteFlagged(reader io.Reader, append bool) (e error)
	Delete()

	Parent() (parentDirectory Directory)
}

File represents a digital file object

Name returns the name of the file, excluding the paths it is stored in

CopyContent stores the files binary content in the writer

Write writes content to the file. The default will not append to the file

Delete deletes the file

Directories

Path Synopsis
Package paths hosts the interface used by pina-golada to parse and concat relative and absolute file paths.
Package paths hosts the interface used by pina-golada to parse and concat relative and absolute file paths.

Jump to

Keyboard shortcuts

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