本文整理汇总了Golang中github.com/Unknwon/com.StatDir函数的典型用法代码示例。如果您正苦于以下问题:Golang StatDir函数的具体用法?Golang StatDir怎么用?Golang StatDir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了StatDir函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: LoadRepoConfig
func LoadRepoConfig() {
// Load .gitignore and license files.
types := []string{"gitignore", "license"}
typeFiles := make([][]string, 2)
for i, t := range types {
files, err := com.StatDir(path.Join("conf", t))
if err != nil {
log.Fatal(4, "Fail to get %s files: %v", t, err)
}
customPath := path.Join(setting.CustomPath, "conf", t)
if com.IsDir(customPath) {
customFiles, err := com.StatDir(customPath)
if err != nil {
log.Fatal(4, "Fail to get custom %s files: %v", t, err)
}
for _, f := range customFiles {
if !com.IsSliceContainsStr(files, f) {
files = append(files, f)
}
}
}
typeFiles[i] = files
}
Gitignores = typeFiles[0]
Licenses = typeFiles[1]
sort.Strings(Gitignores)
sort.Strings(Licenses)
}
示例2: TestExtractTo
func TestExtractTo(t *testing.T) {
Convey("Extract a tar.gz file to given path", t, func() {
z, err := Open("testdata/test.tar.gz")
So(err, ShouldBeNil)
Convey("Extract the tar.gz file without entries", func() {
os.RemoveAll(path.Join(os.TempDir(), "testdata/test1"))
So(z.ExtractTo(path.Join(os.TempDir(), "testdata/test1")), ShouldBeNil)
list, err := com.StatDir(path.Join(os.TempDir(), "testdata/test1"), true)
So(err, ShouldBeNil)
So(com.CompareSliceStrU(list,
strings.Split("dir/ dir/bar dir/empty/ hello readonly", " ")), ShouldBeTrue)
})
Convey("Extract the tar.gz file with entries", func() {
os.RemoveAll(path.Join(os.TempDir(), "testdata/test2"))
So(z.ExtractTo(
path.Join(os.TempDir(), "testdata/test2"),
"dir/", "dir/bar", "readonly"), ShouldBeNil)
list, err := com.StatDir(path.Join(os.TempDir(), "testdata/test2"), true)
So(err, ShouldBeNil)
So(com.CompareSliceStrU(list,
strings.Split("dir/ dir/bar readonly", " ")), ShouldBeTrue)
})
})
}
示例3: LoadRepoConfig
func LoadRepoConfig() {
workDir, err := base.ExecDir()
if err != nil {
qlog.Fatalf("Fail to get work directory: %s\n", err)
}
// Load .gitignore and license files.
types := []string{"gitignore", "license"}
typeFiles := make([][]string, 2)
for i, t := range types {
cfgPath := filepath.Join(workDir, "conf", t)
files, err := com.StatDir(cfgPath)
if err != nil {
qlog.Fatalf("Fail to get default %s files: %v\n", t, err)
}
cfgPath = filepath.Join(workDir, "custom/conf/gitignore")
if com.IsDir(cfgPath) {
customFiles, err := com.StatDir(cfgPath)
if err != nil {
qlog.Fatalf("Fail to get custom %s files: %v\n", t, err)
}
for _, f := range customFiles {
if !com.IsSliceContainsStr(files, f) {
files = append(files, f)
}
}
}
typeFiles[i] = files
}
LanguageIgns = typeFiles[0]
Licenses = typeFiles[1]
}