directory

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2025 License: Apache-2.0 Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Directory

func Directory(path string, opts Options) error

Directory performs the directory checks

Types

type Create added in v1.0.2

type Create struct {
	Kind     CreateKind  // Kind requires either CreateFileIfNotExists or IfNotExists CreateKind
	FileMode os.FileMode // FileMode allows you to set os.ModePerm etc.
	Path     string      // Path stores where the resource will be created
}

Create defines a New Directory that is a CreateKind (default NoAction), options include: - IfNotExists - IfExists Properties in the Create struct dictate the runtime of the Create.Run() method

func (*Create) Run added in v1.0.2

func (create *Create) Run() error

Run will read the Create.Kind and switch between IfExists and IfNotExists to run either createDirectory or replaceDirectory internally.

type CreateKind added in v1.0.2

type CreateKind int8
const (

	// NoAction CreateKind Skips Create in Directory in Options
	NoAction CreateKind = iota

	// IfNotExists CreateKind reads err := os.Stat, then if os.IsNotExists(err) is true and Create.Kind is IfNotExist,
	// the Create.Run() is called to create the directory in the Create.Path
	IfNotExists CreateKind = iota

	// IfExists CreateKind relies on os.Stat where os.IsNotExists(err) is false ; meaning the path exists; if the
	// Create.Kind is IfExists then checkfs will delete the path first, then create a new directory at the path in
	// Create.Path
	IfExists CreateKind = iota
)

type ErrCheckDirBadBaseDir

type ErrCheckDirBadBaseDir struct{ Path, BaseDir string }

func (*ErrCheckDirBadBaseDir) Error

func (e *ErrCheckDirBadBaseDir) Error() string

type ErrCheckDirBadGroup

type ErrCheckDirBadGroup struct{ Path, Expected, Actual string }

func (*ErrCheckDirBadGroup) Error

func (e *ErrCheckDirBadGroup) Error() string

type ErrCheckDirBadOwner

type ErrCheckDirBadOwner struct{ Path, Expected, Actual string }

func (*ErrCheckDirBadOwner) Error

func (e *ErrCheckDirBadOwner) Error() string

type ErrCheckDirNoWritePermissions

type ErrCheckDirNoWritePermissions struct{ Path string }

func (*ErrCheckDirNoWritePermissions) Error

type ErrCheckDirOpenPermissions

type ErrCheckDirOpenPermissions struct{ Path string }

func (*ErrCheckDirOpenPermissions) Error

type Options

type Options struct {
	CreatedBefore      time.Time   // Check directory creation time
	ModifiedBefore     time.Time   // Check directory modified time
	RequireOwner       string      // Check if the directory has a specific owner
	RequireGroup       string      // Check if the directory has a specific group
	RequireBaseDir     string      // Check if the directory is inside a specific base directory
	RequireExt         string      // Check if the directory has an extension (unlikely, but included for parity)
	RequirePrefix      string      // Check if the directory name begins with a prefix
	MorePermissiveThan os.FileMode // Check if mode is at least this permissive (e.g., >= 0444)
	LessPermissiveThan os.FileMode // Check if mode is less permissive than this (e.g., <= 0400)
	ReadOnly           bool        // Check if the directory is read-only
	RequireWrite       bool        // Check if the directory is writable
	WillCreate         bool        // User intends to create the directory, so if true, verify that we can create a directory in the parent of the path
	Create             Create      // user intends to create the directory
	Exists             bool        // If true, require the directory to exist; combining with WillCreate means Exists requires the Create to be successful
}

Jump to

Keyboard shortcuts

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