void AddFile(WorkspaceDirectoryInfo NewWorkspaceDir, StreamFileInfo StreamFile) { // Create a new file for this workspace WorkspaceFileInfo WorkspaceFile = new WorkspaceFileInfo(NewWorkspaceDir, StreamFile.Name, StreamFile.ContentId); NewWorkspaceDir.NameToFile.Add(StreamFile.Name, WorkspaceFile); // Try to add it to the cache TrackedFileInfo TrackedFile; if (ContentIdToTrackedFile.TryGetValue(StreamFile.ContentId, out TrackedFile)) { if (FilesToMove.TryAdd(TrackedFile, new WorkspaceFileToMove(StreamFile, TrackedFile, WorkspaceFile))) { WorkspaceFile.SetMetadata(TrackedFile.Length, TrackedFile.LastModifiedTicks, TrackedFile.bReadOnly); } else { FilesToCopy.Add(new WorkspaceFileToCopy(StreamFile, FilesToMove[TrackedFile].WorkspaceFile, WorkspaceFile)); } } else { WorkspaceFileInfo SourceWorkspaceFile; if (ContentIdToWorkspaceFile.TryGetValue(StreamFile.ContentId, out SourceWorkspaceFile)) { FilesToCopy.Add(new WorkspaceFileToCopy(StreamFile, SourceWorkspaceFile, WorkspaceFile)); } else { FilesToSync.Add(new WorkspaceFileToSync(StreamFile, WorkspaceFile)); } } }
void RemoveFile(WorkspaceFileInfo WorkspaceFile) { if (ContentIdToTrackedFile.ContainsKey(WorkspaceFile.ContentId) || !FilesToMove.TryAdd(WorkspaceFile.ContentId, WorkspaceFile)) { FilesToDelete.Add(WorkspaceFile); } }
public void Read(BinaryReader Reader) { WorkspaceFileInfo[] Files = new WorkspaceFileInfo[Reader.ReadInt32()]; for (int Idx = 0; Idx < Files.Length; Idx++) { Files[Idx] = new WorkspaceFileInfo(this, Reader); } NameToFile = Files.ToDictionary(x => x.Name, x => x, StringComparer.Ordinal); int NumSubDirectories = Reader.ReadInt32(); for (int Idx = 0; Idx < NumSubDirectories; Idx++) { WorkspaceDirectoryInfo SubDirectory = new WorkspaceDirectoryInfo(this, Reader.ReadString()); SubDirectory.Read(Reader); NameToSubDirectory[SubDirectory.Name] = SubDirectory; } }
public WorkspaceFileToSync(StreamFileInfo StreamFile, WorkspaceFileInfo WorkspaceFile) { this.StreamFile = StreamFile; this.WorkspaceFile = WorkspaceFile; }
public WorkspaceFileToCopy(StreamFileInfo StreamFile, WorkspaceFileInfo SourceWorkspaceFile, WorkspaceFileInfo TargetWorkspaceFile) { this.StreamFile = StreamFile; this.SourceWorkspaceFile = SourceWorkspaceFile; this.TargetWorkspaceFile = TargetWorkspaceFile; }
public WorkspaceFileToMove(StreamFileInfo StreamFile, TrackedFileInfo TrackedFile, WorkspaceFileInfo WorkspaceFile) { this.StreamFile = StreamFile; this.TrackedFile = TrackedFile; this.WorkspaceFile = WorkspaceFile; }