fs

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2025 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package fs provides file system operations and error definitions.

Package fs is a generated GoMock package.

Index

Constants

This section is empty.

Variables

View Source
var (
	// File lock errors.
	ErrFileLock = errors.New("lock")
)

Error definitions for fs package.

Functions

This section is empty.

Types

type FS

type FS interface {
	// Exists checks if a file or directory exists at the given path.
	Exists(path string) (bool, error)

	// IsDir checks if the path is a directory.
	IsDir(path string) (bool, error)

	// ReadFile reads the contents of a file.
	ReadFile(path string) ([]byte, error)

	// ReadDir reads the contents of a directory.
	ReadDir(path string) ([]os.DirEntry, error)

	// Glob finds files matching the pattern.
	Glob(pattern string) ([]string, error)

	// MkdirAll creates a directory and all parent directories.
	MkdirAll(path string, perm os.FileMode) error

	// GetHomeDir returns the user's home directory path.
	GetHomeDir() (string, error)

	// IsNotExist checks if an error indicates that a file or directory doesn't exist.
	IsNotExist(err error) bool

	// WriteFileAtomic writes data to a file atomically using a temporary file and rename.
	WriteFileAtomic(filename string, data []byte, perm os.FileMode) error

	// FileLock acquires a file lock and returns an unlock function.
	FileLock(filename string) (func(), error)

	// CreateFileIfNotExists creates a file with initial content if it doesn't exist.
	CreateFileIfNotExists(filename string, initialContent []byte, perm os.FileMode) error

	// RemoveAll removes a file or directory and all its contents.
	RemoveAll(path string) error

	// Which finds the executable path for a command using the system's PATH.
	Which(command string) (string, error)

	// ExecuteCommand executes a command with arguments in the background.
	ExecuteCommand(command string, args ...string) error

	// CreateDirectory creates a directory with permissions.
	CreateDirectory(path string, perm os.FileMode) error

	// CreateFileWithContent creates a file with content.
	CreateFileWithContent(path string, content []byte, perm os.FileMode) error

	// IsDirectoryWritable checks if a directory is writable.
	IsDirectoryWritable(path string) (bool, error)

	// ExpandPath expands ~ to user's home directory.
	ExpandPath(path string) (string, error)
}

FS interface provides file system operations for Git repository detection.

func NewFS

func NewFS() FS

NewFS creates a new FS instance.

type MockFS

type MockFS struct {
	// contains filtered or unexported fields
}

MockFS is a mock of FS interface.

func NewMockFS

func NewMockFS(ctrl *gomock.Controller) *MockFS

NewMockFS creates a new mock instance.

func (*MockFS) CreateDirectory

func (m *MockFS) CreateDirectory(path string, perm os.FileMode) error

CreateDirectory mocks base method.

func (*MockFS) CreateFileIfNotExists

func (m *MockFS) CreateFileIfNotExists(filename string, initialContent []byte, perm os.FileMode) error

CreateFileIfNotExists mocks base method.

func (*MockFS) CreateFileWithContent

func (m *MockFS) CreateFileWithContent(path string, content []byte, perm os.FileMode) error

CreateFileWithContent mocks base method.

func (*MockFS) EXPECT

func (m *MockFS) EXPECT() *MockFSMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockFS) ExecuteCommand

func (m *MockFS) ExecuteCommand(command string, args ...string) error

ExecuteCommand mocks base method.

func (*MockFS) Exists

func (m *MockFS) Exists(path string) (bool, error)

Exists mocks base method.

func (*MockFS) ExpandPath

func (m *MockFS) ExpandPath(path string) (string, error)

ExpandPath mocks base method.

func (*MockFS) FileLock

func (m *MockFS) FileLock(filename string) (func(), error)

FileLock mocks base method.

func (*MockFS) GetHomeDir

func (m *MockFS) GetHomeDir() (string, error)

GetHomeDir mocks base method.

func (*MockFS) Glob

func (m *MockFS) Glob(pattern string) ([]string, error)

Glob mocks base method.

func (*MockFS) IsDir

func (m *MockFS) IsDir(path string) (bool, error)

IsDir mocks base method.

func (*MockFS) IsDirectoryWritable

func (m *MockFS) IsDirectoryWritable(path string) (bool, error)

IsDirectoryWritable mocks base method.

func (*MockFS) IsNotExist

func (m *MockFS) IsNotExist(err error) bool

IsNotExist mocks base method.

func (*MockFS) MkdirAll

func (m *MockFS) MkdirAll(path string, perm os.FileMode) error

MkdirAll mocks base method.

func (*MockFS) ReadDir

func (m *MockFS) ReadDir(path string) ([]os.DirEntry, error)

ReadDir mocks base method.

func (*MockFS) ReadFile

func (m *MockFS) ReadFile(path string) ([]byte, error)

ReadFile mocks base method.

func (*MockFS) RemoveAll

func (m *MockFS) RemoveAll(path string) error

RemoveAll mocks base method.

func (*MockFS) Which

func (m *MockFS) Which(command string) (string, error)

Which mocks base method.

func (*MockFS) WriteFileAtomic

func (m *MockFS) WriteFileAtomic(filename string, data []byte, perm os.FileMode) error

WriteFileAtomic mocks base method.

type MockFSMockRecorder

type MockFSMockRecorder struct {
	// contains filtered or unexported fields
}

MockFSMockRecorder is the mock recorder for MockFS.

func (*MockFSMockRecorder) CreateDirectory

func (mr *MockFSMockRecorder) CreateDirectory(path, perm any) *gomock.Call

CreateDirectory indicates an expected call of CreateDirectory.

func (*MockFSMockRecorder) CreateFileIfNotExists

func (mr *MockFSMockRecorder) CreateFileIfNotExists(filename, initialContent, perm any) *gomock.Call

CreateFileIfNotExists indicates an expected call of CreateFileIfNotExists.

func (*MockFSMockRecorder) CreateFileWithContent

func (mr *MockFSMockRecorder) CreateFileWithContent(path, content, perm any) *gomock.Call

CreateFileWithContent indicates an expected call of CreateFileWithContent.

func (*MockFSMockRecorder) ExecuteCommand

func (mr *MockFSMockRecorder) ExecuteCommand(command any, args ...any) *gomock.Call

ExecuteCommand indicates an expected call of ExecuteCommand.

func (*MockFSMockRecorder) Exists

func (mr *MockFSMockRecorder) Exists(path any) *gomock.Call

Exists indicates an expected call of Exists.

func (*MockFSMockRecorder) ExpandPath

func (mr *MockFSMockRecorder) ExpandPath(path any) *gomock.Call

ExpandPath indicates an expected call of ExpandPath.

func (*MockFSMockRecorder) FileLock

func (mr *MockFSMockRecorder) FileLock(filename any) *gomock.Call

FileLock indicates an expected call of FileLock.

func (*MockFSMockRecorder) GetHomeDir

func (mr *MockFSMockRecorder) GetHomeDir() *gomock.Call

GetHomeDir indicates an expected call of GetHomeDir.

func (*MockFSMockRecorder) Glob

func (mr *MockFSMockRecorder) Glob(pattern any) *gomock.Call

Glob indicates an expected call of Glob.

func (*MockFSMockRecorder) IsDir

func (mr *MockFSMockRecorder) IsDir(path any) *gomock.Call

IsDir indicates an expected call of IsDir.

func (*MockFSMockRecorder) IsDirectoryWritable

func (mr *MockFSMockRecorder) IsDirectoryWritable(path any) *gomock.Call

IsDirectoryWritable indicates an expected call of IsDirectoryWritable.

func (*MockFSMockRecorder) IsNotExist

func (mr *MockFSMockRecorder) IsNotExist(err any) *gomock.Call

IsNotExist indicates an expected call of IsNotExist.

func (*MockFSMockRecorder) MkdirAll

func (mr *MockFSMockRecorder) MkdirAll(path, perm any) *gomock.Call

MkdirAll indicates an expected call of MkdirAll.

func (*MockFSMockRecorder) ReadDir

func (mr *MockFSMockRecorder) ReadDir(path any) *gomock.Call

ReadDir indicates an expected call of ReadDir.

func (*MockFSMockRecorder) ReadFile

func (mr *MockFSMockRecorder) ReadFile(path any) *gomock.Call

ReadFile indicates an expected call of ReadFile.

func (*MockFSMockRecorder) RemoveAll

func (mr *MockFSMockRecorder) RemoveAll(path any) *gomock.Call

RemoveAll indicates an expected call of RemoveAll.

func (*MockFSMockRecorder) Which

func (mr *MockFSMockRecorder) Which(command any) *gomock.Call

Which indicates an expected call of Which.

func (*MockFSMockRecorder) WriteFileAtomic

func (mr *MockFSMockRecorder) WriteFileAtomic(filename, data, perm any) *gomock.Call

WriteFileAtomic indicates an expected call of WriteFileAtomic.

Jump to

Keyboard shortcuts

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