file

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2015 License: MIT Imports: 6 Imported by: 5

Documentation

Index

Constants

View Source
const (
	FilePerm = 0644
	DirPerm  = 0755
)
View Source
const ErrDestIsFile = errors.Err("destnation is a file")

Variables

This section is empty.

Functions

func Append

func Append(fname string, fn FileOpFunc) error

func Copy

func Copy(dst, src string) error

Copy src file to dest file

func CopyDir

func CopyDir(dst, src string) error

CopyDir copy directory from source to destination

func Create

func Create(fname string, fn FileOpFunc) error

func Filter

func Filter(src string, filter io2.LineFilterFunc) error

Filter file content with given filter, file is in ReadOnly mode

func FilterTo

func FilterTo(dst, src string, trunc bool, filter io2.LineFilterFunc) error

FilterTo filter file content with given filter, then write result to dest file

func FirstLine

func FirstLine(src string) (line string, err error)

FirstLine read first line from file

func IsDir

func IsDir(fname string) bool

IsDir check whether or not given name is a dir

func IsDirOrNotExist

func IsDirOrNotExist(dir string) bool

IsDirOrNotExist check whether given is a directory or not exist

func IsExist

func IsExist(fname string) bool

IsExist check whether or not file/dir exist

func IsFile

func IsFile(fname string) bool

IsFile check whether or not file exist

func IsFileOrNotExist

func IsFileOrNotExist(fname string) bool

IsFileOrNotExist check whether given name is a file or not exist

func IsModifiedAfter

func IsModifiedAfter(fname string, fn func()) bool

IsModifiedAfter check whether or not file is modified by the function

func IsSymlink(fname string) bool

IsSymlink check whether or not given name is a symlink

func Open

func Open(fname string, flags int, fn FileOpFunc) error

Open file use given flag

func OpenOrCreate

func OpenOrCreate(fname string, trunc bool, fn FileOpFunc) error

func Overwrite

func Overwrite(src string, content string) error

Overwrite delete all content in file, and write new content to it

func Read

func Read(fname string, fn FileOpFunc) error

func ReadWrite

func ReadWrite(fname string, fn FileOpFunc) error

func Trunc

func Trunc(fname string, fn FileOpFunc) error

func TruncSeek

func TruncSeek(fd *os.File)

TruncSeek truncate file size to 0 and seek current positon to 0

func Write

func Write(fname string, fn FileOpFunc) error

func WriteFlag

func WriteFlag(trunc bool) int

WriteFlag return os.O_APPEND if not delete content, else os.O_TRUNC

Types

type FileOpFunc

type FileOpFunc func(*os.File) error

FileOpFunc accept a file descriptor, return an error or nil

Jump to

Keyboard shortcuts

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