Documentation ¶
Index ¶
- func CloseFileAndRename(fileDescriptor *os.File, sourceFilePath string, targetFilePath string) error
- func CreateDirectory(dir string, perm os.FileMode) error
- func CreateTempFile(filePath string) (*os.File, string, error)
- func DirectoryEmpty(dirPath string) (bool, error)
- func FolderSize(target string) (int64, error)
- func PathExists(path string) (exists bool, isDirectory bool, err error)
- func ReadFromFile(filename string, data interface{}) error
- func ReadJSONFromFile(filename string, data interface{}) error
- func ReadTOMLFromFile(filename string, data interface{}) error
- func WriteJSONToFile(filename string, data interface{}, perm os.FileMode) (err error)
- func WriteTOMLToFile(filename string, data interface{}, perm os.FileMode, header ...string) (err error)
- func WriteToFile(filename string, data interface{}, perm os.FileMode) (err error)
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 ¶
CreateDirectory checks if the directory exists, otherwise it creates it with given permissions.
func CreateTempFile ¶
CreateTempFile creates a file descriptor with _tmp as file extension.
func DirectoryEmpty ¶
DirectoryEmpty returns whether the given directory is empty.
func FolderSize ¶
FolderSize returns the size of a folder.
func PathExists ¶
PathExists returns whether the given file or directory exists.
func ReadFromFile ¶
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 ¶
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 ¶
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 ¶
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 ¶
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.