fsutil

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2023 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exists

func Exists(path string, followLinks bool) (bool, error)

Exists returns true if path is an existing file or directory, otherwise it returns false. If followLinks is true, then Exists will attempt to follow links to their target and report said target's existence. If followLinks is false, Exist will operate on the link itself.

func IsLink(path string) (bool, error)

IsLink returns true if path represents a symlink, otherwise it returns false.

func IsRegularFile

func IsRegularFile(path string) (bool, error)

IsRegularFile returns true if path represents a regular file, otherwise it returns false.

func SameContents

func SameContents(pathA, pathB string) (bool, error)

SameContents checks that two files contain the same bytes

Types

type FileStatus

type FileStatus int

FileStatus enumerates the states of a file on the filesystem.

const (
	// StatusAbsent means that the file does not exist.
	StatusAbsent FileStatus = iota
	// StatusRegularFile means that the file exists as a regular file.
	StatusRegularFile
	// StatusLink means that the artifact exists as a link.
	StatusLink
	// StatusDirectory means that the file exists as a directory.
	StatusDirectory
	// StatusOther means none of the above.
	StatusOther
)

func FileStatusFromPath

func FileStatusFromPath(path string) (FileStatus, error)

FileStatusFromPath converts a path into a FileStatus enum value.

func (FileStatus) MarshalJSON added in v0.4.1

func (fs FileStatus) MarshalJSON() ([]byte, error)

MarshalJSON marshals the FileStatus enum as a quoted JSON string. Note there is no UnmarshalJSON function, as marshalling to JSON is currently only used for printing debug information.

func (FileStatus) String

func (fs FileStatus) String() string

Jump to

Keyboard shortcuts

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