代码拉取完成,页面将自动刷新
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{}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。