public override async Task CopyTo(CompressedFile sourceMetadata, Stream destinationStream) { if (_cd.FileExists(sourceMetadata.FullName)) { var fs = _cd.OpenFile(sourceMetadata.FullName, FileMode.Open, FileAccess.Read); await fs.CopyToAsync(destinationStream); } }
public override async Task CopyTo(CompressedFile sourceMetadata, Stream destinationStream) { using (var entry = _arc.Entries.SingleOrDefault(x => x.FullName == sourceMetadata.FullName)?.Open()) { if (entry != null) { await entry.CopyToAsync(destinationStream); } } }
public override byte[] GetFileBin(CompressedFile metadata) { var entry = _arc.Entries.SingleOrDefault(x => x.FullName == metadata.FullName)?.Open(); if (entry == null) { return(null); } byte[] data; using (var ms = new MemoryStream()) { entry.CopyTo(ms); data = ms.ToArray(); } return(data); }
public override byte[] GetFileBin(CompressedFile metadata) { if (!_cd.FileExists(metadata.FullName)) { return(null); } var fs = _cd.OpenFile(metadata.FullName, FileMode.Open, FileAccess.Read); byte[] data; using (var ms = new MemoryStream()) { fs.CopyTo(ms); data = ms.ToArray(); } return(data); }
public override CompressedFile FindFile(string fullPath) { if (!_cd.FileExists(fullPath)) { return(null); } var content = new CompressedFile { ArcPath = Path, FullName = fullPath }; content.Name = content.FullName.Split('\\').LastOrDefault(); return(content); }
public override CompressedFile FindFile(string fullPath) { ZipArchiveEntry item; if ((item = _arc.Entries.SingleOrDefault(x => x.FullName == fullPath)) == null) { return(null); } var content = new CompressedFile { ArcPath = Path, FullName = item.FullName, Name = item.Name }; return(content); }
public override async Task <byte[]> GetFileBinAsync(CompressedFile metadata) { if (!System.IO.File.Exists(metadata.FullName)) { return(null); } var fs = System.IO.File.Open(metadata.FullName, FileMode.Open, FileAccess.Read); byte[] data; using (var ms = new MemoryStream()) { await fs.CopyToAsync(ms); data = ms.ToArray(); } return(data); }
public override IEnumerable <CompressedFile> ListItem() { var itemList = new List <CompressedFile>(); var listItem = ListFiles(""); foreach (var item in listItem) { var content = new CompressedFile { ArcPath = Path, FullName = item.Remove(item.Length - 2) }; content.Name = content.FullName.Split('\\').LastOrDefault(); itemList.Add(content); } return(itemList); }
public override IEnumerable <CompressedFile> ListItem() { var itemList = new List <CompressedFile>(); foreach (var item in _arc.Entries) { if (item.Name == "") { continue; } var content = new CompressedFile { ArcPath = Path, FullName = item.FullName, Name = item.Name }; itemList.Add(content); } return(itemList); }
private LstFile LstParser(string line, CompressedIo archive, CompressedFile metadata) { var splitLine = line.Split(','); var updateLst = new LstFile { Source = splitLine[0] != "0" ? splitLine[1] : splitLine[2], Destination = splitLine[2], FileSize = ulong.Parse(splitLine[3]), Crc = splitLine[4], Revision = int.Parse(splitLine[5]) }; if (archive.GetType() == typeof(ZipArchiveIo)) { var outerPath = metadata.FullName.Split('/').ToList(); var innerPath = updateLst.Source.Replace("\\", "/").Split('/').ToList(); outerPath.RemoveAt(outerPath.Count - 1); if (splitLine[0] == "0") { outerPath.Add("data"); } foreach (var item in innerPath) { if (item == "..") { outerPath.RemoveAt(outerPath.Count - 1); } else { outerPath.Add(item); } } var query = outerPath[0]; outerPath.RemoveAt(0); foreach (var item in outerPath) { if (item != "") { query += "/" + item; } } updateLst.SrcFileMetadata = archive.FindFile(query); } else { var outerPath = metadata.FullName.Replace("\\", "/").Split('/').ToList(); var innerPath = updateLst.Source.Replace("\\", "/").Split('/').ToList(); outerPath.RemoveAt(outerPath.Count - 1); if (splitLine[0] == "0") { outerPath.Add("data"); } foreach (var item in innerPath) { if (item == "..") { outerPath.RemoveAt(outerPath.Count - 1); } else { outerPath.Add(item); } } var query = ""; if (archive.GetType() == typeof(RawDir)) { query = outerPath[0]; outerPath.RemoveAt(0); } foreach (var item in outerPath) { if (item != "") { query += "\\" + item; } } updateLst.SrcFileMetadata = archive.FindFile(query); } return(updateLst); }
public abstract Task CopyTo(CompressedFile sourceMetadata, Stream destinationStream);
public abstract Task <byte[]> GetFileBinAsync(CompressedFile metadata);
public abstract byte[] GetFileBin(CompressedFile metadata);