fs

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2021 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FlagAppend                = os.O_APPEND
	FlagWrite                 = os.O_WRONLY
	FlagCreate                = os.O_CREATE
	FlagReadOnly              = os.O_RDONLY
	FlagAppendOrWrite         = FlagAppend | FlagWrite
	FlagWriteOrCreate         = FlagWrite | FlagCreate
	FlagWriteOrCreateOrAppend = FlagWrite | FlagCreate | FlagAppend
)

Variables

This section is empty.

Functions

func AppendFile added in v0.1.7

func AppendFile(
	isCreateParentDir bool,
	filePath string,
	content []byte,
) *errorwrapper.Wrapper

func AppendFileUsingLock added in v0.1.7

func AppendFileUsingLock(
	isCreateParentDir bool,
	filePath string,
	content []byte,
) *errorwrapper.Wrapper

func AppendStringFile added in v0.1.7

func AppendStringFile(
	isCreateParentDir bool,
	filePath string,
	content string,
) *errorwrapper.Wrapper

func AppendStringFileUsingLock added in v0.1.7

func AppendStringFileUsingLock(
	isCreateParentDir bool,
	filePath string,
	content string,
) *errorwrapper.Wrapper

func CheckSumFileBytes added in v0.2.2

func CheckSumFileBytes(
	hashType hashas.Variant,
	location string,
) *errbyte.Results

func CheckSumFileBytesUsingLock added in v0.2.2

func CheckSumFileBytesUsingLock(
	hashType hashas.Variant,
	location string,
) *errbyte.Results

func CheckSumFileString added in v0.2.2

func CheckSumFileString(
	hashType hashas.Variant,
	location string,
) *errstr.Result

func CheckSumFileStringUsingLock added in v0.2.2

func CheckSumFileStringUsingLock(
	hashType hashas.Variant,
	location string,
) *errstr.Result

func CopyChmod added in v0.5.0

func CopyChmod(
	srcPath,
	dstPath string,
) *errorwrapper.Wrapper

func CopyChmodChown added in v0.4.4

func CopyChmodChown(
	srcPath,
	dstPath string,
) *errorwrapper.Wrapper

func CopyFile

func CopyFile(srcPath, dstPath string) *errorwrapper.Wrapper

CopyFile Future ref: https://stackoverflow.com/a/21067803

func CopyFileContents added in v0.2.2

func CopyFileContents(
	srcPath,
	dstPath string,
) (errWp *errorwrapper.Wrapper)

func CopyFilesAsync added in v0.4.8

func CopyFilesAsync(
	isMove bool,
	sourceToDestination map[string]string,
) *errorwrapper.Wrapper

func CopySameRootFilesUsingRootReplaceAsync added in v0.4.8

func CopySameRootFilesUsingRootReplaceAsync(
	isContinueOnError,
	isClearDestination,
	isMove bool,
	sourceRoot string,
	sourcePaths []string,
	destinationRootPath string,
) *errorwrapper.Wrapper

CopySameRootFilesUsingRootReplaceAsync

Replaces all sourcePaths using sourceRoot and usage destinationPath to replace the root and copies file on the destination path

Restrictions:

  • Here, all the sourcePaths needs to be in the same dir.
func CopySymLink(src, dst string) error

CopySymLink copies a symbolic link from src to dst.

func CreateDirectoryAllDefault

func CreateDirectoryAllDefault(location string) *errorwrapper.Wrapper

func CreateDirectoryAllUptoParent

func CreateDirectoryAllUptoParent(location string) *errorwrapper.Wrapper

func CreateDirectoryAllUptoParentMany added in v0.3.9

func CreateDirectoryAllUptoParentMany(paths ...string) *errorwrapper.Wrapper

func CreateParentDirWithChmodChown added in v0.4.4

func CreateParentDirWithChmodChown(srcPath string, dstPath string) *errorwrapper.Wrapper

func GetFileName

func GetFileName(location string) string

func IsDirectory

func IsDirectory(location string) bool

func IsExistButDirectory added in v0.1.7

func IsExistButDirectory(location string) bool

func IsNotPathExists added in v0.2.2

func IsNotPathExists(location string) bool

func IsNotPathExistsUsing added in v0.2.2

func IsNotPathExistsUsing(fileInfo os.FileInfo, err error) bool

func IsPathExists

func IsPathExists(location string) bool

func IsPathExistsUsing added in v0.2.2

func IsPathExistsUsing(
	fileInfo os.FileInfo,
	err error,
) bool

func IsPathExistsUsingLock added in v0.2.0

func IsPathExistsUsingLock(location string) bool

func JsonReadUnmarshal added in v0.2.2

func JsonReadUnmarshal(
	filePath string,
	unmarshallObjectRef interface{},
) *errorwrapper.Wrapper

func JsonReadUnmarshalLock added in v0.2.2

func JsonReadUnmarshalLock(
	filePath string,
	unmarshallObjectRef interface{},
) *errorwrapper.Wrapper

func JsonReadUnmarshalOnExist added in v0.3.8

func JsonReadUnmarshalOnExist(
	filePath string,
	unmarshallObjectRef interface{},
) *errorwrapper.Wrapper

func JsonWriteMarshal added in v0.2.2

func JsonWriteMarshal(
	isCreateParentDir,
	isSkipOnNilObject bool,
	isKeepExistingFileModeOnExist bool,
	fileMod os.FileMode,
	filePath string,
	marshallingObjectRef interface{},
) *errorwrapper.Wrapper

func JsonWriteMarshalUsingLock added in v0.2.2

func JsonWriteMarshalUsingLock(
	isCreateParentDir,
	isSkipOnNilObject bool,
	isKeepExistingFileModeOnExist bool,
	fileMod os.FileMode,
	filePath string,
	marshallingObjectRef interface{},
) *errorwrapper.Wrapper

func LinuxTouchFile added in v0.2.1

func LinuxTouchFile(fullPath string) *errorwrapper.Wrapper

func LinuxTouchFileUsingLock added in v0.2.2

func LinuxTouchFileUsingLock(fullPath string) *errorwrapper.Wrapper

func LinuxTouchLocationFile added in v0.2.1

func LinuxTouchLocationFile(parentPath, fileName string) *errorwrapper.Wrapper

func MoveFile added in v0.2.2

func MoveFile(srcPath, dstPath string) *errorwrapper.Wrapper

MoveFile move file path from source to destination

func ParentDir

func ParentDir(location string) string

func Read

func Read(location string, filename string) *errbyte.Results

func ReadErrorJsonResult added in v0.2.4

func ReadErrorJsonResult(filePath string) *errjson.Result

func ReadErrorJsonResultUnmarshal added in v0.2.4

func ReadErrorJsonResultUnmarshal(
	filePath string,
	unmarshalObject interface{},
) *errorwrapper.Wrapper

func ReadErrorJsonResultUnmarshalUsingLock added in v0.2.4

func ReadErrorJsonResultUnmarshalUsingLock(
	filePath string,
	unmarshalObject interface{},
) *errorwrapper.Wrapper

func ReadErrorJsonResultUsingLock added in v0.2.4

func ReadErrorJsonResultUsingLock(filePath string) *errjson.Result

func ReadFile

func ReadFile(filePath string) *errbyte.Results

func ReadFileLinesUsingLock added in v0.2.0

func ReadFileLinesUsingLock(filePath string) *errstr.Results

func ReadFileNonWhitespaceLinesUsingLock added in v0.2.0

func ReadFileNonWhitespaceLinesUsingLock(filePath string) *errstr.Results

func ReadFileString added in v0.2.0

func ReadFileString(filePath string) *errstr.Result

func ReadFileStringUsingLock added in v0.2.0

func ReadFileStringUsingLock(filePath string) *errstr.Result

func ReadFileUsingLock added in v0.2.0

func ReadFileUsingLock(filePath string) *errbyte.Results

func ReadJsonParseSelfInjector added in v0.2.4

func ReadJsonParseSelfInjector(
	filePath string,
	jsonParseSelfInjector corejson.JsonParseSelfInjector,
) *errorwrapper.Wrapper

func ReadJsonParseSelfInjectorUsingLock added in v0.2.4

func ReadJsonParseSelfInjectorUsingLock(
	filePath string,
	jsonParseSelfInjector corejson.JsonParseSelfInjector,
) *errorwrapper.Wrapper

func ReadLinesOnExistUsingLock added in v0.3.8

func ReadLinesOnExistUsingLock(filePath string) *errstr.Results

func ReadSimpleSliceUsingLock added in v0.3.6

func ReadSimpleSliceUsingLock(
	filePath string,
) (*corestr.SimpleSlice, *errorwrapper.Wrapper)

func ReadStringOnExistUsingLock added in v0.3.8

func ReadStringOnExistUsingLock(filePath string) *errstr.Result

func ReadUsingLock added in v0.2.0

func ReadUsingLock(location string, filename string) *errbyte.Results

func Remove

func Remove(location string) *errorwrapper.Wrapper

Remove Reference : https://t.ly/xnAe

func Rename

func Rename(srcPath, dstPath string) *errorwrapper.Wrapper

func SafeRemove

func SafeRemove(location string) *errorwrapper.Wrapper

SafeRemove Reference : https://t.ly/xnAe

func Write

func Write(
	isCreateParentDir bool,
	location string,
	filename string,
	content []byte,
) *errorwrapper.Wrapper

func WriteAllParams added in v0.5.0

func WriteAllParams(
	isCreateParentDir,
	isSkipOnNilObject bool,
	isKeepExistingFileModeOnExist bool,
	fileMod os.FileMode,
	dirCreateMod os.FileMode,
	filePath string,
	contents []byte,
) *errorwrapper.Wrapper

func WriteAllParamsLock added in v0.5.0

func WriteAllParamsLock(
	isCreateParentDir,
	isSkipOnNilObject bool,
	isKeepExistingFileModeOnExist bool,
	fileMod os.FileMode,
	dirCreateMod os.FileMode,
	filePath string,
	contents []byte,
) *errorwrapper.Wrapper

func WriteAnyLock added in v0.2.0

func WriteAnyLock(
	isCreateParentDir bool,
	filePath string,
	content interface{},
) *errorwrapper.Wrapper

WriteAnyLock should be used with caution, it should only be used when one is trying convert struct to string then save it to file. it is not the right way to the file back.

func WriteEmptyStringLock added in v0.3.6

func WriteEmptyStringLock(
	isCreateParentDir bool,
	filePath string,
) *errorwrapper.Wrapper

func WriteErrorJsonResult added in v0.2.4

func WriteErrorJsonResult(
	isCreateParentDir,
	isSkipErrorOnNilOrEmpty bool,
	errJsonResult *errjson.Result,
	location string,
) *errorwrapper.Wrapper

func WriteErrorJsonResultUsingLock added in v0.2.4

func WriteErrorJsonResultUsingLock(
	isCreateParentDir,
	isSkipErrorOnNilOrEmpty bool,
	errJsonResult *errjson.Result,
	location string,
) *errorwrapper.Wrapper

func WriteFile

func WriteFile(
	isCreateParentDir bool,
	filePath string,
	content []byte,
) *errorwrapper.Wrapper

func WriteFileLock added in v0.1.6

func WriteFileLock(
	isCreateParentDir bool,
	filePath string,
	content []byte,
) *errorwrapper.Wrapper

func WriteFileUsingFileMode added in v0.2.2

func WriteFileUsingFileMode(
	isCreateParentDir,
	isKeepExistingFileModeOnExist bool,
	filePath string,
	content []byte,
	mode os.FileMode,
) *errorwrapper.Wrapper

func WriteJsonResult added in v0.2.4

func WriteJsonResult(
	isCreateParentDir,
	isSkipErrorOnNilOrEmpty bool,
	jsonResult *corejson.Result,
	location string,
) *errorwrapper.Wrapper

func WriteJsonResultUsingLock added in v0.2.4

func WriteJsonResultUsingLock(
	isCreateParentDir,
	isSkipErrorOnNilOrEmpty bool,
	jsonResult *corejson.Result,
	location string,
) *errorwrapper.Wrapper

func WriteJsonResultWithoutChecking added in v0.5.0

func WriteJsonResultWithoutChecking(
	jsonResult *corejson.Result,
	location string,
) *errorwrapper.Wrapper

func WriteSimpleSliceToFileUsingLock added in v0.3.6

func WriteSimpleSliceToFileUsingLock(
	isCreateParentDir bool,
	filePath string,
	simpleSlice *corestr.SimpleSlice,
) *errorwrapper.Wrapper

func WriteStringLinesToFile

func WriteStringLinesToFile(
	isCreateParentDir bool,
	filePath string,
	contentLines []string,
) *errorwrapper.Wrapper

func WriteStringLinesToFileSkipOnEmptyUsingLock added in v0.3.6

func WriteStringLinesToFileSkipOnEmptyUsingLock(
	isCreateParentDir bool,
	filePath string,
	contentLines []string,
) *errorwrapper.Wrapper

func WriteStringLinesToFileUsingLock added in v0.1.6

func WriteStringLinesToFileUsingLock(
	isCreateParentDir bool,
	filePath string,
	contentLines []string,
) *errorwrapper.Wrapper

func WriteStringToFile

func WriteStringToFile(
	isCreateParentDir bool,
	filePath string,
	content string,
) *errorwrapper.Wrapper

func WriteStringToFileUsingLock added in v0.1.6

func WriteStringToFileUsingLock(
	isCreateParentDir bool,
	filePath string,
	content string,
) *errorwrapper.Wrapper

func WriteStringToFileUsingLockFileMode added in v0.2.2

func WriteStringToFileUsingLockFileMode(
	isCreateParentDir,
	isKeepExistingFileModeOnExist bool,
	filePath string,
	content string,
	fileMode os.FileMode,
) *errorwrapper.Wrapper

Types

type CopierOrMoverFunc added in v0.4.8

type CopierOrMoverFunc = func(source, destination string) *errorwrapper.Wrapper

type OsFile added in v0.2.2

type OsFile struct {
	Location         string
	OsFile           *os.File
	ErrorWrapper     *errorwrapper.Wrapper
	DeferClosingFunc func() *errorwrapper.Wrapper // must be called upon checking IsDeferCloseRequired
	// contains filtered or unexported fields
}

OsFile defer function must be called to close the file.

func DirFileCreate added in v0.2.2

func DirFileCreate(
	existingFileErrorWrapper *errorwrapper.Wrapper,
	directory,
	relativeFilePath string,
	chmod os.FileMode,
) *OsFile

func GetOsFile added in v0.2.2

func GetOsFile(
	existingErrorWrapper *errorwrapper.Wrapper,
	osFlag int,
	fileMode os.FileMode,
	filePath string,
) *OsFile

GetOsFile defer function must be called to close the file.

func GetOsFileAppendOrWrite added in v0.2.2

func GetOsFileAppendOrWrite(
	existingErrorWrapper *errorwrapper.Wrapper,
	filePath string,
	fileMode os.FileMode,
) *OsFile

GetOsFileAppendOrWrite defer function must be called to close the file.

func GetOsFileAppendOrWriteOrCreate added in v0.2.2

func GetOsFileAppendOrWriteOrCreate(
	existingErrorWrapper *errorwrapper.Wrapper,
	filePath string,
	fileMode os.FileMode,
) *OsFile

GetOsFileAppendOrWriteOrCreate defer function must be called to close the file.

func GetOsFileReadOnly added in v0.2.2

func GetOsFileReadOnly(
	existingErrorWrapper *errorwrapper.Wrapper,
	filePath string,
	fileMode os.FileMode,
) *OsFile

GetOsFileReadOnly defer function must be called to close the file.

func GetOsFileWriteOrCreate added in v0.2.2

func GetOsFileWriteOrCreate(
	existingErrorWrapper *errorwrapper.Wrapper,
	filePath string,
	fileMode os.FileMode,
) *OsFile

GetOsFileWriteOrCreate defer function must be called to close the file.

func TempFileCreate added in v0.2.2

func TempFileCreate(
	existingFileErrorWrapper *errorwrapper.Wrapper,
	relativeFilePath string,
	chmod os.FileMode,
) *OsFile

func TempFileCreateDefaultChmod added in v0.2.2

func TempFileCreateDefaultChmod(
	existingFileErrorWrapper *errorwrapper.Wrapper,
	relativeFilePath string,
) *OsFile

func (*OsFile) ApplyChmod added in v0.2.2

func (it *OsFile) ApplyChmod(mode os.FileMode) *errorwrapper.Wrapper

func (*OsFile) AttachDeferCloseOnRequire added in v0.2.2

func (it *OsFile) AttachDeferCloseOnRequire() *errorwrapper.Wrapper

func (*OsFile) BothExtension added in v0.2.2

func (it *OsFile) BothExtension() (dotExt, ext string)

func (*OsFile) ChmodWithError added in v0.2.2

func (it *OsFile) ChmodWithError() *pathchmod.ChmodWithError

func (*OsFile) ClearFileContents added in v0.2.2

func (it *OsFile) ClearFileContents() *errorwrapper.Wrapper

func (*OsFile) Close added in v0.2.2

func (it *OsFile) Close() *errorwrapper.Wrapper

func (*OsFile) FileInfo added in v0.2.2

func (it *OsFile) FileInfo() (os.FileInfo, *errorwrapper.Wrapper)

func (*OsFile) FileName added in v0.2.2

func (it *OsFile) FileName() string

func (*OsFile) HasError added in v0.2.2

func (it *OsFile) HasError() bool

func (*OsFile) HasFile added in v0.2.2

func (it *OsFile) HasFile() bool

func (*OsFile) IsDeferCloseRequired added in v0.2.2

func (it *OsFile) IsDeferCloseRequired() bool

func (*OsFile) IsEmptyError added in v0.2.2

func (it *OsFile) IsEmptyError() bool

func (*OsFile) IsEmptyFile added in v0.2.2

func (it *OsFile) IsEmptyFile() bool

func (*OsFile) IsSafeFile added in v0.2.2

func (it *OsFile) IsSafeFile() bool

func (*OsFile) ParentDir added in v0.2.2

func (it *OsFile) ParentDir() string

func (*OsFile) RwxWrapper added in v0.2.2

func (it *OsFile) RwxWrapper() *pathchmod.RwxWrapperWithError

func (*OsFile) WriteBytes added in v0.2.2

func (it *OsFile) WriteBytes(
	writingBytes []byte,
) (hasWrittenSuccessfully bool, errWp *errorwrapper.Wrapper)

func (*OsFile) WriteString added in v0.2.2

func (it *OsFile) WriteString(
	writingString string,
) (hasWrittenSuccessfully bool, errWp *errorwrapper.Wrapper)

Source Files

Jump to

Keyboard shortcuts

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