Beispiel #1
0
        public virtual FSOBase[] trawlRecursively(IRecursiveTrawlerManager rtm, Boolean doUpdates)
        {
            if (info)
            {
                Console.WriteLine("Recursively Trawling: " + path);
            }
            var toret = new List <FSOBase>();

            subFSO.Clear();
            var localObjs = new List <FSOBase>();
            var files     = new List <String>(Directory.EnumerateFiles(path));

            for (int i = 0; i < files.Count; i++)
            {
                var c = new FSOFile(files[i])
                {
                    Info = this.info
                };
                if (rtm.shouldTrawl(c))
                {
                    if (doUpdates)
                    {
                        c.update();
                    }
                    toret.Add(c);
                    localObjs.Add(c);
                }
            }
            var dirs = new List <String>(Directory.EnumerateDirectories(path));

            for (int i = 0; i < dirs.Count; i++)
            {
                var c = new FSODirectory(dirs[i])
                {
                    Info = this.info
                };
                if (rtm.shouldTrawl(c))
                {
                    toret.Add(c);
                    localObjs.Add(c);
                    toret.AddRange(c.trawlRecursively(rtm, doUpdates));
                    if (doUpdates)
                    {
                        c.update();
                    }
                }
            }
            subFSO.AddRange(localObjs);
            return(toret.ToArray());
        }
Beispiel #2
0
        public virtual FSOBase[] trawl(Boolean includeDirectories, Boolean doUpdates)
        {
            if (info)
            {
                Console.WriteLine("Trawling: " + path);
            }
            var toret = new List <FSOBase>();

            subFSO.Clear();
            var files = new List <String>(Directory.EnumerateFiles(path));

            for (int i = 0; i < files.Count; i++)
            {
                var c = new FSOFile(files[i])
                {
                    Info = this.info
                };
                if (doUpdates)
                {
                    c.update();
                }
                toret.Add(c);
            }
            if (includeDirectories)
            {
                var dirs = new List <String>(Directory.EnumerateDirectories(path));
                for (int i = 0; i < dirs.Count; i++)
                {
                    var c = new FSODirectory(dirs[i])
                    {
                        Info = this.info
                    };
                    if (doUpdates)
                    {
                        c.update();
                    }
                    toret.Add(c);
                }
            }
            subFSO.AddRange(toret);
            return(toret.ToArray());
        }