Esempio n. 1
0
        // Constructor to fill list from directory and optionally subdirectories
        public DirectoryFilesList(string path, bool subdirectories)
        {
            path = Path.GetFullPath(path);
            string[] files = Directory.GetFiles(path, "*", subdirectories ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);
            Array.Sort(files);             //mxd
            entries    = new Dictionary <string, DirectoryFileEntry>(files.Length, StringComparer.OrdinalIgnoreCase);
            wadentries = new List <string>();

            foreach (string file in files)            //mxd
            {
                var e = new DirectoryFileEntry(file, path);
                if (string.Compare(e.extension, "wad", true) == 0 && e.path.Length == 0)
                {
                    wadentries.Add(file);
                    continue;
                }
                if (EXLUDE_EXTENSIONS.Contains(e.extension))
                {
                    continue;
                }

                if (entries.ContainsKey(e.filepathname))
                {
                    throw new IOException("Multiple files with the same filename in the same directory are not allowed. See: \"" + e.filepathname + "\"");
                }

                entries.Add(e.filepathname, e);
            }
        }
Esempio n. 2
0
 // Constructor to fill list from directory and optionally subdirectories
 public DirectoryFilesList(string path, bool subdirectories)
 {
     path = Path.GetFullPath(path);
     string[] files = Directory.GetFiles(path, "*", subdirectories ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);
     entries       = new DirectoryFileEntry[files.Length];
     hashedentries = new Dictionary <string, DirectoryFileEntry>(files.Length);
     for (int i = 0; i < files.Length; i++)
     {
         entries[i] = new DirectoryFileEntry(files[i], path);
         string hashkey = entries[i].filepathname.ToLowerInvariant();
         if (hashedentries.ContainsKey(hashkey))
         {
             throw new IOException("Multiple files with the same filename in the same directory are not allowed. See: \"" + entries[i].filepathname + "\"");
         }
         hashedentries.Add(hashkey, entries[i]);
     }
 }
        // Constructor to fill list from directory and optionally subdirectories
        public DirectoryFilesList(string path, bool subdirectories)
        {
            path = Path.GetFullPath(path);
            string[] files = Directory.GetFiles(path, "*", subdirectories ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);
            Array.Sort(files);             //mxd
            entries    = new Dictionary <string, DirectoryFileEntry>(files.Length, StringComparer.OrdinalIgnoreCase);
            wadentries = new List <string>();

            foreach (string file in files)            //mxd
            {
                var e = new DirectoryFileEntry(file, path);
                if (string.Compare(e.extension, "wad", true) == 0 && e.path.Length == 0)
                {
                    wadentries.Add(file);
                    continue;
                }

                if (General.Map.Config.IgnoredFileExtensions.Contains(e.extension))
                {
                    continue;
                }

                bool skipfolder = false;
                foreach (string ef in General.Map.Config.IgnoredDirectoryNames)
                {
                    if (e.path.StartsWith(ef + Path.DirectorySeparatorChar))
                    {
                        skipfolder = true;
                        break;
                    }
                }
                if (skipfolder)
                {
                    continue;
                }

                entries.Add(e.filepathname, e);
            }
        }
Esempio n. 4
0
 // This checks whether a file is in the entry dictionary, adds it if it
 // isn't, and replaces the existing entry if the new entry is lowercase
 private void AddOrReplaceEntry(DirectoryFileEntry e)
 {
     // If the entry is already in the dictionary, add the one with
     // greater ordinal value (prefer lowercase)
     if (entries.ContainsKey(e.filepathname))
     {
         // Get the key for the existing entry. It may have a
         // different case, since the dictionary is set up to be
         // case insensitive.
         string existingEntryPath = entries[e.filepathname].filepathname;
         if (e.filepathname.CompareTo(existingEntryPath) == -1)
         {
             entries.Remove(e.filepathname);
             entries.Add(e.filepathname, e);
         }
     }
     else
     {
         // Just add the entry, since it's not in the dictionary yet.
         entries.Add(e.filepathname, e);
     }
 }