Documentation
¶
Overview ¶
Package file provides utilities for handling folder operations.
The `Folder` type is a string-based abstraction over a directory paths. The package includes methods for creating, removing, expanding, and checking the existence of directories, as well as manipulating paths.
Index ¶
- Variables
- type CriteriaFunc
- type Folder
- func (f Folder) Base() string
- func (f Folder) Create() error
- func (f Folder) CreateIgnoreExisting() error
- func (f Folder) Exists() bool
- func (f Folder) Expanded() Folder
- func (f Folder) FindFile(criteria ...CriteriaFunc) (file.File, error)
- func (f Folder) IsParentOf(other Folder) bool
- func (f Folder) IsSet() bool
- func (f Folder) ListFiles() (files.Files, error)
- func (f Folder) ListFolders() ([]Folder, error)
- func (f Folder) Normalized() Folder
- func (f Folder) Path() string
- func (f Folder) Remove() error
- func (f Folder) String() string
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("file not found")
ErrNotFound is returned when a file is not found during a search operation.
Functions ¶
This section is empty.
Types ¶
type CriteriaFunc ¶
CriteriaFunc defines a function type for filtering files during search operations.
type Folder ¶
type Folder string
Folder represents a file system directory as a string. It provides methods for working with directories, such as creating, removing, expanding paths, and checking existence.
func CreateRandomInDir ¶
CreateRandomInDir creates a new random directory inside the given directory. Use "" to create a random directory in the default directory for temporary files.
func NewInTempDir ¶
NewInTempDir assigns but does not create a directory inside the system's temporary directory.
func (Folder) Create ¶
Create creates the Folder and all necessary parent directories with 0755 permissions.
func (Folder) CreateIgnoreExisting ¶
CreateIgnoreExisting creates the Folder and all necessary parent directories with 0755 permissions. If the directory already exists, the error is nil.
func (Folder) FindFile ¶
func (f Folder) FindFile(criteria ...CriteriaFunc) (file.File, error)
FindFile searches for a file in the Folder that matches the provided criteria. It returns the first file found or an error if none are found.
func (Folder) IsParentOf ¶
IsParentOf determines if the Folder is a parent directory of the given 'other' Folder.
func (Folder) ListFiles ¶
ListFiles returns a slice of Files representing all files within the current Folder.
func (Folder) ListFolders ¶
ListFolders returns a slice of Folders representing all subdirectories within the current Folder.
func (Folder) Normalized ¶
Normalized converts the folder path to use forward slashes.