Documentation ¶
Index ¶
- Constants
- Variables
- func AppendLine(path string, content string) error
- func CloseOneExec(file *os.File)
- func CopyDir(src string, dst string) error
- func CopyFile(src, dist string) error
- func CropImage(file string, width, height int) (err error)
- func FileExt(fileName string) string
- func FileType(fileName string) string
- func GetDocumentExts() (exts []string)
- func GetExts(extType string) (exts []string)
- func GetFileMD5(filePath string) (string, error)
- func GetImageSize(file string) (width, height int, err error)
- func IsDocument(ext string) bool
- func IsImage(ext string) bool
- func ListFiles(path string) []string
- func LoadFile(filename string) ([]byte, error)
- func LoadJsonToObject(filename string, obj interface{}) error
- func PathExists(path string) (bool, error)
- func ReadCSV(filename string) ([]string, error)
- func WriteBytesToFile(fileName string, content []byte) error
- func WriteString(path string, content string, append bool) error
- func WriteStringToFile(fileName string, content string) error
- type FileIOSelector
- type IOSelector
Constants ¶
View Source
const FilePerm = 0644
FilePerm default permission of the newly created log file.
Variables ¶
View Source
var ErrInvalidFsize = errors.New("fsize can`t be zero or negative")
ErrInvalidFsize invalid file size.
Functions ¶
func AppendLine ¶
func CloseOneExec ¶
CloseOnExec makes sure closing the file on process forking.
func GetDocumentExts ¶
func GetDocumentExts() (exts []string)
func GetImageSize ¶
GetImageSize 获取图片宽高信息
func LoadJsonToObject ¶
LoadJsonToObject 读取json文件
func PathExists ¶
PathExists check if the directory or file exits
func WriteBytesToFile ¶
func WriteStringToFile ¶
Types ¶
type FileIOSelector ¶
type FileIOSelector struct {
// contains filtered or unexported fields
}
FileIOSelector represents using standard file I/O.
func (*FileIOSelector) Close ¶
func (fio *FileIOSelector) Close() error
Close is a wrapper of os.File Close.
func (*FileIOSelector) Delete ¶
func (fio *FileIOSelector) Delete() error
Delete file descriptor if we don`t use it anymore.
func (*FileIOSelector) Read ¶
func (fio *FileIOSelector) Read(b []byte, offset int64) (int, error)
Read is a wrapper of os.File ReadAt.
func (*FileIOSelector) Sync ¶
func (fio *FileIOSelector) Sync() error
Sync is a wrapper of os.File Sync.
type IOSelector ¶
type IOSelector interface { // Write a slice to log file at offset. // It returns the number of bytes written and an error, if any. Write(b []byte, offset int64) (int, error) // Read a slice from offset. // It returns the number of bytes read and any error encountered. Read(b []byte, offset int64) (int, error) // Sync commits the current contents of the file to stable storage. // Typically, this means flushing the file system's in-memory copy // of recently written data to disk. Sync() error // Close closes the File, rendering it unusable for I/O. // It will return an error if it has already been closed. Close() error // Delete delete the file. // Must close it before delete, and will unmap if in MMapSelector. Delete() error }
IOSelector io selector for fileio and mmap, used by wal and value log right now.
func NewFileIOSelector ¶
func NewFileIOSelector(fName string, fsize int64) (IOSelector, error)
NewFileIOSelector create a new file io selector.
Click to show internal directories.
Click to hide internal directories.