Пример #1
0
        public override async Task AddFileAsync(VfsFile file, CancellationToken cancel = default)
        {
            using (await AsyncLock.LockWithAwait(cancel))
            {
                int r = file.AddLinkRef();
                try
                {
                    if (file.FileSystem != this.FileSystem)
                    {
                        throw new VfsException(file.Name, "file.FileSystem != this.FileSystem");
                    }
                    FileSystem.PathParser.ValidateFileOrDirectoryName(file.Name);
                    if (EntityTable.ContainsKey(file.Name))
                    {
                        throw new VfsException(file.Name, "The same name already exists.");
                    }
                    EntityTable.Add(file.Name, file);
                }
                catch
                {
                    await file.ReleaseLinkAsync();

                    throw;
                }
            }
        }
Пример #2
0
        public override async Task RemoveFileAsync(VfsFile file, CancellationToken cancel = default)
        {
            using (await AsyncLock.LockWithAwait(cancel))
            {
                if (EntityTable.ContainsValue(file) == false)
                {
                    throw new VfsException(file.Name, $"The object is not contained on the parent directory \"{this.Name}\".");
                }

                await file.ReleaseLinkAsync();

                EntityTable.Remove(file.Name);
            }
        }
Пример #3
0
 public abstract Task RemoveFileAsync(VfsFile file, CancellationToken cancel = default);