當前位置: 首頁>>代碼示例>>Golang>>正文


Golang com.StatDir函數代碼示例

本文整理匯總了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)
}
開發者ID:hogehoge999,項目名稱:gogs,代碼行數:30,代碼來源:repo.go

示例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)
		})
	})
}
開發者ID:xuewuhen,項目名稱:cae,代碼行數:26,代碼來源:tz_test.go

示例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]
}
開發者ID:j20,項目名稱:gogs,代碼行數:34,代碼來源:repo.go


注:本文中的github.com/Unknwon/com.StatDir函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。