Load() публичный статический Метод

根据 inode 建立 INodeDirectory
public static Load ( VFSCore vfs, INode inode ) : INodeDirectory
vfs VFSCore
inode INode
Результат INodeDirectory
Пример #1
0
        /// <summary>
        /// 根据 inode 建立 INodeDirectory
        /// </summary>
        /// <param name="vfs"></param>
        /// <param name="inode"></param>
        /// <returns></returns>
        public static INodeDirectory Load(VFSCore vfs, INode inode)
        {
            INodeDirectory t = new INodeDirectory(vfs, inode);

            t.Load();
            return(t);
        }
Пример #2
0
        /// <summary>
        /// 删除一个目录项
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public Boolean Delete(String name)
        {
            if (!Contains(name))
            {
                return(false);
            }
            if (name == "." || name == "..")
            {
                return(false);
            }

            var inodeIndex = entries[name];

            INode inode = INode.Load(vfs, inodeIndex);

            if (inode.IsDirectory())
            {
                // 删除非空目录项:递归删除
                INodeDirectory id = INodeDirectory.Load(vfs, inodeIndex);
                if (id.Size() > 2)
                {
                    var l = id.List();
                    foreach (var pair in l)
                    {
                        id.Delete(pair.Key);
                    }
                }
            }

            inode.data.linkCount--;

            if (inode.data.linkCount == 0)
            {
                inode.Resize(0);
                vfs.DeAllocateINode(inode.index);
            }
            else
            {
                inode.Save();
            }

            entries.Remove(name);
            Save();

            return(true);
        }
Пример #3
0
 /// <summary>
 /// 根据 inode 建立 INodeDirectory
 /// </summary>
 /// <param name="vfs"></param>
 /// <param name="inode"></param>
 /// <returns></returns>
 public static INodeDirectory Load(VFSCore vfs, INode inode)
 {
     INodeDirectory t = new INodeDirectory(vfs, inode);
     t.Load();
     return t;
 }