manager

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2018 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package manager is the core package that contacts directly with the file system

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyDir

func CopyDir(src, dst string) (err error)

CopyDir copies a directory and its children recursively Terminates when it meets an error (no fall back)

func CopyFile

func CopyFile(src, dst string) (err error)

CopyFile copies a file from src to dst. If `src` and `dst` files exist, and are the same, then return success. Otherwise, attempt to create a hard link between the two files. If that fails, copy the file contents from src to dst.

func CreateDir

func CreateDir(fullDirPath string, parents bool) (err error)

CreateDir creates new a new directory It creates parents directory if needed when `parents` is `true` It is similar to `mkdir -p`

func CreateFile

func CreateFile(fullFilePath string) (*os.File, error)

CreateFile creates a new file. If the file is already exists of the directory does not exists, it will return an error

func Remove

func Remove(fullPath string, recursive bool) (err error)

Remove file or directory

func Rename

func Rename(oldpath, newpath string) (err error)

Rename file of directory

func ZipDir

func ZipDir(dirPath string, w io.Writer) (err error)

ZipDir archives a directory to a zip file. `dirPath` is the source path of the directory to be zipped. `w` is the writer you want to write the zip bytes to

Types

type FileProperty

type FileProperty struct {
	Name    string `json:"name"`
	Size    int64  `json:"size"`
	Mode    string `json:"mode"`
	ModTime string `json:"modTime"`
	IsDir   bool   `json:"isDir"`
}

FileProperty is a data structure whichdescribes a file It is part of the result for list api

func ListDir

func ListDir(dir string, all bool, max int, ext string) (results []FileProperty, total int, err error)

ListDir returns all files and/or directories infomation of a specified path and count of all f/d rather than the count of the returned files. Caveats: the size of directory is solid, which is the size of the directory itself, not including what is inside the directory. Calculating the total size of a certain directory needs the program to calculate the sizes of all its sub contents recursively, which costs too much time and memory. It is not necessary to make this calculation.

Jump to

Keyboard shortcuts

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