Modify: re-organize structure of filesystem

This commit is contained in:
HFO4
2019-11-20 15:53:00 +08:00
parent e09294d388
commit 438ce02420
8 changed files with 191 additions and 142 deletions

28
pkg/filesystem/path.go Normal file
View File

@@ -0,0 +1,28 @@
package filesystem
import (
model "github.com/HFO4/cloudreve/models"
"path"
)
/* =================
路径/目录相关
=================
*/
// IsPathExist 返回给定目录是否存在
// 如果存在就返回目录
func (fs *FileSystem) IsPathExist(path string) (bool, model.Folder) {
folder, err := model.GetFolderByPath(path, fs.User.ID)
return err == nil, folder
}
// IsFileExist 返回给定路径的文件是否存在
func (fs *FileSystem) IsFileExist(fullPath string) bool {
basePath := path.Dir(fullPath)
fileName := path.Base(fullPath)
_, err := model.GetFileByPathAndName(basePath, fileName, fs.User.ID)
return err == nil
}