ioutils

package
v0.0.0-...-f63283b Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package ioutils implements helper functions used in github.com/minio/mc

Index

Constants

View Source
const (
	Nanosecond  Duration = 1
	Microsecond          = 1000 * Nanosecond
	Millisecond          = 1000 * Microsecond
	Second               = 1000 * Millisecond
	Minute               = 60 * Second
	Hour                 = 60 * Minute
	Day                  = 24 * Hour
)

Common durations. There is no definition for units of Day or larger to avoid confusion across daylight savings time zone transitions.

To count the number of units in a Duration, divide:

second := time.Second
fmt.Print(int64(second/time.Millisecond)) // prints 1000

To convert an integer number of units to a Duration, multiply:

seconds := 10
fmt.Print(time.Duration(seconds)*time.Second) // prints 10s

Variables

View Source
var ErrDirNotEmpty = errors.New("directory not empty")

ErrDirNotEmpty is used to throw error on directories which have atleast one regular file or a symlink left

View Source
var ErrSkipDir = errors.New("skip this directory")

ErrSkipDir is used as a return value from WalkFuncs to indicate that the directory named in the call is to be skipped. It is not returned as an error by any function.

View Source
var ErrSkipFile = errors.New("skip this file")

ErrSkipFile is used as a return value from WalkFuncs to indicate that the file named in the call is to be skipped. It is not returned as an error by any function.

Functions

func FTW

func FTW(root string, walkFn FTWFunc) error

FTW walks the file tree rooted at root, calling walkFn for each file or directory in the tree, including root.

func IsDirEmpty

func IsDirEmpty(dirname string) (status bool, err error)

IsDirEmpty Check if a directory is empty

func ParseDurationTime

func ParseDurationTime(s string) (time.Duration, error)

ParseDurationTime parses a duration string in the form "10d4h3m". A duration string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as "300ms", "-1.5h" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h", "d". It add the days functionality to time.ParseDuration().

Types

type Duration

type Duration int64

A Duration represents the elapsed time between two instants as an int64 nanosecond count. The representation limits the largest representable duration to approximately 290 years.

type FTWFunc

type FTWFunc func(path string, info os.FileInfo, err error) error

FTWFunc is the type of the function called for each file or directory visited by Walk. The path argument contains the argument to Walk as a prefix; that is, if Walk is called with "dir", which is a directory containing the file "a", the walk function will be called with argument "dir/a". The info argument is the os.FileInfo for the named path.

Jump to

Keyboard shortcuts

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