Ejemplo n.º 1
0
/**
 * Scan the given tar and add graphics sets when it finds one.
 * @param fs        the file scanner to scan for
 * @param extension the extension of files to search for.
 * @param tar       the tar to search in.
 */

        public static uint ScanTar(FileScanner fs, string extension, KeyValuePair <string, TarFileListEntry> tar)
        //Dictionary<string, TarFileListEntry>
        {
            uint num      = 0;
            var  filename = tar.Key;

            if (FileIO.MatchesExtension(extension, filename) && fs.AddFile(filename, tar.Value.tar_filename))
            {
                num++;
            }

            return(num);
        }
Ejemplo n.º 2
0
        /**
         * Scan a single directory (and recursively its children) and add
         * any graphics sets that are found.
         * @param fs              the file scanner to add the files to
         * @param extension       the extension of files to search for.
         * @param path            full path we're currently at
         * @param basepath_length from where in the path are we 'based' on the search path
         * @param recursive       whether to recursively search the sub directories
         */
        public static uint ScanPath(FileScanner fs, string extension, string path, bool recursive = true)
        {
            uint num = 0;

            if (path == null || Directory.Exists(path) == false)
            {
                return(0);
            }
            var dir = new DirectoryInfo(path);

            foreach (var file in dir.GetFiles())
            {
                if (file.Exists == false)
                {
                    continue;
                }

                var filename = path + file.Name;

                if (MatchesExtension(extension, filename) && fs.AddFile(filename, null))
                {
                    num++;
                }
            }
            if (recursive)
            {
                foreach (var subDir in dir.GetDirectories())
                {
                    var filename = FileIO.AppendPathSeparator(path + subDir.Name);

                    //if (!FileIO.AppendPathSeparator(filename)) continue;
                    num += ScanPath(fs, extension, filename, recursive);
                }
            }

            return(num);
        }