本文整理汇总了Golang中github.com/jacobsa/fuse/fusetesting.ReadDirPicky函数的典型用法代码示例。如果您正苦于以下问题:Golang ReadDirPicky函数的具体用法?Golang ReadDirPicky怎么用?Golang ReadDirPicky使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ReadDirPicky函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Rmdir_Empty
func (t *ImplicitDirsTest) Rmdir_Empty() {
var err error
var entries []os.FileInfo
// Create two levels of directories. We can't make an empty implicit dir, so
// there must be a backing object for each.
AssertEq(
nil,
t.createObjects(
map[string]string{
"foo/": "",
"foo/bar/": "",
}))
// Remove the leaf.
err = os.Remove(path.Join(t.Dir, "foo/bar"))
AssertEq(nil, err)
// There should be nothing left in the parent.
entries, err = fusetesting.ReadDirPicky(path.Join(t.Dir, "foo"))
AssertEq(nil, err)
ExpectThat(entries, ElementsAre())
// Remove the parent.
err = os.Remove(path.Join(t.Dir, "foo"))
AssertEq(nil, err)
// Now the root directory should be empty, too.
entries, err = fusetesting.ReadDirPicky(t.Dir)
AssertEq(nil, err)
ExpectThat(entries, ElementsAre())
}
开发者ID:mbookman,项目名称:gcsfuse,代码行数:34,代码来源:implicit_dirs_test.go
示例2: ReadDir_EmptySubDirectory
func (t *ForeignModsTest) ReadDir_EmptySubDirectory() {
// Set up an empty directory placeholder called 'bar'.
AssertEq(nil, t.createEmptyObjects([]string{"bar/"}))
// ReadDir
entries, err := fusetesting.ReadDirPicky(t.mfs.Dir())
AssertEq(nil, err)
AssertEq(1, len(entries))
entries, err = fusetesting.ReadDirPicky(path.Join(t.mfs.Dir(), "bar"))
AssertEq(nil, err)
ExpectThat(entries, ElementsAre())
}
开发者ID:horzadome,项目名称:gcsfuse,代码行数:14,代码来源:foreign_modifications_test.go
示例3: ReadDir_EmptyRoot
func (t *ForeignModsTest) ReadDir_EmptyRoot() {
// ReadDir
entries, err := fusetesting.ReadDirPicky(t.mfs.Dir())
AssertEq(nil, err)
ExpectThat(entries, ElementsAre())
}
开发者ID:horzadome,项目名称:gcsfuse,代码行数:7,代码来源:foreign_modifications_test.go
示例4: EmptyBucket
func (t *CachingTest) EmptyBucket() {
// ReadDir
entries, err := fusetesting.ReadDirPicky(t.Dir)
AssertEq(nil, err)
ExpectThat(entries, ElementsAre())
}
开发者ID:mbookman,项目名称:gcsfuse,代码行数:7,代码来源:caching_test.go
示例5: Inodes
func (t *ForeignModsTest) Inodes() {
// Set up two files and a directory placeholder.
AssertEq(
nil,
t.createEmptyObjects([]string{
"foo",
"bar/",
"baz",
}))
// List.
entries, err := fusetesting.ReadDirPicky(t.mfs.Dir())
AssertEq(nil, err)
AssertEq(3, len(entries), "Names: %v", getFileNames(entries))
// Confirm all of the inodes are distinct.
inodesSeen := make(map[uint64]struct{})
for _, fileInfo := range entries {
stat := fileInfo.Sys().(*syscall.Stat_t)
_, ok := inodesSeen[stat.Ino]
AssertFalse(
ok,
"Duplicate inode (%v). File info: %v",
stat.Ino,
fileInfo)
inodesSeen[stat.Ino] = struct{}{}
}
}
开发者ID:horzadome,项目名称:gcsfuse,代码行数:30,代码来源:foreign_modifications_test.go
示例6: OnlyDir_WithImplicitDir
func (t *GcsfuseTest) OnlyDir_WithImplicitDir() {
var err error
var fi os.FileInfo
// Mount only a single implicit directory from the bucket.
args := []string{
"--only-dir",
path.Dir(canned.ImplicitDirFile),
canned.FakeBucketName,
t.dir,
}
err = t.runGcsfuse(args)
AssertEq(nil, err)
defer unmount(t.dir)
// It should be as if t.dir points into the implicit directory
entries, err := fusetesting.ReadDirPicky(t.dir)
AssertEq(nil, err)
AssertEq(1, len(entries))
fi = entries[0]
ExpectEq(path.Base(canned.ImplicitDirFile), fi.Name())
ExpectEq(len(canned.ImplicitDirFile_Contents), fi.Size())
}
开发者ID:zfo,项目名称:gcsfuse,代码行数:25,代码来源:gcsfuse_test.go
示例7: ReadBeyondEndOfFile
func (t *ForeignModsTest) ReadBeyondEndOfFile() {
const contents = "tacoburritoenchilada"
const contentLen = len(contents)
// Create an object.
AssertEq(nil, t.createWithContents("foo", contents))
// Wait for it to show up in the file system.
_, err := fusetesting.ReadDirPicky(t.mfs.Dir())
AssertEq(nil, err)
// Attempt to open it.
f, err := os.Open(path.Join(t.mfs.Dir(), "foo"))
AssertEq(nil, err)
defer func() { AssertEq(nil, f.Close()) }()
// Attempt to read beyond the end of the file.
_, err = f.Seek(int64(contentLen-1), 0)
AssertEq(nil, err)
buf := make([]byte, 2)
n, err := f.Read(buf)
AssertEq(1, n, "err: %v", err)
AssertEq(contents[contentLen-1], buf[0])
if err == nil {
n, err = f.Read(buf)
AssertEq(0, n)
}
}
开发者ID:horzadome,项目名称:gcsfuse,代码行数:30,代码来源:foreign_modifications_test.go
示例8: OnlyDir_TrailingSlash
func (t *GcsfuseTest) OnlyDir_TrailingSlash() {
var err error
var fi os.FileInfo
// Mount only a single directory from the bucket, including a trailing slash.
args := []string{
"--only-dir",
path.Dir(canned.ExplicitDirFile) + "/",
canned.FakeBucketName,
t.dir,
}
err = t.runGcsfuse(args)
AssertEq(nil, err)
defer unmount(t.dir)
// It should be as if t.dir points into the bucket's first-level directory.
entries, err := fusetesting.ReadDirPicky(t.dir)
AssertEq(nil, err)
AssertEq(1, len(entries))
fi = entries[0]
ExpectEq(path.Base(canned.ExplicitDirFile), fi.Name())
ExpectEq(len(canned.ExplicitDirFile_Contents), fi.Size())
}
开发者ID:zfo,项目名称:gcsfuse,代码行数:25,代码来源:gcsfuse_test.go
示例9: DirectoryObjectPresent
func (t *ImplicitDirsTest) DirectoryObjectPresent() {
var fi os.FileInfo
var entries []os.FileInfo
var err error
// Set up contents.
AssertEq(
nil,
t.createObjects(
map[string]string{
// Directory
"foo/": "",
}))
// Statting the name should return an entry for the directory.
fi, err = os.Stat(path.Join(t.mfs.Dir(), "foo"))
AssertEq(nil, err)
ExpectEq("foo", fi.Name())
ExpectTrue(fi.IsDir())
// ReadDir should show the directory.
entries, err = fusetesting.ReadDirPicky(t.mfs.Dir())
AssertEq(nil, err)
AssertEq(1, len(entries))
fi = entries[0]
ExpectEq("foo", fi.Name())
ExpectTrue(fi.IsDir())
}
开发者ID:mbookman,项目名称:gcsfuse,代码行数:30,代码来源:implicit_dirs_test.go
示例10: NothingPresent
func (t *ImplicitDirsTest) NothingPresent() {
// ReadDir
entries, err := fusetesting.ReadDirPicky(t.mfs.Dir())
AssertEq(nil, err)
ExpectThat(entries, ElementsAre())
}
开发者ID:mbookman,项目名称:gcsfuse,代码行数:7,代码来源:implicit_dirs_test.go
示例11: ReadDir_ContentsInRoot
func (t *ForeignModsTest) ReadDir_ContentsInRoot() {
// Set up contents.
createTime := t.mtimeClock.Now()
AssertEq(
nil,
t.createObjects(
map[string]string{
// File
"foo": "taco",
// Directory
"bar/": "",
// File
"baz": "burrito",
}))
/////////////////////////
// ReadDir
/////////////////////////
entries, err := fusetesting.ReadDirPicky(t.mfs.Dir())
AssertEq(nil, err)
AssertEq(3, len(entries), "Names: %v", getFileNames(entries))
var e os.FileInfo
// bar
e = entries[0]
ExpectEq("bar", e.Name())
ExpectEq(0, e.Size())
ExpectEq(dirPerms|os.ModeDir, e.Mode())
ExpectTrue(e.IsDir())
ExpectEq(1, e.Sys().(*syscall.Stat_t).Nlink)
ExpectEq(currentUid(), e.Sys().(*syscall.Stat_t).Uid)
ExpectEq(currentGid(), e.Sys().(*syscall.Stat_t).Gid)
// baz
e = entries[1]
ExpectEq("baz", e.Name())
ExpectEq(len("burrito"), e.Size())
ExpectEq(filePerms, e.Mode())
ExpectThat(e, fusetesting.MtimeIsWithin(createTime, timeSlop))
ExpectFalse(e.IsDir())
ExpectEq(1, e.Sys().(*syscall.Stat_t).Nlink)
ExpectEq(currentUid(), e.Sys().(*syscall.Stat_t).Uid)
ExpectEq(currentGid(), e.Sys().(*syscall.Stat_t).Gid)
// foo
e = entries[2]
ExpectEq("foo", e.Name())
ExpectEq(len("taco"), e.Size())
ExpectEq(filePerms, e.Mode())
ExpectThat(e, fusetesting.MtimeIsWithin(createTime, timeSlop))
ExpectFalse(e.IsDir())
ExpectEq(1, e.Sys().(*syscall.Stat_t).Nlink)
ExpectEq(currentUid(), e.Sys().(*syscall.Stat_t).Uid)
ExpectEq(currentGid(), e.Sys().(*syscall.Stat_t).Gid)
}
开发者ID:horzadome,项目名称:gcsfuse,代码行数:59,代码来源:foreign_modifications_test.go
示例12: ConflictingNames_OneIsSymlink
func (t *ImplicitDirsTest) ConflictingNames_OneIsSymlink() {
var fi os.FileInfo
var entries []os.FileInfo
var err error
// Set up contents.
AssertEq(
nil,
t.createObjects(
map[string]string{
// Symlink
"foo": "",
// Directory
"foo/": "",
}))
// Cause "foo" to look like a symlink.
err = setSymlinkTarget(t.ctx, t.bucket, "foo", "")
AssertEq(nil, err)
// A listing of the parent should contain a directory named "foo" and a
// symlink named "foo\n".
entries, err = fusetesting.ReadDirPicky(t.mfs.Dir())
AssertEq(nil, err)
AssertEq(2, len(entries))
fi = entries[0]
ExpectEq("foo", fi.Name())
ExpectEq(0, fi.Size())
ExpectEq(dirPerms|os.ModeDir, fi.Mode())
ExpectTrue(fi.IsDir())
ExpectEq(1, fi.Sys().(*syscall.Stat_t).Nlink)
fi = entries[1]
ExpectEq("foo\n", fi.Name())
ExpectEq(0, fi.Size())
ExpectEq(filePerms|os.ModeSymlink, fi.Mode())
ExpectFalse(fi.IsDir())
ExpectEq(1, fi.Sys().(*syscall.Stat_t).Nlink)
// Statting "foo" should yield the directory.
fi, err = os.Lstat(path.Join(t.mfs.Dir(), "foo"))
AssertEq(nil, err)
ExpectEq("foo", fi.Name())
ExpectTrue(fi.IsDir())
// Statting "foo\n" should yield the symlink.
fi, err = os.Lstat(path.Join(t.mfs.Dir(), "foo\n"))
AssertEq(nil, err)
ExpectEq("foo\n", fi.Name())
ExpectEq(filePerms|os.ModeSymlink, fi.Mode())
}
开发者ID:mbookman,项目名称:gcsfuse,代码行数:55,代码来源:implicit_dirs_test.go
示例13: ConflictingNames_PlaceholderNotPresent
func (t *ImplicitDirsTest) ConflictingNames_PlaceholderNotPresent() {
var fi os.FileInfo
var entries []os.FileInfo
var err error
// Set up contents.
AssertEq(
nil,
t.createObjects(
map[string]string{
// File
"foo": "taco",
// Implicit directory
"foo/bar": "",
}))
// A listing of the parent should contain a directory named "foo" and a
// file named "foo\n".
entries, err = fusetesting.ReadDirPicky(t.mfs.Dir())
AssertEq(nil, err)
AssertEq(2, len(entries))
fi = entries[0]
ExpectEq("foo", fi.Name())
ExpectEq(0, fi.Size())
ExpectEq(dirPerms|os.ModeDir, fi.Mode())
ExpectTrue(fi.IsDir())
fi = entries[1]
ExpectEq("foo\n", fi.Name())
ExpectEq(len("taco"), fi.Size())
ExpectEq(len("taco"), fi.Size())
ExpectEq(filePerms, fi.Mode())
ExpectFalse(fi.IsDir())
ExpectEq(1, fi.Sys().(*syscall.Stat_t).Nlink)
// Statting "foo" should yield the directory.
fi, err = os.Stat(path.Join(t.mfs.Dir(), "foo"))
AssertEq(nil, err)
ExpectEq("foo", fi.Name())
ExpectTrue(fi.IsDir())
// Statting "foo\n" should yield the file.
fi, err = os.Stat(path.Join(t.mfs.Dir(), "foo\n"))
AssertEq(nil, err)
ExpectEq("foo\n", fi.Name())
ExpectEq(len("taco"), fi.Size())
ExpectFalse(fi.IsDir())
}
开发者ID:mbookman,项目名称:gcsfuse,代码行数:52,代码来源:implicit_dirs_test.go
示例14: ReadDir_Dir
func (t *HelloFSTest) ReadDir_Dir() {
entries, err := fusetesting.ReadDirPicky(path.Join(t.Dir, "dir"))
AssertEq(nil, err)
AssertEq(1, len(entries))
var fi os.FileInfo
// world
fi = entries[0]
ExpectEq("world", fi.Name())
ExpectEq(len("Hello, world!"), fi.Size())
ExpectEq(0444, fi.Mode())
ExpectEq(0, t.Clock.Now().Sub(fi.ModTime()), "ModTime: %v", fi.ModTime())
ExpectFalse(fi.IsDir())
}
开发者ID:andrewgaul,项目名称:fuse,代码行数:15,代码来源:hello_fs_test.go
示例15: ReadFromFile_Large
func (t *ForeignModsTest) ReadFromFile_Large() {
const contentLen = 1 << 20
contents := randString(contentLen)
// Create an object.
AssertEq(nil, t.createWithContents("foo", contents))
// Wait for it to show up in the file system.
_, err := fusetesting.ReadDirPicky(t.mfs.Dir())
AssertEq(nil, err)
// Attempt to open it.
f, err := os.Open(path.Join(t.mfs.Dir(), "foo"))
AssertEq(nil, err)
defer func() { AssertEq(nil, f.Close()) }()
// Read its entire contents.
slice, err := ioutil.ReadAll(f)
AssertEq(nil, err)
if contents != string(slice) {
ExpectTrue(
false,
"Expected:\n%v\n\nActual:\n%v",
hex.Dump([]byte(contents)),
hex.Dump(slice))
}
// Read from parts of it.
referenceReader := strings.NewReader(contents)
for trial := 0; trial < 1000; trial++ {
offset := rand.Int63n(contentLen + 1)
size := rand.Intn(int(contentLen - offset))
expected, err := readRange(referenceReader, offset, size)
AssertEq(nil, err)
actual, err := readRange(f, offset, size)
AssertEq(nil, err)
if expected != actual {
AssertTrue(
expected == actual,
"Expected:\n%s\nActual:\n%s",
hex.Dump([]byte(expected)),
hex.Dump([]byte(actual)))
}
}
}
开发者ID:mbookman,项目名称:gcsfuse,代码行数:48,代码来源:foreign_modifications_test.go
示例16: ReadRoot
func (t *ReadOnlyTest) ReadRoot() {
var fi os.FileInfo
// Read.
entries, err := fusetesting.ReadDirPicky(t.Dir)
AssertEq(nil, err)
AssertEq(2, len(entries))
// bar
fi = entries[0]
ExpectEq("bar", fi.Name())
ExpectEq(os.FileMode(0777)|os.ModeDir, fi.Mode())
// foo
fi = entries[1]
ExpectEq("foo", fi.Name())
ExpectEq(os.FileMode(0777), fi.Mode())
}
开发者ID:andrewgaul,项目名称:fuse,代码行数:18,代码来源:flush_fs_test.go
示例17: FileCreatedRemotely
func (t *CachingTest) FileCreatedRemotely() {
const name = "foo"
const contents = "taco"
var fi os.FileInfo
// Create an object in GCS.
_, err := gcsutil.CreateObject(
t.ctx,
t.uncachedBucket,
name,
contents)
AssertEq(nil, err)
// It should immediately show up in a listing.
entries, err := fusetesting.ReadDirPicky(t.Dir)
AssertEq(nil, err)
AssertEq(1, len(entries))
fi = entries[0]
ExpectEq(name, fi.Name())
ExpectEq(len(contents), fi.Size())
// And we should be able to stat it.
fi, err = os.Stat(path.Join(t.Dir, name))
AssertEq(nil, err)
ExpectEq(name, fi.Name())
ExpectEq(len(contents), fi.Size())
// And read it.
b, err := ioutil.ReadFile(path.Join(t.Dir, name))
AssertEq(nil, err)
ExpectEq(contents, string(b))
// And overwrite it, and read it back again.
err = ioutil.WriteFile(path.Join(t.Dir, name), []byte("burrito"), 0500)
AssertEq(nil, err)
b, err = ioutil.ReadFile(path.Join(t.Dir, name))
AssertEq(nil, err)
ExpectEq("burrito", string(b))
}
开发者ID:mbookman,项目名称:gcsfuse,代码行数:44,代码来源:caching_test.go
示例18: UnreachableObjects
func (t *ForeignModsTest) UnreachableObjects() {
var fi os.FileInfo
var err error
// Set up objects that appear to be directory contents, but for which there
// is no directory placeholder object. We don't have implicit directories
// enabled, so these should be unreachable.
err = gcsutil.CreateEmptyObjects(
t.ctx,
t.bucket,
[]string{
// Implicit directory contents, conflicting file name.
"foo",
"foo/0",
"foo/1",
// Implicit directory contents, no conflicting file name.
"bar/0/",
})
AssertEq(nil, err)
// Only the conflicitng file name should show up in the root.
entries, err := fusetesting.ReadDirPicky(t.Dir)
AssertEq(nil, err)
AssertEq(1, len(entries))
fi = entries[0]
ExpectEq("foo", fi.Name())
ExpectEq(filePerms, fi.Mode())
ExpectEq(1, fi.Sys().(*syscall.Stat_t).Nlink)
// Statting the conflicting name should give the file.
fi, err = os.Stat(path.Join(t.mfs.Dir(), "foo"))
AssertEq(nil, err)
ExpectEq("foo", fi.Name())
ExpectEq(filePerms, fi.Mode())
ExpectEq(1, fi.Sys().(*syscall.Stat_t).Nlink)
// Statting the other name shouldn't work at all.
_, err = os.Stat(path.Join(t.mfs.Dir(), "bar"))
ExpectTrue(os.IsNotExist(err), "err: %v", err)
}
开发者ID:horzadome,项目名称:gcsfuse,代码行数:44,代码来源:foreign_modifications_test.go
示例19: ReadDir_Root
func (t *HelloFSTest) ReadDir_Root() {
entries, err := fusetesting.ReadDirPicky(t.Dir)
AssertEq(nil, err)
AssertEq(2, len(entries))
var fi os.FileInfo
// dir
fi = entries[0]
ExpectEq("dir", fi.Name())
ExpectEq(0, fi.Size())
ExpectEq(os.ModeDir|0555, fi.Mode())
ExpectEq(0, t.Clock.Now().Sub(fi.ModTime()), "ModTime: %v", fi.ModTime())
ExpectTrue(fi.IsDir())
// hello
fi = entries[1]
ExpectEq("hello", fi.Name())
ExpectEq(len("Hello, world!"), fi.Size())
ExpectEq(0444, fi.Mode())
ExpectEq(0, t.Clock.Now().Sub(fi.ModTime()), "ModTime: %v", fi.ModTime())
ExpectFalse(fi.IsDir())
}
开发者ID:andrewgaul,项目名称:fuse,代码行数:23,代码来源:hello_fs_test.go
注:本文中的github.com/jacobsa/fuse/fusetesting.ReadDirPicky函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论