-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
15 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,32 @@ | ||
package vfs | ||
|
||
import ( | ||
"io/fs" | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/auula/vasedb/clog" | ||
"github.com/auula/vasedb/conf" | ||
"github.com/auula/vasedb/utils" | ||
) | ||
|
||
var ( | ||
// Folders 标准目录结构 | ||
folders = []string{"etc", "temp", "data", "index"} | ||
) | ||
|
||
// SetupFS build vasedb file system | ||
func SetupFS(path string, folders ...string) error { | ||
func SetupFS(path string, perm fs.FileMode) error { | ||
|
||
// 拼接文件路径 | ||
for _, dir := range folders { | ||
// 检查目录是否存在 | ||
if utils.IsExist(filepath.Join(path, dir)) { | ||
clog.Infof("Initial %s checked successful", dir) | ||
} else { | ||
if !utils.IsExist(filepath.Join(path, dir)) { | ||
// 不存在创建对应的目录 | ||
err := os.MkdirAll(filepath.Join(path, dir), conf.Permissions) | ||
err := os.MkdirAll(filepath.Join(path, dir), perm) | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
} | ||
|
||
// 不要写在这里如果这个包被单独拿出去使用,不能配置 clog 包使用 | ||
// clog.Info("Initial storage successful") | ||
return nil | ||
} |