private void UpdateParentDirectory(IDirectoryEntryInfoOverrides overrides) { var directory = directoryCache.ReadDirectory(parentDirectoryBlockId); try { directory.UpdateEntry(index.BlockId, overrides); } finally { directoryCache.UnRegisterDirectory(directory.BlockId); } }
public void UpdateEntry(int blockId, IDirectoryEntryInfoOverrides overrides) { if (overrides == null) { throw new ArgumentNullException(nameof(overrides)); } if (blockId < 0) { throw new ArgumentOutOfRangeException(nameof(blockId)); } indexLock.EnterWriteLock(); try { var buffer = new DirectoryItem[itemsCount]; blockStream.Read(1, buffer); for (var i = 0; i < buffer.Length; i++) { var entry = buffer[i]; if (entry.Entry.BlockIndex == blockId && (entry.Entry.Flags & DirectoryFlags.Deleted) == 0) { ApplyOverrides(ref entry.Entry, overrides); blockStream.Write(i + 1, new[] { entry }); return; } } } finally { indexLock.ExitWriteLock(); } throw new Exception("Entry not found"); }
private void ApplyOverrides(ref DirectoryEntryStruct entry, IDirectoryEntryInfoOverrides overrides) { entry.Size = overrides.Size ?? entry.Size; entry.Updated = overrides.Updated?.Ticks ?? entry.Updated; entry.Flags = overrides.Flags ?? entry.Flags; }
public void UpdateEntry(int blockId, IDirectoryEntryInfoOverrides entry) { throw new InvalidOperationException("Directory is being deleted"); }