public FileHandle Duplicate(Guid id) { var handle = handleStore.Get(id); var duplicate = new FileHandle(Guid.NewGuid(), handle.Path); handleStore.Insert(duplicate); return duplicate; }
public FileHandle Insert(Stream stream, string filename) { var handle = new FileHandle(Guid.NewGuid(), Locate(filename)); using (var filestream = File.Create(handle.Path)) { stream.CopyTo(filestream); } handleStore.Insert(handle); if (totalSize != null) { totalSize += handle.Size; } return handle; }
public FileHandleEventArgs(FileHandle handle) { this.handle = handle; }
private static void Write(string action, FileHandle handle) { Console.Write(action + " [id="); Console.ForegroundColor = ConsoleColor.Cyan; Console.Write(handle.Id); Console.ResetColor(); Console.Write("|path="); Console.ForegroundColor = ConsoleColor.Green; Console.Write(handle.Path); Console.ResetColor(); Console.Write("]"); Console.WriteLine(); }
public FileHandle Insert(string path) { var handle = new FileHandle(Guid.NewGuid(), Locate(path)); File.Copy(path, handle.Path); handleStore.Insert(handle); if (totalSize != null) { totalSize += handle.Size; } return handle; }
public FileHandle Replace(Guid id, string path) { var replacement = new FileHandle(id, Locate(path)); File.Copy(path, replacement.Path); handleStore.Update(replacement); if (totalSize != null) { totalSize += replacement.Size; } return replacement; }
public FileHandle Replace(Guid id, Stream stream, string filename) { var replacement = new FileHandle(id, Locate(filename)); using (var filestream = File.Create(replacement.Path)) { stream.CopyTo(filestream); } handleStore.Update(replacement); if (totalSize != null) { totalSize += replacement.Size; } return replacement; }
public void Update(FileHandle handle) { Remove(handle.Id); Insert(handle); }
public void Insert(FileHandle handle) { handles.Add(handle); }