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


Golang Attr.Size方法代碼示例

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


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

示例1: GetAttr

func (n *fileNode) GetAttr(out *fuse.Attr, file fuse.File, context *fuse.Context) (code fuse.Status) {
	if file != nil {
		return file.GetAttr(out)
	}

	out.Mode = fuse.S_IFREG | 0644
	f := n.File()
	if n.backing != "" {
		fi, err := os.Stat(n.backing)
		if err != nil {
			return fuse.ToStatus(err)
		}
		out.Size = uint64(fi.Size())
		t := f.Mtime()
		if n.dirty {
			t = fi.ModTime()
		}
		out.SetTimes(&t, &t, &t)
	} else if f != nil {
		out.Size = uint64(f.filesize)

		t := f.Mtime()
		out.SetTimes(&t, &t, &t)
	}

	return fuse.OK
}
開發者ID:thomasf,項目名稱:go-mtpfs,代碼行數:27,代碼來源:fs.go

示例2: HeaderToFileInfo

func HeaderToFileInfo(out *fuse.Attr, h *tar.Header) {
	out.Mode = uint32(h.Mode)
	out.Size = uint64(h.Size)
	out.Uid = uint32(h.Uid)
	out.Gid = uint32(h.Gid)
	out.SetTimes(&h.AccessTime, &h.ModTime, &h.ChangeTime)
}
開發者ID:niltonkummer,項目名稱:go-fuse,代碼行數:7,代碼來源:tarfs.go

示例3: GetAttr

func (n *nodeReadNode) GetAttr(out *fuse.Attr, file File, context *fuse.Context) (code fuse.Status) {
	if n.dir {
		out.Mode = fuse.S_IFDIR | 0755
	} else {
		out.Mode = fuse.S_IFREG | 0644
	}
	out.Size = uint64(len(n.data))
	return fuse.OK
}
開發者ID:jszwedko,項目名稱:ec2-metadatafs,代碼行數:9,代碼來源:fileless_test.go

示例4: GetAttr

func (f *p4File) GetAttr(out *fuse.Attr, file nodefs.File, c *fuse.Context) fuse.Status {
	if m, ok := modes[f.stat.HeadType]; ok {
		out.Mode = m
	} else {
		out.Mode = fuse.S_IFREG | 0644
	}

	out.Mtime = uint64(f.stat.HeadTime)
	out.Size = uint64(f.stat.FileSize)
	return fuse.OK
}
開發者ID:hanwen,項目名稱:p4fuse,代碼行數:11,代碼來源:fs.go

示例5: GetAttr

func (n *mtpNodeImpl) GetAttr(out *fuse.Attr, file nodefs.File, context *fuse.Context) (code fuse.Status) {
	out.Mode = fuse.S_IFREG | 0644
	f := n.obj
	if f != nil {
		out.Size = uint64(n.Size)
		t := f.ModificationDate
		out.SetTimes(&t, &t, &t)
	}

	return fuse.OK
}
開發者ID:pvsousalima,項目名稱:go-mtpfs,代碼行數:11,代碼來源:fs.go

示例6: GetAttr

func (dn *DirNode) GetAttr(
	out *fuse.Attr,
	file nodefs.File,
	context *fuse.Context) (code fuse.Status) {
	out.Mode = 0755 | syscall.S_IFDIR
	out.Nlink = 2
	out.Size = 1
	out.Uid = dn.owner.Uid
	out.Gid = dn.owner.Gid
	out.SetTimes(&dn.time, &dn.time, &dn.time)
	return fuse.OK
}
開發者ID:philips,項目名稱:goboardfs,代碼行數:12,代碼來源:dirnode.go

示例7: GetAttr

func (f *etcdFile) GetAttr(out *fuse.Attr) fuse.Status {
	res, err := f.etcdClient.Get(f.path, false, false)

	if err != nil {
		log.Println("Error:", err)
		return fuse.EIO
	}

	out.Mode = fuse.S_IFREG | 0666
	out.Size = uint64(len(res.Node.Value))
	return fuse.OK
}
開發者ID:roberto-reale,項目名稱:etcd-fs,代碼行數:12,代碼來源:file.go

示例8: GetAttr

func (sn *StrNode) GetAttr(
	out *fuse.Attr,
	file nodefs.File,
	context *fuse.Context) (code fuse.Status) {
	out.Mode = 0444 | syscall.S_IFREG
	owner := getDefaultOwner()
	out.Uid = owner.Uid
	out.Gid = owner.Gid
	out.Nlink = 1
	out.Size = uint64(len(sn.s))
	return fuse.OK
}
開發者ID:philips,項目名稱:goboardfs,代碼行數:12,代碼來源:strnode.go

示例9: GetAttr

func (m *MNode) GetAttr(out *fuse.Attr, file nodefs.File, context *fuse.Context) (code fuse.Status) {
	/*if file!=nil {
		return file.GetAttr(out)
	}*/
	reg,isReg := m.obj.Obj.(*joinf.JoinFile)
	if isReg {
		out.Mode = fuse.S_IFREG | 0666
		out.Size = uint64(reg.F.FLength)
	}else{
		out.Mode = fuse.S_IFDIR | 0777
	}
	return fuse.OK
}
開發者ID:maxymania,項目名稱:metaclusterfs,代碼行數:13,代碼來源:node.go

示例10: GetAttr

func (tn *ThreadNode) GetAttr(
	out *fuse.Attr,
	file nodefs.File,
	context *fuse.Context) (code fuse.Status) {
	out.Mode = 0755 | syscall.S_IFDIR
	out.Nlink = 1
	owner := getDefaultOwner()
	out.Uid = owner.Uid
	out.Gid = owner.Gid
	out.Size = uint64(tn.thread.Size())
	t := tn.thread.Time()
	out.SetTimes(&t, &t, &t)
	return fuse.OK
}
開發者ID:philips,項目名稱:goboardfs,代碼行數:14,代碼來源:thread.go

示例11: GetAttr

func (f *file) GetAttr(a *fuse.Attr) fuse.Status {
	cryptfs.Debug.Printf("file.GetAttr()\n")
	st := syscall.Stat_t{}
	f.lock.Lock()
	err := syscall.Fstat(int(f.fd.Fd()), &st)
	f.lock.Unlock()
	if err != nil {
		return fuse.ToStatus(err)
	}
	a.FromStat(&st)
	a.Size = f.cfs.PlainSize(a.Size)

	return fuse.OK
}
開發者ID:gh0std4ncer,項目名稱:gocryptfs,代碼行數:14,代碼來源:file.go

示例12: GetAttr

func (me *DropboxFs) GetAttr(name string, context *fuse.Context) (*fuse.Attr, fuse.Status) {
	path := get_path(name)
	log.Printf("GetAttr: '%s'\n", name)
	attr := fuse.Attr{}
	// XXX: handle this error
	data, _ := Cache.Metadata.Get(path)
	if data.IsDir {
		attr.Mode = fuse.S_IFDIR | 0755
	} else {
		attr.Mode = fuse.S_IFREG | 0644
		attr.Size = uint64(len(path))
	}
	return &attr, fuse.OK
}
開發者ID:sgodbold,項目名稱:dropbox-mnt-go,代碼行數:14,代碼來源:fs.go

示例13: GetAttr

func (f *file) GetAttr(a *fuse.Attr) fuse.Status {
	f.fdLock.RLock()
	defer f.fdLock.RUnlock()

	tlog.Debug.Printf("file.GetAttr()")
	st := syscall.Stat_t{}
	err := syscall.Fstat(int(f.fd.Fd()), &st)
	if err != nil {
		return fuse.ToStatus(err)
	}
	a.FromStat(&st)
	a.Size = f.contentEnc.CipherSizeToPlainSize(a.Size)

	return fuse.OK
}
開發者ID:rfjakob,項目名稱:gocryptfs,代碼行數:15,代碼來源:file.go

示例14: GetAttr

func (me *memNode) GetAttr(out *fuse.Attr, file nodefs.File, context *fuse.Context) (code fuse.Status) {
	var sz uint64
	if file != nil {
		code := file.GetAttr(out)
		if code.Ok() {
			sz = out.Size
		} else {
			msg := fmt.Sprintf("File.GetAttr(%s) = %v, %v", file.String(), out, code)
			panic(msg)
		}
	}
	me.mutex.RLock()
	defer me.mutex.RUnlock()
	*out = me.info
	if file != nil {
		out.Size = sz
	}
	return fuse.OK
}
開發者ID:hanwen,項目名稱:termite,代碼行數:19,代碼來源:memunionfs.go

示例15: GetAttr

func (f *file) GetAttr(out *fuse.Attr) fuse.Status {
	logrus.Debugf("FGetAttr %s", f.kv.Key)
	now := time.Now()
	out.Mtime = uint64(now.Unix())
	out.Mtimensec = uint32(now.UnixNano())
	out.Atime = uint64(now.Unix())
	out.Atimensec = uint32(now.UnixNano())
	out.Ctime = uint64(now.Unix())
	out.Ctimensec = uint32(now.UnixNano())

	if f.kv == nil || strings.HasSuffix(f.kv.Key, "/") || f.kv.Key == "" {
		out.Mode = fuse.S_IFDIR | 0755
		return fuse.OK
	}

	if len(f.kv.Value) > 0 {
		out.Mode = fuse.S_IFREG | 0644
		out.Size = uint64(len(f.kv.Value))
	}
	return fuse.OK
}
開發者ID:cpuguy83,項目名稱:kvfs,代碼行數:21,代碼來源:file.go


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