package fileutil
import "github.com/tredoe/osutil/fileutil"
Package fileutil handles common operations in files.
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(urlFile string, dst io.Writer) 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 LookDirExec(sys sysutil.System, filename string) (string, error)
- func LookPath(sys sysutil.System, filename ...string) (string, 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 ( // ErrNotFound indicates when a search does not find a file at 'LookPath()'. ErrNotFound = errors.New("file not found") )
Functions ¶
func CheckDir ¶
CheckDir checks if the path exists and if it is a directory.
func CheckFile ¶
CheckFile checks if the path exists and if it is a file.
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 CreateDir ¶
CreateDir creates a directory if it does not exist.
func CreateFromString ¶
CreateFromString creates a new file with the string 's'.
func Dload ¶
Dload downloads a file.
func GroupHas ¶
GroupHas reports whether the named file has all given permissions for the group.
func IsDir ¶
IsDir reports whether if the named file is a directory.
func IsFile ¶
IsFile reports whether the named file is a regular file.
func LastDirNumeric ¶
LastDirNumeric returns the last directory based at numbers.
func LookDirExec ¶
LookDirExec looks up the directory of an executable.
func LookPath ¶
LookPath searches for an executable named file in the system directories given one or several executables.
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 OwnerHas ¶
OwnerHas reports whether the named file has all given permissions for the owner.
func PathAbsDir ¶
PathAbsDir returns the absolute path of a directory.
func PathRelative ¶
PathRelative returns the relative path of a file.
func ReadGob ¶
ReadGob gets data from a Go binary value.
func Untar ¶
Untar uncompresses a 'tar.gz' or 'tar' file.
func WriteGob ¶
WriteGob exports data to a Go binary value.
func WritetoTemp ¶
WritetoTemp writes bytes to a temporary file and returns its name.
Types ¶
type Info ¶
type Info struct {
// contains filtered or unexported fields
}
Info represents a wrapper about os.FileInfo to append some functions.
func NewInfo ¶
NewInfo returns a Info describing the named file.
func (Info) GroupHas ¶
GroupHas reports whether the group has all given permissions.
func (Info) IsDir ¶
IsDir reports whether if it is a directory.
func (Info) IsFile ¶
IsFile reports whether it is a regular file.
func (Info) OthersHave ¶
OthersHave reports whether the others have all given permissions.
func (Info) OwnerHas ¶
OwnerHas reports whether the owner has all given permissions.
Source Files ¶
compress.go dir.go doc.go encoding.go file.go http.go info.go io.go path.go
- Version
- v1.3.5
- Published
- Aug 19, 2021
- Platform
- js/wasm
- Imports
- 15 packages
- Last checked
- 1 day ago –
Tools for package owners.