Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
            public AbsolutePath GetPath()
            {
                AbsolutePath parentDirectoryPath = fileEntry.Parent.PathFormatter.GetPath();
                AbsolutePath filePath            = parentDirectoryPath.Append(fileEntry.Name);

                return(filePath);
            }
Ejemplo n.º 3
0
        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()));
        }
Ejemplo n.º 4
0
        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);
        }