private static string GetMethod([CanBeNull] string relativePath, GitHubItemType itemType, GitRepository repository) { var absolutePath = repository.LocalDirectory != null && relativePath != null ? PathConstruction.NormalizePath(Path.Combine(repository.LocalDirectory, relativePath)) : null; if (itemType == GitHubItemType.Directory || Directory.Exists(absolutePath) || relativePath == null) return "tree"; if (itemType == GitHubItemType.File || File.Exists(absolutePath)) return "blob"; return null; }
private static void CompressTar(string directory, string archiveFile, Predicate <FileInfo> filter, Func <Stream, Stream> outputStreamFactory) { FileSystemTasks.EnsureExistingParentDirectory(archiveFile); var files = GetFiles(directory, filter); using (var fileStream = File.Open(archiveFile, FileMode.CreateNew, FileAccess.ReadWrite)) using (var outputStream = outputStreamFactory(fileStream)) using (var tarArchive = TarArchive.CreateOutputTarArchive(outputStream)) { foreach (var file in files) { var entry = TarEntry.CreateEntryFromFile(file); var relativePath = PathConstruction.GetRelativePath(directory, file); entry.Name = PathConstruction.NormalizePath(relativePath, separator: '/'); tarArchive.WriteEntry(entry, recurse: false); } } Logger.Log($"Compressed content of '{directory}' to '{Path.GetFileName(archiveFile)}'."); }
internal MountedPath(string path, AbsolutePath hostPath) { this._path = PathConstruction.NormalizePath(path); HostPath = hostPath; }