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; } } }
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); } }
public abstract Task RemoveFileAsync(VfsFile file, CancellationToken cancel = default);