public Stream Open(string file, OpenMode mode) { var ret = _backend.Open(file, mode); WriteOperation?.Invoke(file); return(ret); }
public Stream OpenWrite(string file) { var ret = new WriteOnlyStream(_backend.Open(file, OpenMode.OpenOrCreate)); WriteOperation?.Invoke(file); // Won't fire if the stream is written to afterwards... FIXME? return(ret); }
/// <inheritdoc cref="WriteAllBytes(string, byte[])"/> public async Task WriteAllBytesAsync(string path, byte[] bytes) { await Task.Run(() => { _backend.WriteAllBytes(path, bytes); WriteOperation?.Invoke(path); }); }
/// <inheritdoc cref="CreateDirectory(string)"/> public async Task CreateDirectoryAsync(string path) { await Task.Run(() => { _backend.CreateDirectory(path); WriteOperation?.Invoke(path); }); }
/// <summary> /// Delete a file or directory from the VFS /// </summary> /// <param name="path">A path to the file or directory to delete</param> public void Delete(string path) { if (IsOpenInProgram(path)) { throw new IOException("The process cannot access the file because it is currently opened in another process."); } _backend.Delete(path); WriteOperation?.Invoke(path); }
/// <summary> /// Write binary data to a file /// </summary> /// <param name="path">The path to a file to write to</param> /// <param name="data">The binary data to write</param> public void WriteAllBytes(string path, byte[] data) { if (data == null) { data = new byte[0]; } _backend.WriteAllBytes(path, data); WriteOperation?.Invoke(path); }
/// <inheritdoc cref="Delete(string)"/> public async Task DeleteAsync(string path) { if (IsOpenInProgram(path)) { throw new IOException("The process cannot access the file because it is currently opened in another process."); } await Task.Run(() => { _backend.Delete(path); WriteOperation?.Invoke(path); }); }
/// <summary> /// Create a directory. /// </summary> /// <param name="path">The path for the new directory.</param> public void CreateDirectory(string path) { _backend.CreateDirectory(path); WriteOperation?.Invoke(path); }