Esempio n. 1
0
        internal VFSDirectory GetDirectory(string path)
        {
            if (path == "/")
            {
                return(_rootdir);
            }
            VFSDirectory currdir = _rootdir;

            string[] parts = path.Split('/');
            bool     ok    = true;

            for (int i = 1; i < parts.Length; i++)
            {
                if (currdir.ContainsDir(parts[i]))
                {
                    currdir = currdir.GetSubdirByName(parts[i]);
                }
                else
                {
                    break;
                }
            }
            if (!ok)
            {
                return(null);
            }
            else
            {
                return(currdir);
            }
        }
Esempio n. 2
0
        private void RebuildTree()
        {
            string[] path;
            _rootdir = null;
            _virtualpaths.Clear();
            GC.Collect();
            _rootdir = new VFSDirectory("/");
            VFSDirectory currdir = _rootdir;

            foreach (VFSVirtualItem item in _items)
            {
                path = item.Name.Split('/');
                for (int i = 0; i < path.Length; i++)
                {
                    if (i != path.Length - 1) //directory
                    {
                        if (!string.IsNullOrEmpty(path[i]))
                        {
                            if (!currdir.ContainsDir(path[i]))
                            {
                                currdir.Subdirs.Add(new VFSDirectory(path[i]));
                            }
                            currdir = currdir.GetSubdirByName(path[i]);
                        }
                    }
                    else
                    {
                        currdir.Files.Add(item);
                    }
                }
            }

            foreach (VFSVirtualItem item in _items)
            {
                _virtualpaths.Add(getPath(item.Name));
            }
            _virtualpaths = _virtualpaths.Distinct().ToList();
        }