public static bool TryGetInArchive(string path, IArchiveInfo archiveInfo, out FileType type) { foreach (var possibleType in FileTypes) { if (possibleType == OctetStream) { continue; } if (possibleType.CheckInArchive(path, archiveInfo)) { type = possibleType; return(true); } } type = OctetStream; return(false); }
private void WriteToSubStream(ArchiveWriteStream MainStream, IArchiveInfo Info) { var SubStream = new ArchiveWriteStream(); var SubEncoder = new ArchiveEncoder(SubStream); Info.Encode(SubEncoder); SubEncoder.Flush(); MainStream.WriteStream(SubStream); }
public override bool CheckInArchive(string path, IArchiveInfo archiveInfo) { if (ExtensionIsAnyOf(path, _extensions) == false) { return(false); } return(true); }
public bool Decode(IArchiveInfo Arc) { try { Arc.Decode(Decoder_); return(true); } catch (Exception Ex) { LLogger.LError(Ex.Message); return(false); } }
public bool Encode(IArchiveInfo Arc) { try { Arc.Encode(Encoder_); Encoder_.Flush(); return(true); } catch (Exception Ex) { LLogger.LError(Ex.Message); return(false); } }
/// <summary> /// Search a directory or archive and add any files or sub-directories /// to the list of candidates currently being resolved /// </summary> /// <param name="candidates">Candidates currently being resolved</param> public void Explode(SubmissionCandidates candidates, string workingDirectory) { if (IsArchive) { // Archives in Archives!! if (IsArchivedFile) { string exportPath = Path.Combine(workingDirectory, HunterConfig.GalileoDefaultDataFolder + Path.DirectorySeparatorChar + "galileo_" + Guid.ToString() + FileExtension); ArchiveInfo.Extract(ReadPath, exportPath); _resolvePath = exportPath; } if (_fileType == FileTypes.Types.Zip) { _archiveInfo = new ZipArchiveInfo(ReadPath); _archiveChildren = new List <SubmissionCandidate>(10); if (_archiveInfo.IsOpen == false) { // Probably best to do something better than this? throw new Exception("Could not open archive???"); } foreach (var fileName in _archiveInfo) { SubmissionCandidate candidate = candidates.Add(fileName, _depth + 1, this); _archiveChildren.Add(candidate); } // We leave _archiveInfo open, because later the files // will want to be inspected and possibly extracted. } } else if (IsDirectory) { System.IO.DirectoryInfo info = new System.IO.DirectoryInfo(ReadPath); foreach (var file in info.EnumerateFiles()) { candidates.Add(file.FullName, _depth + 1, this); } foreach (var directory in info.EnumerateDirectories()) { candidates.Add(directory.FullName, _depth + 1, this); } } }
public static bool IsArchiveInArchive(string path, IArchiveInfo archiveInfo, out FileType type) { if (Zip.CheckInArchive(path, archiveInfo)) { type = Zip; return(true); } // Add more here, when as needed. :D type = None; return(false); }
public override bool CheckInArchive(string path, IArchiveInfo archiveInfo) { return(true); }
public abstract bool CheckInArchive(string path, IArchiveInfo archiveInfo);