Documentation ¶
Index ¶
- Constants
- Variables
- func ModePermsToUnixPerms(fileMode os.FileMode) uint32
- func UnixPermsOrDefault(n Node) uint32
- func UnixPermsToModePerms(unixPerms uint32) os.FileMode
- func UpdateFileMode(path string, mode os.FileMode) error
- func UpdateFileModeUnix(path string, mode uint32) error
- func UpdateMeta(path string, mode os.FileMode, mtime time.Time) error
- func UpdateMetaUnix(path string, mode uint32, mtime time.Time) error
- func UpdateModTime(path string, mtime time.Time) error
- func Walk(nd Node, cb func(fpath string, nd Node) error) error
- func WriteTo(nd Node, fpath string) error
- type DirEntry
- type DirIterator
- type Directory
- func DirFromEntry(e DirEntry) Directory
- func NewFileFromPartReader(reader *multipart.Reader, mediatype string) (Directory, error)
- func NewMapDirectory(f map[string]Node) Directory
- func NewMapStatDirectory(f map[string]Node, stat os.FileInfo) Directory
- func NewSliceDirectory(files []DirEntry) Directory
- func NewSliceStatDirectory(files []DirEntry, stat os.FileInfo) Directory
- func ToDir(n Node) Directory
- type File
- func FileFromEntry(e DirEntry) File
- func NewBytesFile(b []byte) File
- func NewBytesStatFile(b []byte, stat os.FileInfo) File
- func NewLinkFile(target string, stat os.FileInfo) File
- func NewReaderFile(reader io.Reader) File
- func NewReaderStatFile(reader io.Reader, stat os.FileInfo) File
- func NewSymlinkFile(target string, mtime time.Time) File
- func ToFile(n Node) File
- type FileInfo
- type Filter
- type MultiFileReader
- type Node
- type ReaderFile
- func (f *ReaderFile) AbsPath() string
- func (f *ReaderFile) Close() error
- func (f *ReaderFile) ModTime() time.Time
- func (f *ReaderFile) Mode() os.FileMode
- func (f *ReaderFile) Read(p []byte) (int, error)
- func (f *ReaderFile) Seek(offset int64, whence int) (int64, error)
- func (f *ReaderFile) Size() (int64, error)
- func (f *ReaderFile) Stat() os.FileInfo
- type SliceFile
- type Symlink
- type TarWriter
- type WebFile
- func (wf *WebFile) AbsPath() string
- func (wf *WebFile) Close() error
- func (wf *WebFile) ModTime() time.Time
- func (wf *WebFile) Mode() os.FileMode
- func (wf *WebFile) Read(b []byte) (int, error)
- func (wf *WebFile) Seek(offset int64, whence int) (int64, error)
- func (wf *WebFile) Size() (int64, error)
- func (wf *WebFile) Stat() os.FileInfo
Constants ¶
const FileModeHeaderName = "File-Mode"
the HTTP Response header that provides the unix file mode
const LastModifiedHeaderName = "Last-Modified"
the HTTP Response header that provides the last modified timestamp
Variables ¶
var ( ErrNotDirectory = errors.New("file isn't a directory") ErrNotReader = errors.New("file isn't a regular file") ErrNotSupported = errors.New("operation not supported") )
var ( ErrInvalidDirectoryEntry = errors.New("invalid directory entry name") ErrPathExistsOverwrite = errors.New("path already exists and overwriting is not allowed") )
var ErrUnixFSPathOutsideRoot = errors.New("relative UnixFS paths outside the root are not allowed, use CAR instead")
Functions ¶
func ModePermsToUnixPerms ¶ added in v0.24.3
ModePermsToUnixPerms converts the permission bits of an os.FileMode to unix style mode permissions.
func UnixPermsOrDefault ¶ added in v0.24.3
UnixPermsOrDefault returns the unix style permissions stored for the given Node, or default unix permissions for the Node type.
func UnixPermsToModePerms ¶ added in v0.24.3
UnixPermsToModePerms converts unix style mode permissions to os.FileMode permissions, as it only operates on permission bits it does not set the underlying type (fs.ModeDir, fs.ModeSymlink, etc.) in the returned os.FileMode.
func UpdateFileMode ¶ added in v0.24.3
UpdateFileMode sets the unix mode of the filesystem object referenced by path.
func UpdateFileModeUnix ¶ added in v0.24.3
UpdateFileModeUnix sets the unix mode of the filesystem object referenced by path. It takes the mode in the form of a unix mode.
func UpdateMeta ¶ added in v0.24.3
UpdateMeta sets the unix mode and modification time of the filesystem object referenced by path.
func UpdateMetaUnix ¶ added in v0.24.3
UpdateUnix sets the unix mode and modification time of the filesystem object referenced by path. The mode is in the form of a unix mode.
func UpdateModTime ¶ added in v0.24.3
UpdateModTime sets the last access and modification time of the target filesystem object to the given time. When the given path references a symlink, if supported, the symlink is updated.
Types ¶
type DirEntry ¶
type DirEntry interface { // Name returns base name of this entry, which is the base name of referenced // file Name() string // Node returns the file referenced by this DirEntry Node() Node }
DirEntry exposes information about a directory entry
type DirIterator ¶
type DirIterator interface { // DirEntry holds information about current directory entry. // Note that after creating new iterator you MUST call Next() at least once // before accessing these methods. Calling these methods without prior calls // to Next() and after Next() returned false may result in undefined behavior DirEntry // Next advances iterator to the next file. Next() bool // Err may return an error after previous call to Next() returned `false`. // If previous call to Next() returned `true`, Err() is guaranteed to // return nil Err() error }
DirIterator is a iterator over directory entries. See Directory.Entries for more
type Directory ¶
type Directory interface { Node // Entries returns a stateful iterator over directory entries. The iterator // may consume the Directory state so it must be called only once (this // applies specifically to the multipartIterator). // // Example usage: // // it := dir.Entries() // for it.Next() { // name := it.Name() // file := it.Node() // [...] // } // if it.Err() != nil { // return err // } // // Note that you can't store the result of it.Node() and use it after // advancing the iterator Entries() DirIterator }
Directory is a special file which can link to any number of files.
func DirFromEntry ¶
DirFromEntry calls ToDir on Node in the given entry
func NewFileFromPartReader ¶
NewFileFromPartReader creates a Directory from a multipart reader.
func NewMapDirectory ¶
func NewMapStatDirectory ¶ added in v0.24.3
func NewSliceDirectory ¶
func NewSliceStatDirectory ¶ added in v0.24.3
type File ¶
Node represents a regular Unix file
func FileFromEntry ¶
FileFromEntry calls ToFile on Node in the given entry
func NewBytesFile ¶
func NewReaderFile ¶
type FileInfo ¶
type FileInfo interface { Node // AbsPath returns full real file path. AbsPath() string // Stat returns os.Stat of this file, may be nil for some files Stat() os.FileInfo }
FileInfo exposes information on files in local filesystem
type Filter ¶
type Filter struct { // IncludeHidden - Include hidden files IncludeHidden bool // Rules - File filter rules Rules *ignore.GitIgnore }
Filter represents a set of rules for determining if a file should be included or excluded. A rule follows the syntax for patterns used in .gitgnore files for specifying untracked files. Examples: foo.txt *.app bar/ **/baz fizz/**
func NewFilter ¶
NewFilter creates a new file filter from a .gitignore file and/or a list of ignore rules. An ignoreFile is a path to a file with .gitignore-style patterns to exclude, one per line rules is an array of strings representing .gitignore-style patterns For reference on ignore rule syntax, see https://git-scm.com/docs/gitignore
type MultiFileReader ¶
MultiFileReader reads from a `commands.Node` (which can be a directory of files or a regular file) as HTTP multipart encoded data.
func NewMultiFileReader ¶
func NewMultiFileReader(file Directory, form, rawAbsPath bool) *MultiFileReader
NewMultiFileReader constructs a MultiFileReader. `file` can be any `commands.Directory`. If `form` is set to true, the Content-Disposition will be "form-data". Otherwise, it will be "attachment". If `rawAbsPath` is set to true, the "abspath" header will be sent. Otherwise, the "abspath-encoded" header will be sent.
func (*MultiFileReader) Boundary ¶
func (mfr *MultiFileReader) Boundary() string
Boundary returns the boundary string to be used to separate files in the multipart data
type Node ¶
type Node interface { io.Closer // Mode returns the mode. // Optional, if unknown/unspecified returns zero. Mode() os.FileMode // ModTime returns the last modification time. If the last // modification time is unknown/unspecified ModTime returns zero. ModTime() (mtime time.Time) // Size returns size of this file (if this file is a directory, total size of // all files stored in the tree should be returned). Some implementations may // choose not to implement this Size() (int64, error) }
Node is a common interface for files, directories and other special files
func NewSerialFile ¶
NewSerialFile takes a filepath, a bool specifying if hidden files should be included, and a fileInfo and returns a Node representing file, directory or special file.
func NewSerialFileWithFilter ¶
NewSerialFileWith takes a filepath, a filter for determining which files should be operated upon if the filepath is a directory, and a fileInfo and returns a Node representing file, directory or special file.
type ReaderFile ¶
type ReaderFile struct {
// contains filtered or unexported fields
}
ReaderFile is a implementation of File created from an `io.Reader`. ReaderFiles are never directories, and can be read from and closed.
func NewReaderPathFile ¶
func NewReaderPathFile(path string, reader io.ReadCloser, stat os.FileInfo) (*ReaderFile, error)
func (*ReaderFile) AbsPath ¶
func (f *ReaderFile) AbsPath() string
func (*ReaderFile) Close ¶
func (f *ReaderFile) Close() error
func (*ReaderFile) ModTime ¶ added in v0.24.3
func (f *ReaderFile) ModTime() time.Time
func (*ReaderFile) Mode ¶ added in v0.24.3
func (f *ReaderFile) Mode() os.FileMode
func (*ReaderFile) Size ¶
func (f *ReaderFile) Size() (int64, error)
func (*ReaderFile) Stat ¶
func (f *ReaderFile) Stat() os.FileInfo
type SliceFile ¶
type SliceFile struct {
// contains filtered or unexported fields
}
SliceFile implements Node, and provides simple directory handling. It contains children files, and is created from a `[]Node`. SliceFiles are always directories, and can't be read from or closed.
func (*SliceFile) Entries ¶
func (f *SliceFile) Entries() DirIterator
type TarWriter ¶
func NewTarWriter ¶
NewTarWriter wraps given io.Writer into a new tar writer
type WebFile ¶
type WebFile struct {
// contains filtered or unexported fields
}
WebFile is an implementation of File which reads it from a Web URL (http). A GET request will be performed against the source when calling Read().
func NewWebFile ¶
NewWebFile creates a WebFile with the given URL, which will be used to perform the GET request on Read().
func (*WebFile) Read ¶
Read reads the File from it's web location. On the first call to Read, a GET request will be performed against the WebFile's URL, using Go's default HTTP client. Any further reads will keep reading from the HTTP Request body.