fileex

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 23, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Byte  = 1
	KByte = Byte * 1024
	MByte = KByte * 1024
	GByte = MByte * 1024
	TByte = GByte * 1024
	PByte = TByte * 1024
	EByte = PByte * 1024
)

Storage unit constants.

Variables

View Source
var DEFAULT_PID_FILE = "log/PID"

DEFAULT_PID_FILE the default PID file name

View Source
var ErrExceedLimit = errors.New("write exceed limit")
View Source
var ErrOffset = errors.New("Seek: invalid offset")
View Source
var ErrWhence = errors.New("Seek: invalid whence")

Functions

func CheckPermission added in v0.0.7

func CheckPermission(src string) bool

CheckPermission 检查文件权限

func CopyDir

func CopyDir(src string, dst string) error

CopyDir 拷贝目录 copy directory from src to dst

func CopyFile

func CopyFile(src, dst string) error

CopyFile 拷贝文件 copy file

func CreateDir added in v0.0.6

func CreateDir(path string) error

func CreateFile added in v0.0.6

func CreateFile(path string) bool

func DirExists added in v0.0.5

func DirExists(path string) bool

检查目录是否存在

func Exists added in v0.0.5

func Exists(path string) bool

校验目录或文件是否存在

func FileExists added in v0.0.4

func FileExists(path string) bool

func FileMTime added in v0.0.7

func FileMTime(file string) (int64, error)

FileMTime returns file modified time and possible error.

func FilePutContents added in v0.0.4

func FilePutContents(fileName, data string, flags ...interface{}) (int, error)

FilePutContents write files with offset/limit fileName name of file to where put data flags[0] - flags how to put this data FileAppend | LockEx

func FileSize added in v0.0.7

func FileSize(file string) (int64, error)

FileSize returns file size in bytes and possible error.

func GetDatasFromCSV added in v0.0.9

func GetDatasFromCSV(file *os.File) ([][]string, error)

GetDatasFromCSV 从csv文件获取数据

func GetDatasFromXlsx added in v0.0.9

func GetDatasFromXlsx(file *os.File) ([][]string, error)

GetDatasFromXlsx 从xlsx文件获取数据

func GetExePath

func GetExePath() (exePath string, err error)

func GetFileDir

func GetFileDir(filePath string) string

func HumaneFileSize added in v0.0.7

func HumaneFileSize(s uint64) string

HumaneFileSize calculates the file size and generate user-friendly string.

func IsDir added in v0.0.4

func IsDir(fileName string) bool

IsDir tells whether the filename is a directory

func IsFile added in v0.0.4

func IsFile(fp string) bool
func IsLink(fileName string) bool

IsLink tells whether the filename is a symbolic link

func IsRegularFile added in v0.0.4

func IsRegularFile(fileName string) bool

IsRegularFile tells whether the filename is a regular file

func ReadJsonFileIntoVar added in v0.0.9

func ReadJsonFileIntoVar(val interface{}, jFile string) error

func ReadLine added in v0.0.9

func ReadLine(r *bufio.Reader) ([]byte, error)

func ToBytes added in v0.0.9

func ToBytes(filePath string) ([]byte, error)

func ToInt64 added in v0.0.9

func ToInt64(filePath string) (int64, error)

func ToString added in v0.0.9

func ToString(filePath string) (string, error)

func ToTrimString added in v0.0.9

func ToTrimString(filePath string) (string, error)

func ToUint64 added in v0.0.9

func ToUint64(filePath string) (uint64, error)

func WriteBytes added in v0.0.9

func WriteBytes(filePath string, b []byte) (int, error)

func WriteFileAtomic added in v0.0.4

func WriteFileAtomic(filename string, data []byte, perm os.FileMode) error

Write file to temp and atomically move when everything else succeeds.

func WritePidFile added in v0.0.9

func WritePidFile(pidFile ...string)

WritePidFile writes the current PID to the specified file.

func WriteString added in v0.0.9

func WriteString(filePath string, s string) (int, error)

func WriteValueToJsonFile added in v0.0.9

func WriteValueToJsonFile(val interface{}, jFile string) error

Types

type SectionWriter added in v0.0.4

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

func NewSectionWriter added in v0.0.4

func NewSectionWriter(w io.WriterAt, off int64, n int64) *SectionWriter

func (*SectionWriter) Seek added in v0.0.4

func (s *SectionWriter) Seek(offset int64, whence int) (int64, error)

func (*SectionWriter) Size added in v0.0.4

func (s *SectionWriter) Size() int64

Size returns the size of the section in bytes.

func (*SectionWriter) Write added in v0.0.4

func (s *SectionWriter) Write(p []byte) (n int, err error)

func (*SectionWriter) WriteAt added in v0.0.4

func (s *SectionWriter) WriteAt(p []byte, off int64) (n int, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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