本文整理匯總了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]
}