public void AddFile(string path, DateTime lastWriteTime) { var parentPathParts = path.Split("/").SkipLast(1); var currentNode = rootNode; foreach (var part in parentPathParts) { if (currentNode.Directories.TryGetValue(part, out var directory)) { currentNode = directory; } else { directory = new FileTreeNode(); currentNode.Directories[part] = directory; currentNode = directory; } } var file = new MockFile(path, lastWriteTime, true); currentNode.AddFile(file); }
public IFile GetFileInfo(string path) { var pathParts = path.Split("/").SkipLast(1); var currentNode = rootNode; foreach (var part in pathParts) { if (currentNode.Directories.TryGetValue(part, out var directory)) { currentNode = directory; } else { throw new ArgumentException($"No file found at: {path}"); } } if (!currentNode.Files.TryGetValue(path.Split("/").Last(), out var file)) { file = new MockFile(path, DateTime.Today, false); } return(file); }
public void AddFile(MockFile file) { Files.Add(file.FileName, file); }