common

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2016 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// O_NONBLOCK flag tell some functions not to block.
	// Its value does not interfere with O_* constants from 'os' package.
	O_NONBLOCK = syscall.O_NONBLOCK
)

Variables

This section is empty.

Functions

func FlagsForAccess

func FlagsForAccess(flag int) int

FlagsForAccess extracts os.O_RDONLY, os.O_WRONLY, os.O_RDWR, and O_NONBLOCK flag values.

func FlagsForOpen

func FlagsForOpen(flag int) int

FlagsForOpen extracts os.O_CREATE and os.O_EXCL flag values.

func IsTimeoutErr added in v0.3.0

func IsTimeoutErr(err error) bool

IsTimeoutErr returns true, if the given error is a temporary syscall error.

func OpenOrCreate

func OpenOrCreate(creator func(bool) error, flag int) (bool, error)

OpenOrCreate performs open/create file operation according to the given mode. It allows to find out if the object was opened or created.

creator is the function which performs actual operation.
	It is called with 'true', if it must create an object, and with false otherwise.
	It must return an 'not exists error' if the param is false, and the object does not exist.
	It must return an 'already exists error' if the param is true, and the object already exists.
flag is the combination of open flags from os package.
	If flag == os.O_CREATE, OpenOrCreate makes several attempts to open or create an object,
	and analyzes the return error. It tries to open the object first.

func SyscallErrHasCode

func SyscallErrHasCode(err error, code syscall.Errno) bool

SyscallErrHasCode returns true, if given error is a syscall error with given code.

Types

This section is empty.

Jump to

Keyboard shortcuts

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