Exemple #1
0
 public bool TryGetParentDirectory(BaseEntry entry, out DirectoryEntry directory)
 {
     lock (_directoriesLockObject)
     {
         return(_directories.TryGetValue(entry.DirectoryId, out directory));
     }
 }
Exemple #2
0
 public bool CanWrite(BaseEntry entry)
 {
     lock (_writeLockObject)
     {
         var entryLocker = EntryLockerAccessorFactory.GetEntryLockerAccessor(Operation.Write)(this);
         return(!entryLocker.CheckIsLocked(entry));
     }
 }
Exemple #3
0
 public bool CanRead(BaseEntry entry)
 {
     lock (_readLockObject)
     {
         var entryLocker = EntryLockerAccessorFactory.GetEntryLockerAccessor(Operation.Read)(this);
         return(!entryLocker.CheckIsLocked(entry));
     }
 }
Exemple #4
0
 public void Unlock(BaseEntry entry)
 {
     lock (_lockObject)
     {
         if (CheckIsLocked(entry))
         {
             _dictionary[entry]--;
         }
     }
 }
Exemple #5
0
            public void Lock(BaseEntry entry)
            {
                lock (_lockObject)
                {
                    if (!_dictionary.ContainsKey(entry))
                    {
                        _dictionary.Add(entry, 0);
                    }

                    _dictionary[entry]++;
                }
            }
Exemple #6
0
        public void AddEntry(BaseEntry entry)
        {
            switch (entry)
            {
            case FileEntry file:
                addFile(file);
                break;

            case DirectoryEntry directory:
                addDirectory(directory);
                break;
            }
        }
Exemple #7
0
        public void RemoveEntry(BaseEntry entry)
        {
            switch (entry)
            {
            case FileEntry file:
                removeFile(file);
                break;

            case DirectoryEntry directory:
                removeDirectory(directory);
                break;
            }
        }
Exemple #8
0
        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);
            }
        }
Exemple #10
0
 public bool CheckIsLocked(BaseEntry entry)
 {
     lock (_lockObject)
         return(_dictionary.ContainsKey(entry) && _dictionary[entry] > 0);
 }
Exemple #11
0
 public LockerOperation LockWriting(BaseEntry entry)
 {
     return(LockWriting(new[] { entry }));
 }