1 Star 0 Fork 0

api-go/smartystreets-goconvey

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
file_system.go 948 Bytes
一键复制 编辑 原始数据 按行查看 历史
package system
import (
"io/ioutil"
"log"
"os"
"path/filepath"
"strings"
)
type FileSystem struct{}
func (self *FileSystem) Walk(root string, step filepath.WalkFunc) {
err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
if self.isMetaDirectory(info) {
return filepath.SkipDir
}
return step(path, info, err)
})
if err != nil {
log.Println("Error while walking file system:", err)
panic(err)
}
}
func (self *FileSystem) isMetaDirectory(info os.FileInfo) bool {
name := info.Name()
return info.IsDir() && (strings.HasPrefix(name, ".") || strings.HasPrefix(name, "_") || name == "testdata")
}
func (self *FileSystem) Listing(directory string) ([]os.FileInfo, error) {
return ioutil.ReadDir(directory)
}
func (self *FileSystem) Exists(directory string) bool {
info, err := os.Stat(directory)
return err == nil && info.IsDir()
}
func NewFileSystem() *FileSystem {
return &FileSystem{}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/netscript/smartystreets-goconvey.git
git@gitee.com:netscript/smartystreets-goconvey.git
netscript
smartystreets-goconvey
smartystreets-goconvey
v1.5.0

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385