ioutils

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2023 License: Apache-2.0, BSD-2-Clause Imports: 7 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseFileAndRename

func CloseFileAndRename(fileDescriptor *os.File, sourceFilePath string, targetFilePath string) error

CloseFileAndRename closes the file descriptor and renames the file.

func CreateDirectory

func CreateDirectory(dir string, perm os.FileMode) error

CreateDirectory checks if the directory exists, otherwise it creates it with given permissions.

func CreateTempFile

func CreateTempFile(filePath string) (*os.File, string, error)

CreateTempFile creates a file descriptor with _tmp as file extension.

func DirExistsAndIsNotEmpty

func DirExistsAndIsNotEmpty(path string) (bool, error)

DirExistsAndIsNotEmpty checks if the folder exists and is not empty.

func DirectoryEmpty

func DirectoryEmpty(dirPath string) (bool, error)

DirectoryEmpty returns whether the given directory is empty.

func FolderSize

func FolderSize(target string) (int64, error)

FolderSize returns the size of a folder.

func PathExists

func PathExists(path string) (exists bool, isDirectory bool, err error)

PathExists returns whether the given file or directory exists.

func ReadFromFile

func ReadFromFile(filename string, data interface{}) error

ReadFromFile reads structured binary data from the file named by filename to data. A successful call returns err == nil, not err == EOF. ReadFromFile uses binary.Read to decode data. Data must be a pointer to a fixed-size value or a slice of fixed-size values.

func ReadJSONFromFile

func ReadJSONFromFile(filename string, data interface{}) error

ReadJSONFromFile reads JSON data from the file named by filename to data. ReadJSONFromFile uses json.Unmarshal to decode data. Data must be a pointer to a fixed-size value or a slice of fixed-size values.

func ReadTOMLFromFile

func ReadTOMLFromFile(filename string, data interface{}) error

ReadTOMLFromFile reads TOML data from the file named by filename to data. ReadTOMLFromFile uses toml.Unmarshal to decode data. Data must be a pointer to a fixed-size value or a slice of fixed-size values.

func WriteJSONToFile

func WriteJSONToFile(filename string, data interface{}, perm os.FileMode) (err error)

WriteJSONToFile writes the JSON representation of data to a file named by filename. If the file does not exist, WriteJSONToFile creates it with permissions perm (before umask); otherwise WriteJSONToFile truncates it before writing, without changing permissions. WriteJSONToFile uses json.MarshalIndent to encode data. Data must be a pointer to a fixed-size value or a slice of fixed-size values.

func WriteTOMLToFile

func WriteTOMLToFile(filename string, data interface{}, perm os.FileMode, header ...string) (err error)

WriteTOMLToFile writes the TOML representation of data to a file named by filename. If the file does not exist, WriteTOMLToFile creates it with permissions perm (before umask); otherwise WriteTOMLToFile truncates it before writing, without changing permissions. WriteTOMLToFile uses toml.Marshal to encode data. Data must be a pointer to a fixed-size value or a slice of fixed-size values. An additional header can be passed.

func WriteToFile

func WriteToFile(filename string, data interface{}, perm os.FileMode) (err error)

WriteToFile writes the binary representation of data to a file named by filename. If the file does not exist, WriteFile creates it with permissions perm (before umask); otherwise WriteFile truncates it before writing, without changing permissions. WriteToFile uses binary.Write to encode data. Data must be a pointer to a fixed-size value or a slice of fixed-size values.

Types

This section is empty.

Jump to

Keyboard shortcuts

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