VirtualFileSystem.INode.Load C# (CSharp) Méthode

Load() public static méthode

从存储介质中获取 inode
public static Load ( VFSCore vfs, UInt32 index ) : INode
vfs VFSCore
index System.UInt32
Résultat INode
        public static INode Load(VFSCore vfs, UInt32 index)
        {
            if (index >= vfs.GetSuperBlock().data.inodeCapacity)
            {
                throw new Exception("无效 inode 编号");
            }

            INode inode = null;

            if (inodeInstances.ContainsKey(index))
            {
                inode = inodeInstances[index];
                return inode;
            }
            else
            {
                _INode data = vfs.GetDevice().Read<_INode>(GetPosition(vfs, index));
                inode = new INode(vfs, data, index);
                inodeInstances[index] = inode;
            }

            inode.data.accessTime = (UInt64)DateTime.Now.Ticks;
            inode.Save();
            return inode;
        }

Usage Example

Exemple #1
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);
        }
All Usage Examples Of VirtualFileSystem.INode::Load