public IArchiveContent GetArchiveContent(string filePath) { var archData = new ArchiveContent(); using (FileStream fs = File.OpenRead(filePath)) { var reader = new RawDataReader(fs, Encoding.UTF8); byte[] sign = Signature; foreach (byte b in sign) { if (reader.ReadByte() != b) { throw new CorruptedFileException(filePath); } } archData.CreationTime = reader.ReadTime(); int len = reader.ReadInt(); archData.ArchiveHeader = reader.ReadBytes(len); archData.Files = FilesBag.GetContent(fs); return(archData); } }
public static void Main(string[] args) { DotNetEnv.Env.Load(); DotNetEnv.Env.TraversePath().Load(); Console.WriteLine("Loading archive"); ArchiveContent.Load(); Console.WriteLine("Loaded!"); CreateHostBuilder(args).Build().Run(); }
public async Task Get() { string path = Request.Path + Request.QueryString; path = path.Split('#')[0]; var entry = ArchiveContent.TryFetchEntry(path); if (entry == null) { await Send404(); return; } var stream = await entry.FetchStream(); if (stream == null) { await Send404(); return; } Response.StatusCode = entry.status; if (entry.contentType != null) { Response.Headers.Add("content-type", entry.contentType); } if (entry.location != null) { Response.Headers.Add("location", entry.location); } await stream.CopyToAsync(Response.Body); stream.Close(); }
/// <summary> /// Clears all controls. /// </summary> public void ClearView() { _archiveContent = null; _archiveExtractor = null; _metadataListView.Items.Clear(); _archiveItemInfoListView.Items.Clear(); _foldersTreeView.Nodes.Clear(); _attributesTabPage.Text = "Attributes (0)"; _fileIdLabel.Text = ""; _classificationLabel.Text = ""; _idMatchTypeLabel.Text = ""; _textSourceLabel.Text = ""; _contentResultLabel.Text = ""; _errorMessageLabel.Text = ""; _sha1BinaryHashLabel.Text = ""; _sha1ContentHashLabel.Text = ""; _fileEntropyLabel.Text = ""; _isEncryptedLabel.Text = ""; _attributesTextBox.Text = ""; _totalItemCountLabel.Text = ""; }
/// <summary> /// Displays archive content. /// </summary> /// <param name="archiveContent"></param> /// <param name="archiveExtractor"></param> /// <param name="filename"></param> /// <param name="filelength"></param> public void UpdateContentView(ArchiveContent archiveContent, IArchiveExtractor archiveExtractor, string filename, long filelength) { ClearView(); _archiveContent = archiveContent; _archiveExtractor = archiveExtractor; _fileNameLabel.Text = filename; _fileSizeLabel.Text = string.Format("{0:###,###,###,###}", filelength); if (_archiveContent == null) { return; } _fileIdLabel.Text = archiveContent.FormatId.ID.ToString(); _classificationLabel.Text = archiveContent.FormatId.Classification.ToString(); _idMatchTypeLabel.Text = archiveContent.FormatId.MatchType.ToString(); _textSourceLabel.Text = archiveContent.TextSourceType.ToString(); _contentResultLabel.Text = archiveContent.Result.ToString(); _errorMessageLabel.Text = archiveContent.ErrorMessage != null ? archiveContent.ErrorMessage : ""; _sha1BinaryHashLabel.Text = archiveContent.SHA1BinaryHash != null ? archiveContent.SHA1BinaryHash : ""; _sha1ContentHashLabel.Text = archiveContent.SHA1ContentHash != null ? archiveContent.SHA1ContentHash : ""; _fileEntropyLabel.Text = archiveContent.FileEntropy != null?archiveContent.FileEntropy.Value.ToString("F7") : ""; _isEncryptedLabel.Text = archiveContent.FormatId.IsEncrypted.ToString(); _totalItemCountLabel.Text = archiveContent.ItemCount.ToString(); // // Set metadata: // _metdataTabPage.Text = string.Format("Metadata ({0})", archiveContent.Metadata.Count + archiveContent.CustomMetadata.Count); if (archiveContent.Metadata.Count > 0 || archiveContent.CustomMetadata.Count > 0) { MetadataHelper.PopulateListViewWithMetadata(_metadataListView, archiveContent.Metadata); MetadataHelper.PopulateListViewWithMetadata(_metadataListView, archiveContent.CustomMetadata, false); } UpdateArchiveItemListView(); // // Set Attributes: // if (archiveContent.Attributes.Count > 0) { var attributeBuilder = new StringBuilder(); foreach (var flag in archiveContent.Attributes) { attributeBuilder.AppendLine(flag.ToString()); } _attributesTextBox.Text = attributeBuilder.ToString(); } else { _attributesTextBox.Text = ""; } _attributesTabPage.Text = string.Format("Attributes ({0})", archiveContent.Attributes.Count); // // // Set folders (note: not all archives have internally stored email folders): // if (archiveContent.Root != null) { SetFolders(archiveContent.Root, _foldersTreeView); if (_foldersTreeView.Nodes.Count > 0) { _foldersTreeView.ExpandAll(); _foldersTreeView.SelectedNode = _foldersTreeView.Nodes[0]; } } }
/// <summary> /// Constructor. /// </summary> /// <param name="archiveContent"></param> /// <param name="archiveExtractor"></param> /// <param name="host"></param> public ArchiveExtractorHelper(ArchiveContent archiveContent, IArchiveExtractor archiveExtractor, IHostUI host) { _archiveContent = archiveContent; _archiveExtractor = archiveExtractor; _hostUI = host; }