file

package
v0.0.0-...-4a7a8e8 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package file Filesystem related utilities

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrEmptyDirectoryName is returned by constructing the full path
	// of data directory if the passed argument is empty
	ErrEmptyDirectoryName = errors.New("data directory must not be empty")
	// ErrDotDirectoryName is returned by constructing the full path of
	// data directory if the passed argument is "."
	ErrDotDirectoryName = errors.New("data directory must not be equal to \".\"")
)

Functions

func CopyFile

func CopyFile(dst string, src io.Reader) (n int64, err error)

CopyFile copy file

func DetermineResourcePath

func DetermineResourcePath(staticDir string, resourceDir string, devDir string) (string, error)

DetermineResourcePath DEPRECATE

func InitDataDir

func InitDataDir(dir string) (string, error)

InitDataDir Joins dir with the user's $HOME directory. If $HOME cannot be determined, uses the current working directory. dir must not be the empty string

func LoadJSON

func LoadJSON(filename string, thing interface{}) error

LoadJSON load json file

func ResolveResourceDirectory

func ResolveResourceDirectory(path string) string

ResolveResourceDirectory searches locations for a research directory and returns absolute path

func SaveBinary

func SaveBinary(filename string, data []byte, mode os.FileMode) error

SaveBinary persists data into given file in binary, backup the previous file, if there was one

func SaveJSON

func SaveJSON(filename string, thing interface{}, mode os.FileMode) error

SaveJSON write value into json file

func SaveJSONSafe

func SaveJSONSafe(filename string, thing interface{}, mode os.FileMode) error

SaveJSONSafe saves json to disk, but refuses if file already exists

func UserHome

func UserHome() string

UserHome returns the current user home path

Types

This section is empty.

Jump to

Keyboard shortcuts

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