Documentation
¶
Index ¶
- Constants
- Variables
- func CheckNoMountPoint(path string) error
- func CheckNotExist(src string) bool
- func CheckPermission(src string) bool
- func CommonPrefix(sep byte, paths ...string) string
- func ComparisonHash(data []byte, hash string) bool
- func CopyDir(src string, dst string, style string) error
- func CopyDirContext(ctx context.Context, src, dst, style string) error
- func CopyInRoots(ctx context.Context, src *os.Root, srcRel string, dst *os.Root, ...) error
- func CopyInRootsAs(ctx context.Context, src *os.Root, srcRel string, dst *os.Root, ...) error
- func CopySingleFile(src, dst, style string) error
- func CreateFile(path string) error
- func CreateFileAndWriteContent(path string, content string) error
- func DataLength(length int) []byte
- func DirSizeB(path string) (int64, error)
- func Exists(path string) bool
- func GetBlockInfo(fileSize int64) (blockSize int, length int)
- func GetExt(fileName string) string
- func GetFileOrDirSize(path string) (int64, error)
- func GetHashByContent(data []byte) string
- func GetHashByPath(path string) string
- func GetImage(path string, width, height int) ([]byte, error)
- func GetImageExt(p string) (string, error)
- func GetImageExtByName(p string) (string, error)
- func GetImageNamed(path, name string, width, height int) ([]byte, error)
- func GetNoDuplicateFileName(fullPath string) string
- func GetSize(f multipart.File) (int, error)
- func GetThumbnailByOwnerPhotos(path string) ([]byte, error)
- func GetThumbnailByWebPhoto(path string, width, height int) ([]byte, error)
- func ImageExtArray() []string
- func IsDir(path string) bool
- func IsFile(path string) bool
- func IsNotExistCreateFile(src string) error
- func IsNotExistMkDir(src string) error
- func MkDir(src string) error
- func MoveFile(sourcePath, destPath string) error
- func MustOpen(fileName, filePath string) (*os.File, error)
- func NameAccumulation(name string, dir string) string
- func Open(name string, flag int, perm os.FileMode) (*os.File, error)
- func Overlap(from, to string) bool
- func ParseFileHeader(h []byte, boundary []byte) (map[string]string, bool)
- func ParseFromHead(read_data []byte, read_total int, boundary []byte, stream io.ReadCloser) (map[string]string, []byte, error)
- func PrefixLength(byteLength int) []byte
- func RMDir(src string) error
- func ReadFullFile(path string) []byte
- func ReadLine(lineNumber int, path string) string
- func ReadToBoundary(boundary []byte, stream io.ReadCloser, target io.WriteCloser) ([]byte, bool, error)
- func RemoveAll(dir string) error
- func RemoveAllNoCross(path string) error
- func ReplaceFile(path string, data []byte) error
- func ReplaceFileFrom(path string, r io.Reader) error
- func SizeIn(root *os.Root, rel string) (int64, error)
- func SpliceFiles(dir, path string, length int, startPoint int) error
- func WriteFileAtomic(path string, data []byte) error
- func WriteFileAtomicFrom(path string, r io.Reader, perm os.FileMode) error
- func WriteToFullPath(data []byte, fullPath string, perm fs.FileMode) error
- func WriteToPath(data []byte, path, name string) error
- type ReadLineFromEnd
Constants ¶
const NoFollow = syscall.O_NOFOLLOW
NoFollow is the open flag that refuses a symlink as the last name (ELOOP).
Variables ¶
var ErrHoldsMountPoint = errors.New("a disk or a share is mounted there")
ErrHoldsMountPoint is the error of RemoveAllNoCross when a disk or a share is mounted in the tree.
var ErrLinkOutside = errors.New("a link out of the managed file roots: skipped")
ErrLinkOutside is the error of a copy that skipped a link inside the copied folder that leads out of file ManagementRoots (copying it would bring what it points to inside).
var ErrNotRegular = errors.New("not a regular file: skipped")
ErrNotRegular is the error of a copy that skipped what is not a regular file.
Functions ¶
func CheckNoMountPoint ¶ added in v0.4.82
CheckNoMountPoint is the rule of RemoveAllNoCross: ErrHoldsMountPoint when a disk or a share is mounted at the folder path or under it.
func CheckPermission ¶
CheckPermission check if the file has permission
func CommonPrefix ¶
func CopyDirContext ¶ added in v0.4.82
CopyDirContext is CopyDir that stops when ctx is done, between files and inside them.
func CopyInRoots ¶ added in v0.4.118
func CopyInRoots(ctx context.Context, src *os.Root, srcRel string, dst *os.Root, dstDir, style string) error
CopyInRoots copies srcRel of src into the folder dstDir of dst, under its own name, as CopyDirContext does. A link is copied as what it points to when that stays inside src, skipped otherwise (ErrLinkOutside, said at the end, as a device or a pipe is, ErrNotRegular). style "skip" leaves a file already there; anything else overwrites it.
func CopyInRootsAs ¶ added in v0.4.118
func CopyInRootsAs(ctx context.Context, src *os.Root, srcRel string, dst *os.Root, dstRel, style string) error
CopyInRootsAs is CopyInRoots to the name dstRel itself.
func CopySingleFile ¶
*
- @description:
- @param {*} src
- @param {*} dst
- @param {string} style
- @return {*}
- @method:
- @router:
func CreateFile ¶
func GetFileOrDirSize ¶
func GetImageExt ¶
* * @description:get a image's ext * @param {string} path "file path" * @return {string} ext "file ext" * @return {error} err "error info"
func GetImageExtByName ¶
func GetImageNamed ¶ added in v0.4.118
GetImageNamed is GetImage of the file at path, whose format is told by name (path may be a /proc/self/fd/N that has none).
func GetNoDuplicateFileName ¶
Check for duplicate file names
func GetThumbnailByWebPhoto ¶
func ImageExtArray ¶
func ImageExtArray() []string
func IsNotExistCreateFile ¶
IsNotExistCreateFile create a file if it does not exist
func IsNotExistMkDir ¶
IsNotExistMkDir create a directory if it does not exist
func NameAccumulation ¶
func Overlap ¶ added in v0.4.82
Overlap reports whether copying or moving from into the folder to would write over from or into it: the entry it makes, to/<name of from>, is from or holds it, or to is from or inside it. Paths are compared with their links resolved, and as files where they exist: a bind mount gives a folder a second name that no path comparison sees.
func ParseFromHead ¶
func ReadFullFile ¶
func ReadToBoundary ¶
func ReadToBoundary(boundary []byte, stream io.ReadCloser, target io.WriteCloser) ([]byte, bool, error)
func RemoveAllNoCross ¶ added in v0.4.82
RemoveAllNoCross is os.RemoveAll that never goes into a mounted disk or share: when one is mounted at path or under it, it removes nothing.
func ReplaceFile ¶ added in v0.4.82
ReplaceFile is ReplaceFileFrom for data.
func ReplaceFileFrom ¶ added in v0.4.82
ReplaceFileFrom writes what it reads from r over an existing file as WriteFileAtomic does, for a file someone edits or sends again: through a link it writes the link's target, the new file keeps the old one's mode and owner, and a file with hard links is written in place.
func SizeIn ¶ added in v0.4.118
SizeIn is the size of rel below root, a folder counted with all it holds: entries are measured as they are (Lstat), links not followed, and nothing is read outside root.
func WriteFileAtomic ¶ added in v0.4.62
WriteFileAtomic writes data to a temporary file next to path, syncs it to disk and renames it over path: after a power cut (common on single-board boxes) the file holds the old content or the new one, never an empty one. os.CreateTemp creates it 0600, whatever the old file's mode: it is for root's own state files.
func WriteFileAtomicFrom ¶ added in v0.4.82
WriteFileAtomicFrom is WriteFileAtomic for the content read from r, the new file made perm.
func WriteToPath ¶
Types ¶
type ReadLineFromEnd ¶
type ReadLineFromEnd struct {
// contains filtered or unexported fields
}
ReadLineFromEnd --
func NewReadLineFromEnd ¶
func NewReadLineFromEnd(name string) (rd *ReadLineFromEnd, err error)
NewReadLineFromEnd --
func (*ReadLineFromEnd) ReadLine ¶
func (c *ReadLineFromEnd) ReadLine() (line []byte, err error)
ReadLine 结尾包含'\n'