fileio

package
v0.0.0-...-a954c3e Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileInterface

type FileInterface interface {
	TouchFile(string) error
	GetFileInfo(string) (os.FileInfo, error)
	RenameAndMoveFile(string, string) error
	CopyFile(string, string) error
	DeleteFile(string) error
	ReadFile(string) ([]byte, error)
	ReadFileByLine(string) ([]string, error)
	WriteToFile(string, interface{}, bool) error
	ReadJSONFile(string, interface{}) error
	ListFiles(string) ([]string, error)
	GenerateChecksum(string) error
	VerifyChecksum(string) (bool, error)
	GenerateHashForDir(string) ([]string, error)
	GenerateHashForFile(string) (string, error)
	NewYamlFromTemplateYaml(string, string, interface{}) error
	ListFilesWithPatterns(string, []string) ([]string, error)
	WriteToFileWithBase64Decoding(string, string) error
	Extract(string, string) error
}

FileInterface interface contains ways to R/W data From/To a file respectively

func New

func New() FileInterface

New returns new instance of Pf9FileIO for file IO ops

type Pf9FileIO

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

Pf9FileIO : A Platform9 wrapper for doing file IO operations

func (*Pf9FileIO) CopyFile

func (f *Pf9FileIO) CopyFile(originalFile, duplicateFile string) error

CopyFile copies a file

func (*Pf9FileIO) DeleteFile

func (f *Pf9FileIO) DeleteFile(filename string) error

DeleteFile deletes a file

func (*Pf9FileIO) Extract

func (f *Pf9FileIO) Extract(tgzFile string, destDir string) error

extract the targz file to the destination directory

func (*Pf9FileIO) GenerateChecksum

func (f *Pf9FileIO) GenerateChecksum(imageDir string) error

GenerateChecksum generates sha256 checksum for files and writes the checksum file in checksum sub-dir in given directory

func (*Pf9FileIO) GenerateHashForDir

func (f *Pf9FileIO) GenerateHashForDir(imageDir string) ([]string, error)

GenerateHashForDir generates sha256 hash for files in directory and returns string slice of hashes of files

func (*Pf9FileIO) GenerateHashForFile

func (f *Pf9FileIO) GenerateHashForFile(fileName string) (string, error)

GenerateHashForFile generates sha256 hash for given file and returns string of hash of file

func (*Pf9FileIO) GetFileInfo

func (f *Pf9FileIO) GetFileInfo(filename string) (os.FileInfo, error)

GetFileInfo fetches file details

func (*Pf9FileIO) ListFiles

func (f *Pf9FileIO) ListFiles(dirname string) ([]string, error)

ListFiles lists all the files in the directory

func (*Pf9FileIO) ListFilesWithPatterns

func (f *Pf9FileIO) ListFilesWithPatterns(root string, patterns []string) ([]string, error)

ListfilesWithPattern returns list of filenames with given patterns from given directory *recursively*

func (*Pf9FileIO) NewYamlFromTemplateYaml

func (f *Pf9FileIO) NewYamlFromTemplateYaml(templFile string, outFile string, data interface{}) error

NewYamlFromTemplateYaml creates new yaml from template yaml file by replacing the value in provided data

func (*Pf9FileIO) ReadFile

func (f *Pf9FileIO) ReadFile(filename string) ([]byte, error)

ReadFile reads an entire file and returns as bytes array

Should avoid reading large files

func (*Pf9FileIO) ReadFileByLine

func (f *Pf9FileIO) ReadFileByLine(filename string) ([]string, error)

ReadFileByLine reads a file line by line and returns it as slice

Should be avoided when reading large files

func (*Pf9FileIO) ReadJSONFile

func (f *Pf9FileIO) ReadJSONFile(filename string, output interface{}) error

ReadJSONFile reads a JSON file and updates the map passed as argument

func (*Pf9FileIO) RenameAndMoveFile

func (f *Pf9FileIO) RenameAndMoveFile(originalFile, newFile string) error

RenameAndMoveFile renames and/or moves file

func (*Pf9FileIO) TouchFile

func (f *Pf9FileIO) TouchFile(filename string) error

TouchFile creates an empty file

func (*Pf9FileIO) VerifyChecksum

func (f *Pf9FileIO) VerifyChecksum(imageDir string) (bool, error)

VerifyChecksum verifies the current sha256 checksum of all files with checksum file

func (*Pf9FileIO) WriteToFile

func (f *Pf9FileIO) WriteToFile(filename string, data interface{}, append bool) error

WriteToFile writes data to file

func (*Pf9FileIO) WriteToFileWithBase64Decoding

func (f *Pf9FileIO) WriteToFileWithBase64Decoding(destFile string, srcFile string) error

WriteToFileWithBase64Decoding writes base64 decoded data of source file to dest file

Jump to

Keyboard shortcuts

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