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


Golang pathfs.FileSystem類代碼示例

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


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

示例1: TestSimpleFile

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

	var testfs pathfs.FileSystem

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

	file, code := testfs.Create("coconut", uint32(os.O_CREATE|os.O_RDWR), 0644, nil)
	assert.Equal(s.T(), fuse.OK, code)
	n, code := file.Write([]byte("Lime!"), 0)
	assert.Equal(s.T(), uint32(5), n)
	assertAttr(s, testfs, "coconut", 0644|fuse.S_IFREG, 5)

	data := make([]byte, 5)
	rr, code := file.Read(data, 0)
	assert.Equal(s.T(), fuse.OK, code)
	assert.Equal(s.T(), 5, rr.Size())
	assert.Equal(s.T(), "Lime!", string(data))

	code = testfs.Truncate("coconut", 4, nil)
	assert.Equal(s.T(), fuse.OK, code)
	assertAttr(s, testfs, "coconut", 0644|fuse.S_IFREG, 4)
	rr, code = file.Read(data, 0)
	assert.Equal(s.T(), fuse.OK, code)
	assert.Equal(s.T(), 4, rr.Size())
	assert.Equal(s.T(), "Lime!", string(data))
}
開發者ID:Richardphp,項目名稱:noms,代碼行數:28,代碼來源:rw_test.go

示例2: getAttr

func getAttr(fs pathfs.FileSystem, name string) *attrResponse {
	a, code := fs.GetAttr(name, nil)
	return &attrResponse{
		Attr:   a,
		Status: code,
	}
}
開發者ID:rfjakob,項目名稱:go-fuse,代碼行數:7,代碼來源:cachingfs.go

示例3: readLink

func readLink(fs pathfs.FileSystem, name string) *linkResponse {
	a, code := fs.Readlink(name, nil)
	return &linkResponse{
		linkContent: a,
		Status:      code,
	}
}
開發者ID:rfjakob,項目名稱:go-fuse,代碼行數:7,代碼來源:cachingfs.go

示例4: getXAttr

func getXAttr(fs pathfs.FileSystem, nameAttr string) *xattrResponse {
	ns := strings.SplitN(nameAttr, _XATTRSEP, 2)
	a, code := fs.GetXAttr(ns[0], ns[1], nil)
	return &xattrResponse{
		data:   a,
		Status: code,
	}
}
開發者ID:rfjakob,項目名稱:go-fuse,代碼行數:8,代碼來源:cachingfs.go

示例5: assertAttr

func assertAttr(s *fuseTestSuite, fs pathfs.FileSystem, path string, mode uint32, size uint64) {
	attr, code := fs.GetAttr(path, nil)
	assert.Equal(s.T(), fuse.OK, code)
	if code == fuse.OK {
		assert.Equal(s.T(), mode, attr.Mode)
		assert.Equal(s.T(), size, attr.Size)
	}
}
開發者ID:Richardphp,項目名稱:noms,代碼行數:8,代碼來源:basics_test.go

示例6: readDir

func readDir(fs pathfs.FileSystem, name string) *dirResponse {
	origStream, code := fs.OpenDir(name, nil)

	r := &dirResponse{nil, code}
	if !code.Ok() {
		return r
	}
	r.entries = origStream
	return r
}
開發者ID:rfjakob,項目名稱:go-fuse,代碼行數:10,代碼來源:cachingfs.go

示例7: TestFile

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

	var testfs pathfs.FileSystem

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

	_, code := testfs.Create("pokemon.go", uint32(os.O_CREATE)|uint32(os.O_WRONLY), 0644, nil)
	assert.Equal(s.T(), fuse.OK, code)
	assertAttr(s, testfs, "pokemon.go", 0644|fuse.S_IFREG, 0)
}
開發者ID:Richardphp,項目名稱:noms,代碼行數:12,代碼來源:basics_test.go

示例8: 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

示例9: TestSymlink

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

	var testfs pathfs.FileSystem

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

	code := testfs.Symlink("there", "here", nil)
	assert.Equal(s.T(), fuse.OK, code)
	assertAttr(s, testfs, "here", 0755|fuse.S_IFLNK, 0)
	value, code := testfs.Readlink("here", nil)
	assert.Equal(s.T(), fuse.OK, code)
	assert.Equal(s.T(), "there", value)
}
開發者ID:Richardphp,項目名稱:noms,代碼行數:15,代碼來源:basics_test.go

示例10: TestUnlink

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

	var testfs pathfs.FileSystem

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

	_, code := testfs.Create("dilma", uint32(os.O_CREATE)|uint32(os.O_WRONLY), 0755, nil)
	assert.Equal(s.T(), fuse.OK, code)
	assertAttr(s, testfs, "", 0777|fuse.S_IFDIR, 1) // 1 means it's there
	code = testfs.Unlink("dilma", 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

示例11: 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

示例12: findDir

func findDir(fs pathfs.FileSystem, path string, delimiter string) []string {
	ents, _ := fs.OpenDir(path, nil)
	ret := make([]string, 0)
	for _, ent := range ents {
		child := path + delimiter + ent.Name
		attr, _ := fs.GetAttr(child, nil)
		if attr.Mode&fuse.S_IFDIR != 0 {
			ret = append(ret, child+"/")
			ret = append(ret, findDir(fs, child, "/")...)
		} else {
			ret = append(ret, child)
		}
	}

	return ret
}
開發者ID:Richardphp,項目名稱:noms,代碼行數:16,代碼來源:dir_test.go

示例13: NewMemUnionFs

// NewMemUnionFs instantiates a new union file system.  Calling this
// will access the root of the supplied R/O filesystem.
func NewMemUnionFs(backingStore string, roFs pathfs.FileSystem) (*MemUnionFs, error) {
	me := &MemUnionFs{
		deleted:      make(map[string]bool),
		backingStore: backingStore,
		readonly:     roFs,
	}

	me.root = me.newNode(true)
	fi, code := roFs.GetAttr("", nil)
	if !code.Ok() {
		return nil, fmt.Errorf("GetAttr(\"\") for R/O returned %v", code)
	}

	me.root.info = *fi
	me.cond = sync.NewCond(&me.mutex)

	return me, nil
}
開發者ID:hanwen,項目名稱:termite,代碼行數:20,代碼來源:memunionfs.go

示例14: newDirnameMap

// newDirnameMap reads the contents of the given directory. On error,
// returns a nil map. This forces reloads in the dirCache until we
// succeed.
func newDirnameMap(fs pathfs.FileSystem, dir string) map[string]bool {
	stream, code := fs.OpenDir(dir, nil)
	if code == fuse.ENOENT {
		// The directory not existing is not an error.
		return map[string]bool{}
	}

	if !code.Ok() {
		return nil
	}

	result := make(map[string]bool)
	for _, e := range stream {
		if e.Mode&fuse.S_IFREG != 0 {
			result[e.Name] = true
		}
	}
	return result
}
開發者ID:Richardphp,項目名稱:noms,代碼行數:22,代碼來源:dircache.go

示例15: 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


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