Example #1
0
        public void WriteEntries()
        {
            using (IDisposable writeLock = locker.AccquireWriteLock()) {
                if (Cache.Count == 0)
                {
                    return;
                }

                ValidateBackingFile();
                using (Stream s = File.OpenWrite(FilePath)) {
                    // This truncates the lower 4 bits off - so e.g. if a power off occurred
                    // and 21 bytes were in the file, this sets the position to byte 16
                    s.Position = s.Length & ~0x0F;
                    BlockDBFile.WriteEntries(s, Cache);

                    lock (CacheLock)
                        Cache = new FastList <BlockDBEntry>();
                }
            }
        }