public static AbsolutePath TryGetPathOfFirstOpenFile([NotNull] this DirectoryEntry directory, [NotNull] AbsolutePath path) { Guard.NotNull(directory, nameof(directory)); Guard.NotNull(path, nameof(path)); FileEntry file = directory.Files.Values.FirstOrDefault(x => x.IsOpen()); if (file != null) { return(path.Append(file.Name)); } foreach (DirectoryEntry subdirectory in directory.Directories.Values) { AbsolutePath subdirectoryPath = path.Append(subdirectory.Name); AbsolutePath openFilePath = TryGetPathOfFirstOpenFile(subdirectory, subdirectoryPath); if (openFilePath != null) { return(openFilePath); } } return(null); }
public AbsolutePath GetPath() { AbsolutePath parentDirectoryPath = fileEntry.Parent.PathFormatter.GetPath(); AbsolutePath filePath = parentDirectoryPath.Append(fileEntry.Name); return(filePath); }
public IDirectoryInfo CreateSubdirectory(string path) { // TODO: Review what kinds of path are allowed here. AbsolutePath subPath = AbsolutePath.Append(path); return(Owner.Directory.CreateDirectory(subPath.GetText())); }
private static AbsolutePath CombinePathComponents([NotNull] AbsolutePath basePath, [NotNull] string relativePath) { AbsolutePath resultPath = basePath; foreach (string component in relativePath.Split(PathFacts.DirectorySeparatorChars)) { resultPath = resultPath.Append(component); } return(resultPath); }