mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
Feat: archive download and sign temp url
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package util
|
||||
|
||||
import "os"
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
// Exists reports whether the named file or directory exists.
|
||||
func Exists(name string) bool {
|
||||
@@ -11,3 +14,17 @@ func Exists(name string) bool {
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// CreatNestedFile 给定path创建文件,如果目录不存在就递归创建
|
||||
func CreatNestedFile(path string) (*os.File, error) {
|
||||
basePath := filepath.Dir(path)
|
||||
if !Exists(basePath) {
|
||||
err := os.MkdirAll(basePath, 0700)
|
||||
if err != nil {
|
||||
Log().Warning("无法创建目录,%s", err)
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return os.Create(path)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user