本文整理匯總了Golang中github.com/hanwen/go-fuse/fuse.DirEntry.Mode方法的典型用法代碼示例。如果您正苦於以下問題:Golang DirEntry.Mode方法的具體用法?Golang DirEntry.Mode怎麽用?Golang DirEntry.Mode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/hanwen/go-fuse/fuse.DirEntry
的用法示例。
在下文中一共展示了DirEntry.Mode方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: OpenDir
func (gf *GistFs) OpenDir(n string, c *fuse.Context) ([]fuse.DirEntry, fuse.Status) {
dirs := make([]fuse.DirEntry, 0)
if gf.files != nil && n == "" {
for _, f := range gf.files {
d := fuse.DirEntry{Name: f.Name, Mode: fuse.S_IFREG | 0440}
if f.isDir {
d.Mode = fuse.S_IFDIR | 0550
}
dirs = append(dirs, d)
}
return dirs, fuse.OK
}
gf.files = make(map[string]File)
u := gf.user
if n != "" {
u = n
}
gists, err := getGists(u)
if err != nil {
log.Println(err)
return nil, fuse.ENOENT
}
for _, g := range gists {
for _, f := range g.Files {
gf.files[n+f.Name] = f
dirs = append(dirs, fuse.DirEntry{Name: f.Name, Mode: fuse.S_IFREG | 0440})
}
}
return dirs, fuse.OK
}
示例2: OpenDir
func (fs *loopbackFileSystem) OpenDir(name string, context *fuse.Context) (stream []fuse.DirEntry, status fuse.Status) {
// What other ways beyond O_RDONLY are there to open
// directories?
f, err := os.Open(fs.GetPath(name))
if err != nil {
return nil, fuse.ToStatus(err)
}
want := 500
output := make([]fuse.DirEntry, 0, want)
for {
infos, err := f.Readdir(want)
for i := range infos {
n := infos[i].Name()
d := fuse.DirEntry{
Name: n,
}
if s := fuse.ToStatT(infos[i]); s != nil {
d.Mode = uint32(s.Mode)
} else {
log.Printf("ReadDir entry %q for %q has no stat info", n, name)
}
output = append(output, d)
}
if len(infos) < want || err == io.EOF {
break
}
if err != nil {
log.Println("Readdir() returned err:", err)
break
}
}
f.Close()
return output, fuse.OK
}
示例3: OpenDir
func (fs *MultiZipFs) OpenDir(name string, context *fuse.Context) (stream []fuse.DirEntry, code fuse.Status) {
fs.lock.RLock()
defer fs.lock.RUnlock()
stream = make([]fuse.DirEntry, 0, len(fs.zips)+2)
if name == "" {
var d fuse.DirEntry
d.Name = "config"
d.Mode = fuse.S_IFDIR | 0700
stream = append(stream, fuse.DirEntry(d))
}
if name == "config" {
for k := range fs.zips {
var d fuse.DirEntry
d.Name = k
d.Mode = fuse.S_IFLNK
stream = append(stream, fuse.DirEntry(d))
}
}
return stream, fuse.OK
}
示例4: OpenDir
func (me *MultiZipFs) OpenDir(name string) (stream chan fuse.DirEntry, code fuse.Status) {
me.lock.RLock()
defer me.lock.RUnlock()
// We don't use a goroutine, since we don't want to hold the
// lock.
stream = make(chan fuse.DirEntry,
len(me.pendingZips)+len(me.zips)+2)
submode := uint32(fuse.S_IFDIR | 0700)
if name == "config" {
submode = fuse.S_IFREG | 0600
}
for k, _ := range me.zips {
var d fuse.DirEntry
d.Name = k
d.Mode = submode
stream <- fuse.DirEntry(d)
}
for k, _ := range me.pendingZips {
var d fuse.DirEntry
d.Name = k
d.Mode = submode
stream <- fuse.DirEntry(d)
}
if name == "" {
var d fuse.DirEntry
d.Name = "config"
d.Mode = fuse.S_IFDIR | 0700
stream <- fuse.DirEntry(d)
}
close(stream)
return stream, fuse.OK
}
示例5: OpenDir
func (me *MultiZipFs) OpenDir(name string, context *fuse.Context) (stream chan fuse.DirEntry, code fuse.Status) {
me.lock.RLock()
defer me.lock.RUnlock()
stream = make(chan fuse.DirEntry, len(me.zips)+2)
if name == "" {
var d fuse.DirEntry
d.Name = "config"
d.Mode = fuse.S_IFDIR | 0700
stream <- fuse.DirEntry(d)
}
if name == "config" {
for k, _ := range me.zips {
var d fuse.DirEntry
d.Name = k
d.Mode = fuse.S_IFLNK
stream <- fuse.DirEntry(d)
}
}
close(stream)
return stream, fuse.OK
}
示例6: OpenDir
func (fs *KakigooriFileSystem) OpenDir(name string, context *fuse.Context) (stream []fuse.DirEntry, status fuse.Status) {
fullPath := fs.GetPath(name)
f, err := os.Open(fullPath)
if err != nil {
return nil, fuse.ToStatus(err)
}
want := 500
output := make([]fuse.DirEntry, 0, want)
for {
infos, err := f.Readdir(want)
for i := range infos {
// workaround for https://code.google.com/p/go/issues/detail?id=5960
if infos[i] == nil {
continue
}
n := infos[i].Name()
d := fuse.DirEntry{
Name: n,
}
if s := fuse.ToStatT(infos[i]); s != nil {
d.Mode = uint32(s.Mode)
} else {
log.Printf("ReadDir entry %q for %q has no stat info", n, name)
}
output = append(output, d)
}
if len(infos) < want || err == io.EOF {
break
}
if err != nil {
log.Println("Readdir() returned err:", err)
break
}
}
f.Close()
go event.Notify(event.OpenDir, fullPath)
return output, fuse.OK
}