public bool TryGetParentDirectory(BaseEntry entry, out DirectoryEntry directory) { lock (_directoriesLockObject) { return(_directories.TryGetValue(entry.DirectoryId, out directory)); } }
public bool CanWrite(BaseEntry entry) { lock (_writeLockObject) { var entryLocker = EntryLockerAccessorFactory.GetEntryLockerAccessor(Operation.Write)(this); return(!entryLocker.CheckIsLocked(entry)); } }
public bool CanRead(BaseEntry entry) { lock (_readLockObject) { var entryLocker = EntryLockerAccessorFactory.GetEntryLockerAccessor(Operation.Read)(this); return(!entryLocker.CheckIsLocked(entry)); } }
public void Unlock(BaseEntry entry) { lock (_lockObject) { if (CheckIsLocked(entry)) { _dictionary[entry]--; } } }
public void Lock(BaseEntry entry) { lock (_lockObject) { if (!_dictionary.ContainsKey(entry)) { _dictionary.Add(entry, 0); } _dictionary[entry]++; } }
public void AddEntry(BaseEntry entry) { switch (entry) { case FileEntry file: addFile(file); break; case DirectoryEntry directory: addDirectory(directory); break; } }
public void RemoveEntry(BaseEntry entry) { switch (entry) { case FileEntry file: removeFile(file); break; case DirectoryEntry directory: removeDirectory(directory); break; } }
public bool TryLockWriting(BaseEntry entry, out LockerOperation operation) { lock (_writeLockObject) { operation = null; if (!CanWrite(entry)) { return(false); } operation = LockWriting(entry); return(true); } }
private IEnumerable <DirectoryEntry> getDirectoryChain(BaseEntry entry) { var tmpEntry = entry; while (tmpEntry.DirectoryId > -1) { if (!Indexer.TryGetParentDirectory(tmpEntry, out var retv)) { continue; } tmpEntry = retv; yield return(retv); } }
public bool CheckIsLocked(BaseEntry entry) { lock (_lockObject) return(_dictionary.ContainsKey(entry) && _dictionary[entry] > 0); }
public LockerOperation LockWriting(BaseEntry entry) { return(LockWriting(new[] { entry })); }