Exemple #1
0
 /// <summary>
 /// Create a new Cache Interface to the given file
 /// </summary>
 /// <param name="zoneFile"></param>
 /// <param name="makeType">Convert floats to your type</param>
 /// <param name="cacheSize"></param>
 public ZoneCache(string zoneFile, Func<int, float[], T> makeType, int cacheSize = 0)
 {
     if (!File.Exists(zoneFile)) throw new IOException("FILE: '" + zoneFile + "' DOES NOT EXIST!");
     Reader = new BinaryReader(new FileStream(zoneFile, FileMode.Open, FileAccess.Read, FileShare.Read, 0x5000, FileOptions.RandomAccess), Encoding.Default);
     Zones = Reader.ReadInt32();
     if (cacheSize > 0)
     {
         Cache = new LocklessCache<int, T>(cacheSize);
     }
     else
     {
         Cache = new LocklessCache<int, T>();
     }
     Version = Reader.ReadInt32();
     Types = Reader.ReadInt32();
     Make = makeType;
     DataLine = new byte[Types * 4];
     FileSize = Reader.BaseStream.Length;
     LoadSparseIndexes();
 }
Exemple #2
0
 /// <summary>
 /// Create a new Cache Interface to the given file
 /// </summary>
 /// <param name="ODCFile">The file to use as a cache</param>
 /// <param name="MakeType">Convert floats to your type</param>
 public ZoneCache(string ZoneFile, Func<int, float[], T> MakeType, int cacheSize = 0)
 {
     if ( !File.Exists( ZoneFile ) ) throw new IOException( "FILE: '" + ZoneFile + "' DOES NOT EXIST!" );
     this.Reader = new BinaryReader( new FileStream( ZoneFile, FileMode.Open, FileAccess.Read, FileShare.Read, 0x5000, FileOptions.RandomAccess ), Encoding.Default );
     this.Zones = this.Reader.ReadInt32();
     if ( cacheSize > 0 )
     {
         this.Cache = new LocklessCache<int, T>( cacheSize );
     }
     else
     {
         this.Cache = new LocklessCache<int, T>();
     }
     this.Version = this.Reader.ReadInt32();
     this.Types = this.Reader.ReadInt32();
     this.Make = MakeType;
     this.DataLine = new byte[this.Types * 4];
     this.FileSize = this.Reader.BaseStream.Length;
     this.LoadSparseIndexes( this.Reader );
 }