Beispiel #1
0
 public Stream Open(FileDataEntry dataEntry)
 {
     if (dataEntry == null)
     {
         return(null);
     }
     return(GetBlockView(dataEntry.BlockIndex));
 }
Beispiel #2
0
        public FileDataEntry GetFileDataEntryByHash(byte[] hash)
        {
            if (hash.Length != 20)
            {
                throw new ArgumentException("Hash must be exactly 20 bytes.", nameof(hash));
            }
            var index = _dataEntries.BinarySearch(FileDataEntry.ForSearch(hash), BlockHashComparer.Instance);

            if (index < 0)
            {
                return(null);
            }
            return(_dataEntries[index]);
        }
Beispiel #3
0
        private List <FileDataEntry> ReadDataHeaders(BinaryReader getBlockView)
        {
            var dataEntries = new List <FileDataEntry>();

            for (var x = 0; x < RootIndex.BlockCount; x++)
            {
                var thisDataEntry = FileDataEntry.FromReader(getBlockView);
                var insertIndex   = dataEntries.BinarySearch(thisDataEntry, BlockHashComparer.Instance);
                if (insertIndex < 0)
                {
                    insertIndex = ~insertIndex;
                }
                dataEntries.Insert(insertIndex, thisDataEntry);
            }

            return(dataEntries);
        }