os

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OperationRead           = "read"
	OperationWrite          = "write"
	OperationExecute        = "execute"
	OperationReadFile       = "read file"
	OperationWriteFile      = "write file"
	OperationReadDirectory  = "read directory"
	OperationWriteDirectory = "write directory"
	OperationOpenDatabase   = "open database"
)

Operation constants for file access checks

Variables

This section is empty.

Functions

func CheckFileAccess added in v1.6.0

func CheckFileAccess(path string, operation string) error

CheckFileAccess checks if a file or directory is accessible and returns detailed permission information if there's an issue

func CopyFile

func CopyFile(src, dst string) error

CopyFile copies a file. It truncates the destination file if it exists.

func EnsureDir

func EnsureDir(dir string, mode os.FileMode) error

EnsureDir ensures the given directory exists, creating it if necessary. Errors if the path already exists as a non-directory.

func FileExists

func FileExists(filePath string) bool

func WrapPermissionError added in v1.6.0

func WrapPermissionError(path string, operation string, err error) error

WrapPermissionError wraps an error with detailed permission diagnostics if it's a permission error

Types

type NoopCloser added in v1.0.0

type NoopCloser struct{}

NoopCloser is a no-op io.Closer.

func (NoopCloser) Close added in v1.0.0

func (NoopCloser) Close() error

type PermissionError added in v1.6.0

type PermissionError struct {
	Path              string
	Operation         string
	OriginalError     error
	FileUID           int
	FileGID           int
	FileMode          os.FileMode
	ProcessUID        int
	ProcessGID        int
	ProcessEUID       int
	ProcessEGID       int
	ParentDirMode     os.FileMode
	ParentDirUID      int
	ParentDirGID      int
	IsPermissionIssue bool
}

PermissionError represents a detailed permission error with diagnostic information

func (*PermissionError) Error added in v1.6.0

func (e *PermissionError) Error() string

Error implements the error interface

func (*PermissionError) Unwrap added in v1.6.0

func (e *PermissionError) Unwrap() error

Unwrap returns the underlying error

Jump to

Keyboard shortcuts

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