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


Golang FileSystem.Mkdir方法代碼示例

本文整理匯總了Golang中github.com/hanwen/go-fuse/fuse/pathfs.FileSystem.Mkdir方法的典型用法代碼示例。如果您正苦於以下問題:Golang FileSystem.Mkdir方法的具體用法?Golang FileSystem.Mkdir怎麽用?Golang FileSystem.Mkdir使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/hanwen/go-fuse/fuse/pathfs.FileSystem的用法示例。


在下文中一共展示了FileSystem.Mkdir方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: TestDir

func (s *fuseTestSuite) TestDir() {
	datasetName := "TestDir"
	str := spec.CreateValueSpecString("ldb", s.LdbDir, datasetName)

	var testfs pathfs.FileSystem

	start(str, func(fs pathfs.FileSystem) { testfs = fs })

	code := testfs.Mkdir("noms", 0777, nil)
	assert.Equal(s.T(), fuse.OK, code)
	assertAttr(s, testfs, "noms", 0777|fuse.S_IFDIR, 0)
}
開發者ID:Richardphp,項目名稱:noms,代碼行數:12,代碼來源:basics_test.go

示例2: TestRmdir

func (s *fuseTestSuite) TestRmdir() {
	datasetName := "TestRmdir"
	str := spec.CreateValueSpecString("ldb", s.LdbDir, datasetName)

	var testfs pathfs.FileSystem

	start(str, func(fs pathfs.FileSystem) { testfs = fs })

	code := testfs.Mkdir("wikileaks", 0755, nil)
	assert.Equal(s.T(), fuse.OK, code)
	assertAttr(s, testfs, "", 0777|fuse.S_IFDIR, 1) // 1 means it's there
	code = testfs.Rmdir("wikileaks", nil)
	assert.Equal(s.T(), fuse.OK, code)
	assertAttr(s, testfs, "", 0777|fuse.S_IFDIR, 0) // 0 means no entries
}
開發者ID:Richardphp,項目名稱:noms,代碼行數:15,代碼來源:basics_test.go

示例3: TestDirError

func (s *fuseTestSuite) TestDirError() {
	datasetName := "TestDirError"
	str := spec.CreateValueSpecString("ldb", s.LdbDir, datasetName)

	var testfs pathfs.FileSystem

	start(str, func(fs pathfs.FileSystem) { testfs = fs })

	code := testfs.Mkdir("foo/bar", 0755, nil)
	assert.Equal(s.T(), fuse.ENOENT, code)
	_, code = testfs.Create("foo", uint32(os.O_CREATE)|uint32(os.O_WRONLY), 0644, nil)
	assert.Equal(s.T(), fuse.OK, code)
	code = testfs.Mkdir("foo/bar", 0755, nil)
	assert.Equal(s.T(), fuse.ENOTDIR, code)

	_, code = testfs.OpenDir("foo", nil)
	assert.Equal(s.T(), fuse.ENOTDIR, code)
}
開發者ID:Richardphp,項目名稱:noms,代碼行數:18,代碼來源:dir_test.go

示例4: TestFileInDir

func (s *fuseTestSuite) TestFileInDir() {
	datasetName := "TestFile"
	str := spec.CreateValueSpecString("ldb", s.LdbDir, datasetName)

	var testfs pathfs.FileSystem

	start(str, func(fs pathfs.FileSystem) { testfs = fs })

	code := testfs.Mkdir("usr", 0555, nil)
	assert.Equal(s.T(), fuse.OK, code)
	code = testfs.Mkdir("usr/sbin", 0555, nil)
	assert.Equal(s.T(), fuse.OK, code)
	_, code = testfs.Create("usr/sbin/dtrace", uint32(os.O_CREATE)|uint32(os.O_WRONLY), 0555, nil)
	assert.Equal(s.T(), fuse.OK, code)
	assertAttr(s, testfs, "usr", 0555|fuse.S_IFDIR, 1)
	assertAttr(s, testfs, "usr/sbin", 0555|fuse.S_IFDIR, 1)
	assertAttr(s, testfs, "usr/sbin/dtrace", 0555|fuse.S_IFREG, 0)
}
開發者ID:Richardphp,項目名稱:noms,代碼行數:18,代碼來源:basics_test.go

示例5: TestHierarchy

func (s *fuseTestSuite) TestHierarchy() {
	datasetName := "TestHierarchy"
	str := spec.CreateValueSpecString("ldb", s.LdbDir, datasetName)

	var testfs pathfs.FileSystem

	start(str, func(fs pathfs.FileSystem) { testfs = fs })

	hierarchy := []string{
		"bin/",
		"bin/sh",
		"usr/",
		"usr/bin/",
		"usr/bin/cat",
		"usr/bin/bash",
		"usr/lib/",
		"usr/lib/libc.so.1",
		"usr/dict/",
		"usr/dict/words",
		"usr/dict/words2",
	}

	for _, path := range hierarchy {
		if ll := len(path); path[ll-1] == '/' {
			code := testfs.Mkdir(path[:ll-1], 0555, nil)
			assert.Equal(s.T(), fuse.OK, code)
		} else {
			_, code := testfs.Create(path, uint32(os.O_CREATE)|uint32(os.O_WRONLY), 0444, nil)
			assert.Equal(s.T(), fuse.OK, code)
		}
	}

	h := find(testfs)

	sort.Strings(hierarchy)
	sort.Strings(h)

	assert.Equal(s.T(), hierarchy, h)
}
開發者ID:Richardphp,項目名稱:noms,代碼行數:39,代碼來源:dir_test.go

示例6: TestRenameWhileOpen

func (s *fuseTestSuite) TestRenameWhileOpen() {
	datasetName := "TestRenameWhileOpen"
	str := spec.CreateValueSpecString("ldb", s.LdbDir, datasetName)

	var testfs pathfs.FileSystem

	start(str, func(fs pathfs.FileSystem) { testfs = fs })

	code := testfs.Mkdir("foo", 0755, nil)
	assert.Equal(s.T(), fuse.OK, code)
	code = testfs.Mkdir("foo/bar", 0755, nil)
	assert.Equal(s.T(), fuse.OK, code)
	file, code := testfs.Create("foo/bar/file.txt", uint32(os.O_CREATE)|uint32(os.O_WRONLY), 0644, nil)
	assert.Equal(s.T(), fuse.OK, code)

	// Validate renaming a file between opening it and writing to it.
	code = testfs.Rename("foo/bar/file.txt", "file.txt", nil)
	assert.Equal(s.T(), fuse.OK, code)

	n, code := file.Write([]byte("howdy!"), 0)
	assert.Equal(s.T(), uint32(6), n)
	assert.Equal(s.T(), fuse.OK, code)
	assertAttr(s, testfs, "file.txt", 0644|fuse.S_IFREG, 6)
}
開發者ID:Richardphp,項目名稱:noms,代碼行數:24,代碼來源:dir_test.go


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