filesystem

package
v1.6.4 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileSystem

type FileSystem struct {
	Fs afero.Fs
}

func NewFileSystem

func NewFileSystem(fs afero.Fs) *FileSystem

func (*FileSystem) CreateDirectoryIfNotExists

func (s *FileSystem) CreateDirectoryIfNotExists(path string) error

CreateDirectoryIfNotExists creates a directory if it does not already exist.

func (*FileSystem) CreateFile

func (s *FileSystem) CreateFile(filename string) (afero.File, error)

CreateFile creates or truncates the named file.

func (*FileSystem) CreateFileIfNotExists

func (s *FileSystem) CreateFileIfNotExists(filename string) (afero.File, error)

CreateFileIfNotExists creates a file if it does not already exist.

func (*FileSystem) GetAferoFs

func (s *FileSystem) GetAferoFs() afero.Fs

func (*FileSystem) ReadDir

func (s *FileSystem) ReadDir(path string) ([]string, error)

ReadDir reads the directory named by path and returns a slice of file names.

func (*FileSystem) ReadFile

func (s *FileSystem) ReadFile(filePath string) (string, error)

ReadFile reads the content of a file and returns it as a string.

func (*FileSystem) ReadFileFromURL

func (s *FileSystem) ReadFileFromURL(url string) (string, error)

func (*FileSystem) WriteFile

func (s *FileSystem) WriteFile(filename string, content string) error

WriteFile writes a string to a file, overwriting it if it already exists.

type FileSystemInterface

type FileSystemInterface interface {
	GetAferoFs() afero.Fs
	CreateDirectoryIfNotExists(path string) error
	ReadFile(filePath string) (string, error)
	CreateFileIfNotExists(filename string) (afero.File, error)
	CreateFile(filename string) (afero.File, error)
	WriteFile(filename string, content string) error
	ReadDir(path string) ([]string, error)
	ReadFileFromURL(url string) (string, error)
}

Jump to

Keyboard shortcuts

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