public static FileSet CreateFileSetFrom(Purl directory) { FileSystemEntry entry = Infrastructure.FileSystemEntryRepository.FindEntry(directory); FileSet fileSet = new FileSet(); fileSet.AddAll(entry.BreadthFirstFiles); return fileSet; }
public Hooks(IFileSystem fileSystem, Purl path) { _path = path; _fileSystem = fileSystem; _hookTypes.Add(new HookType("cmd", typeof(CmdExecHook))); _hookTypes.Add(new HookType("ps1", typeof(PowershellHook))); }
private static ZipOutputStream OpenZipStream(Purl path) { Stream stream = path.CreateFile(); ZipOutputStream zip = new ZipOutputStream(stream); zip.SetLevel(5); return zip; }
private void SaveProjectManifest(ProjectManifest manifest, Purl path) { using (StreamWriter stream = new StreamWriter(_fileSystem.CreateFile(path.AsString))) { stream.Write(_serializer.Serialize(manifest)); } }
public void CheckoutVersionFromRepository(Repository repository, ArchivedProjectVersion version, Purl directory) { _log.Info("Checking out: " + version + " into " + directory); Archive archive = ArchiveFactory.ReadZip(new Purl(repository.PathFor(version).AsString + ZipPackager.ZipExtension)); ZipUnpackager unpackager = new ZipUnpackager(archive); unpackager.UnpackageZip(directory); }
public FileSystemFile(Purl path, long length, DateTime createdAt, DateTime accessedAt, DateTime modifiedAt) : base(path) { _length = length; _createdAt = createdAt; _accessedAt = accessedAt; _modifiedAt = modifiedAt; }
public void CheckoutVersionFromRepository(Repository repository, ArchivedProjectVersion version, Purl directory) { _log.Info("Checking out: " + version + " into " + directory); FileSystemEntry entry = Infrastructure.FileSystemEntryRepository.FindEntry(repository.PathFor(version)); FileSet fileSet = new FileSet(); fileSet.AddAll(entry.BreadthFirstFiles); CopyFiles(fileSet, directory, true); }
public virtual IncludeExclude Includes(Purl path) { if (_expression.IsMatch(path.Name)) { return IncludeExclude.Include; } return IncludeExclude.Unknown; }
public Purl ChangeRoot(Purl root) { if (!IsARoot(root)) { throw new InvalidOperationException(String.Format("Unable to change root of {0} to {1}", this, root)); } string rootPath = PathHelper.NormalizeDirectorySlashes(root.AsString); return new Purl(this.AsString.Substring(rootPath.Length)); }
public ProjectManifestStore FindProjectManifestStore(Purl path) { _log.Info("Loading: " + path.AsString); if (_cache.ContainsKey(path)) { return _cache[path]; } ProjectManifestStore manifestStore = new ProjectManifestStore(path, ReadManifests(path)); _cache[manifestStore.RootDirectory] = manifestStore; return manifestStore; }
private ProjectManifest ReadProjectManifest(Purl path) { using (StreamReader stream = new StreamReader(_fileSystem.OpenFile(path.AsString))) { ProjectManifest manifest = _serializer.DeserializeString(stream.ReadToEnd()); if (!manifest.IsAcceptableFileName(path)) { throw new InvalidOperationException("Project reference manifest and project name should match: " + path); } return manifest; } }
private IList<ProjectManifest> ReadManifests(Purl directory) { List<ProjectManifest> manifests = new List<ProjectManifest>(); if (_fileSystem.IsDirectory(directory.AsString)) { foreach (string fileName in _fileSystem.GetFiles(directory.AsString, "*." + ProjectManifest.Extension)) { manifests.Add(ReadProjectManifest(new Purl(fileName))); } } return manifests; }
public Repository FindRepository(Purl path) { Purl manifestPath = path.Join("Manifest.xml"); if (!_fileSystem.IsFile(manifestPath.AsString)) { Console.WriteLine("Creating new repository: " + path.AsString); _log.Info("Creating new repository: " + path.AsString); return Hydrate(new Repository(), manifestPath); } _log.Info("Opening: " + path.AsString); using (StreamReader stream = new StreamReader(_fileSystem.OpenFile(manifestPath.AsString))) { return Hydrate(_serializer.DeserializeString(stream.ReadToEnd()), manifestPath); } }
public IncludeExclude Includes(Purl path) { foreach (IDecidesInclusion child in _rules) { switch (child.Includes(path)) { case IncludeExclude.Include: return IncludeExclude.Include; case IncludeExclude.Exclude: return IncludeExclude.Exclude; case IncludeExclude.Unknown: break; } } return _default; }
private void CopyFiles(FileSet fileSet, Purl destiny, bool overwrite) { if (!_fileSystem.IsDirectory(destiny.AsString)) { _fileSystem.CreateDirectory(destiny.AsString); } int filesSoFar = 0; foreach (FileSystemFile file in fileSet.Files) { Purl fileDestiny = destiny.Join(file.Path.ChangeRoot(fileSet.FindCommonDirectory())); fileDestiny.CreateParentDirectory(); _fileSystem.CopyFile(file.Purl.AsString, fileDestiny.AsString, overwrite); filesSoFar++; DistributionDomainEvents.OnProgress(this, new FileCopyProgressEventArgs(filesSoFar / (double)fileSet.Count, file, destiny)); } }
public static Archive ReadZip(Purl path) { ZipFile zip = new ZipFile(path.AsString); Archive archive = new Archive(path, zip); foreach (ZipEntry entry in zip) { if (!entry.IsDirectory) { Purl entryPath = new Purl(entry.Name); ArchivedFileInZip fileInZip = new ArchivedFileInZip(entryPath, zip, entry); ManifestEntry manifestEntry = new ManifestEntry(entryPath, fileInZip); archive.Add(manifestEntry); } } return archive; }
public FileSystemFile WriteZip(Purl path) { _pathOfArchive = path; _totalBytes = _archive.UncompressedBytes; _otherBytesSoFar = 0; using (ZipOutputStream zip = OpenZipStream(path)) { foreach (ManifestEntry entry in _archive.Entries) { using (Stream source = entry.FileAsset.OpenForReading()) { _currentEntry = entry; ZipEntry zipEntry = new ZipEntry(entry.ArchivePath.AsString); zipEntry.DateTime = entry.FileAsset.ModifiedAt; zip.PutNextEntry(zipEntry); StreamHelper.Copy(source, zip, ReportProgress); zip.CloseEntry(); _otherBytesSoFar += entry.UncompressedLength; } } } return FileSystemFileFactory.CreateFile(path); }
public ProjectStructure(Purl root) { _root = root; }
public PowershellHook(Purl path) : base(path) { }
public CmdExecHook(Purl path) : base(path) { }
public FileSystemDirectory(Purl path) : base(path) { }
public RootDirectoryConfiguration(Purl path) : base(path) { }
public IncludeExclude IncludesDirectory(Purl path) { return _directoryRules.Includes(path); }
public IncludeExclude IncludesFile(Purl path) { return _fileRules.Includes(path); }
public ManifestEntry(Purl archivePath, FileAsset fileAsset) { _archivePath = archivePath; _fileAsset = fileAsset; }
public ProjectDependencyDirectory(Project project, ArchivedProject dependency) { _dependency = dependency; _path = project.DependencyPackageDirectoryFor(dependency); _manifests = Infrastructure.ProjectManifestRepository.FindProjectManifestStore(_path); }
protected ArchivedFile(Purl path) { _path = path; }
public RunnableHook(Purl path) { _path = path; }
public bool IsAcceptableFileName(Purl path) { return this.FileName.Equals(path.Name, StringComparison.InvariantCultureIgnoreCase); }
public ArchivedFileInZip(Purl path, ZipFile zipFile, ZipEntry zipEntry) : base(path) { _zipFile = zipFile; _zipEntry = zipEntry; }