Exemplo n.º 1
0
        public PointFile(string path, string hash, Int64 size, PointTree tree)
        {
            this.hash = hash;
            this.tree = tree;
            this.path = path;
            this.size = size;
            var dir = System.IO.Path.GetDirectoryName(path);

            name = System.IO.Path.GetFileName(path);
            if (dir != "")
            {
                parent = tree.getDir(dir);
            }
            else
            {
                parent = tree;
            }
            if (parent is IAddSize)
            {
                ((IAddSize)parent).AddSize(size);
            }
            if (parent is IAddChild)
            {
                ((IAddChild)parent).AddChild(name, this);
            }
        }
Exemplo n.º 2
0
        public PointDir(string path, PointTree tree)
        {
            this.path = path;
            this.tree = tree;
            this.name = System.IO.Path.GetFileName(path);
            var dir = System.IO.Path.GetDirectoryName(path);

            if (dir != "")
            {
                var pdir = tree.getDir(dir);
                pdir.AddChild(this.name, this);
                parent = pdir;
            }
            else
            {
                parent = tree;
                tree.AddChild(this.name, this);
            }
        }
Exemplo n.º 3
0
        public IEnumerable <IDirItem> Childs()
        {
            var newCachePoint = new Dictionary <string, IDirItem>();
            var result        = new List <IDirItem>();

            foreach (string subDir in Directory.EnumerateDirectories(path))
            {
                IDirItem item;
                if (cachePoint.ContainsKey(subDir))
                {
                    item = cachePoint[subDir];
                }
                else
                {
                    item = new FSDirectory(subDir, System.IO.Path.GetFileName(subDir), this);
                }
                newCachePoint[subDir] = item;
            }
            foreach (string subDir in Directory.EnumerateFiles(path))
            {
                if (System.IO.Path.GetExtension(subDir).ToLower() != ".log")
                {
                    IDirItem item;
                    if (cachePoint.ContainsKey(subDir))
                    {
                        item = cachePoint[subDir];
                    }
                    else
                    {
                        item = new PointTree(subDir, System.IO.Path.GetFileName(subDir), this);
                    }
                    newCachePoint[subDir] = item;
                }
            }
            cachePoint = newCachePoint;
            return(newCachePoint.Values);
        }