コード例 #1
0
        public override async Task AddDirectoryAsync(VfsDirectory directory, CancellationToken cancel = default)
        {
            using (await AsyncLock.LockWithAwait(cancel))
            {
                int r = directory.AddLinkRef();
                try
                {
                    if (r >= 2)
                    {
                        throw new VfsException(directory.Name, "The directory object is already referenced by other directory.");
                    }
                    if (directory.FileSystem != this.FileSystem)
                    {
                        throw new VfsException(directory.Name, "directory.FileSystem != this.FileSystem");
                    }
                    FileSystem.PathParser.ValidateFileOrDirectoryName(directory.Name);
                    if (EntityTable.ContainsKey(directory.Name))
                    {
                        throw new VfsException(directory.Name, "The same name already exists.");
                    }
                    EntityTable.Add(directory.Name, directory);
                }
                catch
                {
                    await directory.ReleaseLinkAsync();

                    throw;
                }
            }
        }
コード例 #2
0
        public override async Task RemoveDirectoryAsync(VfsDirectory directory, CancellationToken cancel = default)
        {
            using (await AsyncLock.LockWithAwait(cancel))
            {
                if (EntityTable.ContainsValue(directory) == false)
                {
                    throw new VfsException(directory.Name, $"The object is not contained on the parent directory \"{this.Name}\".");
                }

                await directory.ReleaseLinkAsync();

                EntityTable.Remove(directory.Name);
            }
        }
コード例 #3
0
 public abstract Task RemoveDirectoryAsync(VfsDirectory directory, CancellationToken cancel = default);