Documentation ¶
Overview ¶
Package fileutil handles common operations in files.
During tests, can be used the next tags:
-tags=log Run tests with logging.
Index ¶
- Constants
- Variables
- func CheckDir(p string) error
- func CheckFile(p string) error
- func CopyFile(src, dst string) error
- func CopytoTemp(filename string) (tmpFile string, err error)
- func Create(filename string, b []byte) (err error)
- func CreateDir(dir string) error
- func CreateFromString(filename string, s string) error
- func Dload(dst io.Writer, fileURL string) error
- func DloadToFile(dir, fileURL string) error
- func GroupHas(name string, p ...perm) (bool, error)
- func IsDir(name string) (bool, error)
- func IsFile(name string) (bool, error)
- func LastDirNumeric(path string) (fullPath string, version string, err error)
- func OthersHave(name string, p ...perm) (bool, error)
- func Overwrite(filename string, b []byte) (err error)
- func OwnerHas(name string, p ...perm) (bool, error)
- func PathAbsDir(dir string) (string, error)
- func PathRelative(dir, file string) string
- func ReadGob(filePath string, x interface{}) (err error)
- func Untar(filename, dirDst string) error
- func WriteGob(filePath string, x interface{}) (err error)
- func WritetoTemp(b []byte, name string) (filename string, err error)
- type Info
Constants ¶
const ( R perm // read W // write X // execute )
Permissions
Variables ¶
var Log *log.Logger
Log is the logger by default.
Functions ¶
func CopyFile ¶
CopyFile copies a file from 'src' to 'dst'. If 'src' and 'dst' files exist, and are the same, then return success. Otherwise, copy the file contents from 'src' to 'dst'.
The file will be created if it does not already exist. If the destination file exists, all it's contents will be replaced by the contents of the source file.
func CopytoTemp ¶
CopytoTemp copies a file from the filename to the default directory with temporary files (see 'os.TempDir').
Returns the temporary file name.
func Create ¶
Create creates a new file with b bytes.
If the file already exists, it is truncated. If the file does not exist, it is created with mode 0666 (before umask).
func CreateFromString ¶
CreateFromString creates a new file with the string 's'.
func DloadToFile ¶
DloadToFile downloads a file and saves it into directory 'dir'.
func LastDirNumeric ¶
LastDirNumeric returns the last directory based at numbers.
func OthersHave ¶
OthersHave reports whether the named file have all given permissions for the others.
func Overwrite ¶
Overwrite truncates the named file to zero and writes len(b) bytes. It is created with mode 0666 (before umask).
func PathAbsDir ¶
PathAbsDir returns the absolute path of a directory.
func PathRelative ¶
PathRelative returns the relative path of a file.
Types ¶
type Info ¶
type Info struct {
// contains filtered or unexported fields
}
Info represents a wrapper about os.FileInfo to append some functions.
func (Info) OthersHave ¶
OthersHave reports whether the others have all given permissions.