Documentation ¶
Index ¶
- Variables
- type File
- func (f *File) Close() error
- func (f *File) ExtractSymlink(path string) []error
- func (f *File) ExtractTo(path string) []error
- func (f *File) ExtractWithOptions(path string, dereferenceSymlink, unbreakSymlink bool, folderPerm os.FileMode, ...) (errs []error)
- func (f *File) GetChildren() (children []*File, err error)
- func (f *File) GetChildrenRecursively() (children []*File, err error)
- func (f *File) GetFileAtPath(dirPath string) *File
- func (f *File) GetSymlinkFile() *File
- func (f *File) IsDir() bool
- func (f *File) IsFile() bool
- func (f *File) IsSymlink() bool
- func (f *File) ModTime() time.Time
- func (f *File) Mode() os.FileMode
- func (f *File) Name() string
- func (f *File) Path() string
- func (f *File) Read(p []byte) (int, error)
- func (f *File) Size() int64
- func (f *File) SymlinkPath() string
- func (f *File) Sys() interface{}
- type Reader
- func (r *Reader) ExtractTo(path string) []error
- func (r *Reader) FindAll(query func(*File) bool) (all []*File)
- func (r *Reader) FindFile(query func(*File) bool) *File
- func (r *Reader) GetAllFiles() (fils []*File, err error)
- func (r *Reader) GetFileAtPath(path string) *File
- func (r *Reader) GetRootFolder() (root *File, err error)
- func (r *Reader) ModTime() time.Time
Constants ¶
This section is empty.
Variables ¶
var ( //ErrBrokenSymlink is returned when using ExtractWithOptions with the unbreakSymlink set to true, but the symlink's file cannot be extracted. ErrBrokenSymlink = errors.New("Extracted symlink is probably broken") )
var ( //ErrOptions is returned when compression options that I haven't tested is set. When this is returned, the Reader is also returned. ErrOptions = errors.New("Possibly incompatible compressor options") )
Functions ¶
This section is empty.
Types ¶
type File ¶ added in v0.2.0
type File struct { Parent *File //The parent directory. Should ALWAYS be a folder. If it's the root directory, will be nil Reader io.Reader //Underlying reader. When writing, will probably be an os.File. When reading this is kept nil UNTIL reading to save memory. // contains filtered or unexported fields }
File is the main way to interact with files within squashfs, or when putting files into a squashfs. File can be either a file or folder. When reading from a squashfs, it reads from the datablocks. When writing, this holds the information on WHERE the file will be placed inside the archive.
Implements os.FileInfo and io.ReadCloser
func (*File) Close ¶ added in v0.2.0
Close frees up the memory held up by the underlying reader. Should NOT be called when writing. When reading, Close is safe to use, but any subsequent Read calls resets to the beginning of the file.
func (*File) ExtractSymlink ¶ added in v0.3.1
ExtractSymlink is similar to ExtractTo, but when it extracts a symlink, it instead extracts the file associated with the symlink in it's place. This is the same as ExtractWithOptions(path, true, false, os.ModePerm, false)
func (*File) ExtractTo ¶ added in v0.3.0
ExtractTo extracts the file to the given path. This is the same as ExtractWithOptions(path, false, false, os.ModePerm, false). Will NOT try to keep symlinks valid, folders extracted will have the permissions set by the squashfs, but the folder to make path will have full permissions (777).
Will try it's best to extract all files, and if any errors come up, they will be appended to the error slice that's returned.
func (*File) ExtractWithOptions ¶ added in v0.3.0
func (f *File) ExtractWithOptions(path string, dereferenceSymlink, unbreakSymlink bool, folderPerm os.FileMode, verbose bool) (errs []error)
ExtractWithOptions will extract the file to the given path, while allowing customization on how it works. ExtractTo is the "default" options. Will try it's best to extract all files, and if any errors come up, they will be appended to the error slice that's returned. Should only return multiple errors if extracting a folder.
If dereferenceSymlink is set, instead of extracting a symlink, it will extract the file the symlink is pointed to in it's place. If both dereferenceSymlink and unbreakSymlink is set, dereferenceSymlink takes precendence.
If unbreakSymlink is set, it will also try to extract the symlink's associated file. WARNING: the symlink's file may have to go up the directory to work. If unbreakSymlink is set and the file cannot be extracted, a ErrBrokenSymlink will be appended to the returned error slice.
folderPerm only applies to the folders created to get to path. Folders from the archive are given the correct permissions defined by the archive.
func (*File) GetChildren ¶ added in v0.2.0
GetChildren returns a *squashfs.File slice of every direct child of the directory. If the File is not a directory, will return ErrNotDirectory
func (*File) GetChildrenRecursively ¶ added in v0.2.0
GetChildrenRecursively returns ALL children. Goes down ALL folder paths.
func (*File) GetFileAtPath ¶ added in v0.2.1
GetFileAtPath tries to return the File at the given path, relative to the file. Returns nil if called on something other then a folder, OR if the path goes oustide the archive. Allows wildcards supported by path.Match (namely * and ?).
func (*File) GetSymlinkFile ¶ added in v0.2.1
GetSymlinkFile tries to return the squashfs.File associated with the symlink
func (*File) Mode ¶ added in v0.3.4
Mode returns the os.FileMode of the File. Sets mode bits for directories and symlinks.
func (*File) Read ¶ added in v0.2.0
Read from the file. Doesn't do anything fancy, just pases it to the underlying io.Reader. If a directory, return io.EOF.
func (*File) SymlinkPath ¶ added in v0.2.1
SymlinkPath returns the path the symlink is pointing to. If the file ISN'T a symlink, will return an empty string. If a path begins with "/" then the symlink is pointing to an absolute path (starting from root, and not a file inside the archive)
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader processes and reads a squashfs archive.
func NewSquashfsReader ¶
NewSquashfsReader returns a new squashfs.Reader from an io.ReaderAt
func (*Reader) ExtractTo ¶ added in v0.3.3
ExtractTo tries to extract ALL files to the given path. This is the same as getting the root folder and extracting that.
func (*Reader) FindAll ¶ added in v0.2.0
FindAll returns all files where the given function returns true.
func (*Reader) FindFile ¶ added in v0.2.0
FindFile returns the first file (in the same order as Reader.GetAllFiles) that the given function returns true for. Returns nil if nothing is found.
func (*Reader) GetAllFiles ¶ added in v0.2.0
GetAllFiles returns a slice of ALL files and folders contained in the squashfs.
func (*Reader) GetFileAtPath ¶ added in v0.2.0
GetFileAtPath will return the file at the given path. If the file cannot be found, will return nil.
func (*Reader) GetRootFolder ¶ added in v0.2.0
GetRootFolder returns a squashfs.File that references the root directory of the squashfs archive.