示例#1
0
文件: Directory.cs 项目: ilf80/FS
        private void UpdateParentDirectory(IDirectoryEntryInfoOverrides overrides)
        {
            var directory = directoryCache.ReadDirectory(parentDirectoryBlockId);

            try
            {
                directory.UpdateEntry(index.BlockId, overrides);
            }
            finally
            {
                directoryCache.UnRegisterDirectory(directory.BlockId);
            }
        }
示例#2
0
文件: Directory.cs 项目: ilf80/FS
        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");
        }
示例#3
0
文件: Directory.cs 项目: ilf80/FS
 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;
 }
示例#4
0
 public void UpdateEntry(int blockId, IDirectoryEntryInfoOverrides entry)
 {
     throw new InvalidOperationException("Directory is being deleted");
 }