VirtualFileSystem.INodeDirectory.Resolve C# (CSharp) 메소드

Resolve() 공개 정적인 메소드

根据路径解析目录,路径必须以 / 结尾
public static Resolve ( VFSCore vfs, String path ) : INodeDirectory
vfs VFSCore
path String
리턴 INodeDirectory
        public static INodeDirectory Resolve(VFSCore vfs, String path)
        {
            INodeDirectory root = Load(vfs, 0);

            var pathCom = path.Split('/');
            var node = root;

            for (var i = 1; i < pathCom.Length - 1; ++i)
            {
                if (node.Contains(pathCom[i]) && INode.Load(vfs, node.Find(pathCom[i])).IsDirectory())
                {
                    node = Load(vfs, node.Find(pathCom[i]));
                }
                else
                {
                    return null;
                }
            }

            return node;
        }

Usage Example

예제 #1
0
            public Directory(VFSCore vfs, String path)
            {
                this.vfs = vfs;

                if (!path.EndsWith("/"))
                {
                    path += "/";
                }

                this.path = path;

                dir = INodeDirectory.Resolve(vfs, path);

                if (dir == null)
                {
                    throw new Exception("无效路径");
                }
            }
All Usage Examples Of VirtualFileSystem.INodeDirectory::Resolve