Documentation ¶
Overview ¶
Package dirctrl is an abstraction layer for filesystem function calls.
Index ¶
- Constants
- type DefaultDirectoryCommands
- type DefaultDirectoryController
- func (d *DefaultDirectoryController) DirectoryIsAccessible(directory string) bool
- func (d *DefaultDirectoryController) GetAbsolutePath(directory string) (string, error)
- func (d *DefaultDirectoryController) GetDirectoryInfo(directory string) (string, error)
- func (d *DefaultDirectoryController) GetInitialDirectory() (string, error)
- func (d *DefaultDirectoryController) ScanDirectory(path string, callback func(dirName string)) error
- type DefaultInfoWriter
- type DirectoryCommands
- type DirectoryController
- type DirectoryError
- type InfoWriter
Constants ¶
const ( DirUnexpectedError = iota + 1 DirUnprivilegedError )
const OsPathSeparator = string(os.PathSeparator)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DefaultDirectoryCommands ¶
type DefaultDirectoryCommands struct{}
DefaultDirectoryCommands is a placeholder struct for implemented methods of the DirectoryCommands interface.
func (*DefaultDirectoryCommands) GetAbsolutePath ¶
func (*DefaultDirectoryCommands) GetAbsolutePath(path string) (string, error)
GetAbsolutePath gets the full path of the specified directory.
func (*DefaultDirectoryCommands) ReadDirectory ¶
func (d *DefaultDirectoryCommands) ReadDirectory(dirname string) ([]fs.FileInfo, error)
ReadDirectory returns a list of fs.FileInfo objects from the specified directory.
func (*DefaultDirectoryCommands) ScanDirectory ¶
func (d *DefaultDirectoryCommands) ScanDirectory( path string, callback func(dirName string), ) error
ScanDirectory iterates over each file in the path and executes a callback that is provided the name of that file.
type DefaultDirectoryController ¶
type DefaultDirectoryController struct { Writer InfoWriter Commands DirectoryCommands }
DefaultDirectoryController contains a collection of methods that execute various commands on the filesystem.
func NewDefaultDirectoryController ¶
func NewDefaultDirectoryController() *DefaultDirectoryController
NewDefaultDirectoryController creates a new instance of DefaultDirectoryController with initialized methods.
func (*DefaultDirectoryController) DirectoryIsAccessible ¶
func (d *DefaultDirectoryController) DirectoryIsAccessible(directory string) bool
DirectoryIsAccessible determines if a directory is accessible to the current user.
func (*DefaultDirectoryController) GetAbsolutePath ¶
func (d *DefaultDirectoryController) GetAbsolutePath(directory string) (string, error)
GetAbsolutePath gets the full path of the specified directory.
func (*DefaultDirectoryController) GetDirectoryInfo ¶
func (d *DefaultDirectoryController) GetDirectoryInfo(directory string) (string, error)
GetDirectoryInfo returns a formatted list of files in the specified directory.
func (*DefaultDirectoryController) GetInitialDirectory ¶
func (d *DefaultDirectoryController) GetInitialDirectory() (string, error)
GetInitialDirectory returns the path that ci was run from.
func (*DefaultDirectoryController) ScanDirectory ¶
func (d *DefaultDirectoryController) ScanDirectory(path string, callback func(dirName string)) error
ScanDirectory iterates over each file in the path and executes a callback that is provided the name of that file.
type DefaultInfoWriter ¶
type DefaultInfoWriter struct {
// contains filtered or unexported fields
}
DefaultInfoWriter is an InfoWriter wrapper of the tabwriter module that outputs tab formatted data to a buffer.
func NewDefaultInfoWriter ¶
func NewDefaultInfoWriter() *DefaultInfoWriter
NewDefaultInfoWriter creates a new instance of DefaultInfoWriter.
func (*DefaultInfoWriter) Flush ¶
func (d *DefaultInfoWriter) Flush() (string, error)
Flush clears the DefaultInfoWriter buffers and returns its contents.
type DirectoryCommands ¶
type DirectoryCommands interface { ReadDirectory(dirname string) ([]fs.FileInfo, error) GetAbsolutePath(path string) (string, error) ScanDirectory(path string, callback func(dirName string)) error }
DirectoryCommands specifies the filesystem path functions that ci uses.
type DirectoryController ¶
type DirectoryController interface { GetInitialDirectory() (string, error) DirectoryIsAccessible(dir string) bool GetDirectoryInfo(dir string) (string, error) GetAbsolutePath(dir string) (string, error) ScanDirectory(path string, callback func(dirName string)) error }
DirectoryController specifies the abstracted filesystem functions that ci uses.
type DirectoryError ¶
DirectoryError represents an error that occurs while accessing the filesystem.
func (*DirectoryError) Error ¶
func (d *DirectoryError) Error() string
Error returns the message for this error.