예제 #1
0
        public Pack(PackCollection collection, DirectoryInfo dataDirectory, PackIdentifier id)
        {
            if (dataDirectory == null)
            {
                throw new ArgumentNullException("dataDirectory");
            }
            if (!dataDirectory.Exists)
            {
                throw new DirectoryNotFoundException();
            }

            Collection    = collection;
            DataDirectory = dataDirectory;
            this.Id       = id;

            var indexPath  = Path.Combine(DataDirectory.FullName, id.Expansion, string.Format(IndexFileFormat, Id.TypeKey, Id.ExpansionKey, Id.Number));
            var index2Path = Path.Combine(DataDirectory.FullName, id.Expansion, string.Format(Index2FileFormat, Id.TypeKey, Id.ExpansionKey, Id.Number));

            if (IOFile.Exists(indexPath))
            {
                Source = new IndexSource(this, new Index(id, indexPath));
            }
            else if (IOFile.Exists(index2Path))
            {
                Source = new Index2Source(this, new Index2(id, index2Path));
            }
            else
            {
                throw new FileNotFoundException();
            }
        }
 public Enumerator(IndexSource source)
 {
     _Source = source;
     _DirectoryEnumerator = source.Index.Directories.Values.GetEnumerator();
 }