示例#1
0
        public void List(Pfm.MarshallerListOp op)
        {
            long openId = op.OpenId();
            int  err    = 0;

            if (!opens.ContainsKey(openId) || opens[openId].isdir == 0)
            {
                err = Pfm.errorAccessDenied;
            }
            else
            {
                Entry entry  = opens[openId];
                var   entrys = ListEntries(entry);
                foreach (var item in entrys)
                {
                    Pfm.Attribs att = new Pfm.Attribs();
                    SetAttTime(ref att, item);
                    att.fileId   = GetFileId(item);
                    att.fileSize = item.size;
                    att.fileType = item.isdir != 0 ? Pfm.fileTypeFolder : Pfm.fileTypeFile;
                    op.Add(att, item.server_filename);
                }
            }
            op.Complete(err, true);
        }
示例#2
0
文件: tempfs.cs 项目: jhult/pfmkit
    // Pfm.FormatterDispatch.List
    public void List(Pfm.MarshallerListOp op)
    {
        long       openId = op.OpenId();
        long       listId = op.ListId();
        int        perr   = 0;
        bool       noMore = true;
        SortedList children;

        Pfm.Attribs attribs = new Pfm.Attribs();
        OpenRef     openRef;
        ListRef     listRef;
        NameLink    nameLink;
        File        file;

        openRef = (OpenRef)(openRefs.Get(openId));
        if (openRef == null)
        {
            perr = Pfm.errorInvalid;
        }
        else
        {
            listRef = (ListRef)(openRef.listRefs.Get(listId));
            if (listRef == null)
            {
                listRef = new ListRef();
                openRef.listRefs.Set(listId, listRef);
            }
            children = openRef.file.children;
            while (true)
            {
                if (listRef.position >= children.Count)
                {
                    noMore = true;
                }
                else
                {
                    nameLink           = (NameLink)(children.GetByIndex(listRef.position));
                    file               = nameLink.file;
                    attribs.fileId     = file.fileId;
                    attribs.fileType   = file.fileType;
                    attribs.createTime = file.createTime;
                    attribs.accessTime = file.accessTime;
                    attribs.writeTime  = file.writeTime;
                    attribs.changeTime = file.changeTime;
                    attribs.fileSize   = file.fileSize;
                    if (op.Add(attribs, nameLink.endName))
                    {
                        listRef.position++;
                        continue;
                    }
                }
                break;
            }
        }

        op.Complete(perr, noMore);
    }
示例#3
0
文件: hellofs.cs 项目: jhult/pfmkit
    public void List(Pfm.MarshallerListOp op)
    {
        long openId = op.OpenId();
        int  perr   = 0;

        Pfm.Attribs attribs = new Pfm.Attribs();

        if (openId != folderOpenId)
        {
            perr = Pfm.errorAccessDenied;
        }
        else
        {
            attribs.fileType = Pfm.fileTypeFile;
            attribs.fileId   = helloFileId;
            attribs.fileSize = helloFileData.Length;
            op.Add(attribs, helloFileName);
        }

        op.Complete(perr, true /*noMore*/);
    }