utils

package
v0.8.9 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package utils implements some useful functions to work with the file system.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyDir

func CopyDir(source string, dest string, uid, gid int) error

CopyDir copies a directory from source to dest and all of its sub-directories. It doesn't stop if it finds an error during the copy. Returns an error if any.

func CopyFile

func CopyFile(source string, dest string, uid, gid int) error

CopyFile copies a file from source to dest and returns an error if any.

func CutUserPath

func CutUserPath(p, filesPath string) string

* removes users path, and trim next prefix userName/files filesPath - path for users data directory

func Exists

func Exists(path string) bool

func GenPreviewConvertPath

func GenPreviewConvertPath(path string, scope string, previewScope string) (outp string)

Will return input and output to be processed to the bash convert/ffmpeg in order to generate preview

func GetFileInfo

func GetFileInfo(scope, urlPath string) (info os.FileInfo, err error, path string)

should get information about file.

func GetFileType added in v0.8.7

func GetFileType(name string) (res bool, t string)

getBasedOnExtensions checks if a file can be edited by its mimeExt.

func GetMimeType

func GetMimeType(f string) string

func ModPermission

func ModPermission(uid, gid int, path string) (err error)

func ReplacePrevExt

func ReplacePrevExt(srcPath string) (path string, t string)

modify existing file extension to the preview

func ResolveSymlink(p string) (inf os.FileInfo, realPath string, err error)

func ServeArchiveCompress

func ServeArchiveCompress(paths []string, filesFolder string, writer io.Writer, infos []os.FileInfo) (err error)

write archive file to writer, paths - absolute files paths, filesFolder - absolute path for users folder, this method will trim user folder path from archive

func SlashClean

func SlashClean(name string) string

SlashClean is equivalent to but slightly more efficient than path.Clean("/" + name).

func SplitURL

func SplitURL(path string) (int, string)

SplitURL splits the path and returns everything that stands before the first slash and everything that goes after.

Types

type Dir

type Dir string

A Dir uses the native file system restricted to a specific directory tree. Originally from ttps://github.com/golang/net/blob/master/webdav/file.go An empty Dir is treated as ".".

func (Dir) Copy

func (d Dir) Copy(src, dst string, uid, gid int) error

Copy copies a file or directory from src to dst. If it is a directory, all of the files and sub-directories will be copied.

func (Dir) Mkdir

func (d Dir) Mkdir(name string, perm os.FileMode, uid, gid int) error

Mkdir implements os.Mkdir in this directory context.

func (Dir) OpenFile

func (d Dir) OpenFile(name string, flag int, perm os.FileMode, uid, gid int) (*os.File, error)

OpenFile implements os.OpenFile in this directory context.

func (Dir) RemoveAll

func (d Dir) RemoveAll(name string) error

RemoveAll implements os.RemoveAll in this directory context.

func (Dir) Rename

func (d Dir) Rename(oldName, newName string) error

Rename implements os.Rename in this directory context.

func (Dir) Stat

func (d Dir) Stat(name string) (os.FileInfo, error)

Stat implements os.Stat in this directory context.

func (Dir) String

func (d Dir) String() string

Jump to

Keyboard shortcuts

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