filesystem

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2018 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultPollingInterval is the default watch polling interval, in seconds.
	DefaultPollingInterval = 10
)
View Source
const (

	// MutagenDirectoryName is the name of the Mutagen control directory inside
	// the user's home directory.
	MutagenDirectoryName = ".mutagen"
)

Variables

View Source
var HomeDirectory string

HomeDirectory is the cached path to the current user's home directory.

View Source
var MutagenConfigurationPath string

MutagenConfigurationPath is the path to the Mutagen configuration file.

View Source
var WatchMode_name = map[int32]string{
	0: "WatchDefault",
	1: "WatchPortable",
	2: "WatchForcePoll",
}
View Source
var WatchMode_value = map[string]int32{
	"WatchDefault":   0,
	"WatchPortable":  1,
	"WatchForcePoll": 2,
}

Functions

func DecomposesUnicode

func DecomposesUnicode(path string) (bool, error)

func DeviceID

func DeviceID(path string) (uint64, error)

func DirectoryContents

func DirectoryContents(path string) ([]string, error)

func GetOwnership

func GetOwnership(info os.FileInfo) (int, int, error)

func Mutagen

func Mutagen(create bool, subpath ...string) (string, error)

func Normalize

func Normalize(path string) (string, error)

func PreservesExecutability

func PreservesExecutability(path string) (bool, error)

func RenameFileAtomic

func RenameFileAtomic(oldPath, newPath string) error

RenameFileAtomic performs an atomic file rename. In the simplest case, it's a simple alias for os.Rename. However, if moving a file across filesystems, it will fall back to a copy/rename combination that should still approximate atomicity (at least in terms of swapping the destination file contents). It does NOT support renaming directories, only files. It takes inspiration from: https://github.com/golang/dep/blob/4ad9f4ec24012607dc247ca24528e3224d61519a/fs.go#L80

func SetOwnership

func SetOwnership(path string, uid, gid int) error

func Watch

func Watch(context context.Context, root string, events chan struct{}, mode WatchMode, pollInterval uint32)

TODO: Document that this function closes the events channel when the watch is cancelled. TODO: Document that this function will always succeed in one way or another (it doesn't have any total failure modes) and won't exit until the associated context is cancelled. TODO: Document that the events channel must be buffered.

func WriteFileAtomic

func WriteFileAtomic(path string, data []byte, permissions os.FileMode) error

Types

type Locker

type Locker struct {
	// contains filtered or unexported fields
}

func NewLocker

func NewLocker(path string, permissions os.FileMode) (*Locker, error)

func (*Locker) Lock

func (l *Locker) Lock(block bool) error

func (*Locker) Unlock

func (l *Locker) Unlock() error

type WatchMode

type WatchMode int32

WatchMode specifies the mode for filesystem watching.

const (
	// WatchMode_WatchDefault represents an unspecified watch mode. It should be
	// converted to one of the following values based on the desired default
	// behavior.
	WatchMode_WatchDefault WatchMode = 0
	// WatchMode_WatchPortable specifies that native recursive watching should
	// be used to monitor paths on systems that support it if those paths fall
	// under the home directory. In these cases, a watch on the entire home
	// directory is established and filtered for events pertaining to the
	// specified path. On all other systems and for all other paths, poll-based
	// watching is used.
	WatchMode_WatchPortable WatchMode = 1
	// WatchMode_WatchForcePoll specifies that only poll-based watching should
	// be used.
	WatchMode_WatchForcePoll WatchMode = 2
)

func (WatchMode) Description

func (m WatchMode) Description() string

Description returns a human-readable description of a watch mode.

func (WatchMode) EnumDescriptor

func (WatchMode) EnumDescriptor() ([]byte, []int)

func (WatchMode) String

func (x WatchMode) String() string

func (WatchMode) Supported

func (m WatchMode) Supported() bool

Supported indicates whether or not a particular watch mode is a valid, non-default value.

func (*WatchMode) UnmarshalText

func (m *WatchMode) UnmarshalText(textBytes []byte) error

UnmarshalText implements the text unmarshalling interface used when loading from TOML files.

Directories

Path Synopsis
Package winfsnotify allows the user to receive file system event notifications on Windows.
Package winfsnotify allows the user to receive file system event notifications on Windows.

Jump to

Keyboard shortcuts

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