예제 #1
0
 /// <summary> Counts the total number of entries of BlockDB entries in memory and on disc. </summary>
 public long TotalEntries()
 {
     using (IDisposable rLock = Locker.AccquireRead(5 * 1000)) {
         if (rLock != null)
         {
             return(Cache.Count + BlockDBFile.CountEntries(MapName));
         }
         return(-1);
     }
 }
예제 #2
0
        /// <summary> Returns number of entries in the backing file on disc if it exists. </summary>
        public static long CountEntries(string map)
        {
            string path = FilePath(map);

            if (!File.Exists(path))
            {
                return(0);
            }

            using (Stream src = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Read, FileShare.ReadWrite)) {
                Vec3U16     dims;
                BlockDBFile file = ReadHeader(src, out dims);
                return(file.CountEntries(src));
            }
        }