Exemple #1
0
        public ITask CreateExtract()
        {
            return(Build("Extract ARC", task =>
            {
                var files = GetInputFiles(task);
                if (!files.Any())
                {
                    task.Message = "No input files.";
                    return false;
                }

                ParallelProgress(task, files, file =>
                {
                    using var stream = OpenRead(task, file);

                    var entries = _arcStreamReader.Read(stream).ToArray();
                    var index = 0;

                    foreach (var entry in entries)
                    {
                        task.Progress = index / (float)entries.Length;
                        task.Message = $"Extracting {entry.Name}";
                        using var outFile = OpenWriteSingle(task, file, _ => entry.Name);
                        outFile.Write(_arcLzDecoder.Decode(entry.Data));
                        outFile.Flush();
                    }
                });

                return true;
            }));
        }
Exemple #2
0
        public ArcFile Decompress(ArcFile file)
        {
            var data = file.CompressedSize == file.DecompressedSize
                ? file.Data.ToArray()
                : _arcLzDecoder.Decode(file.Data);

            return(new ArcFile
            {
                Name = file.Name,
                DecompressedSize = data.Length,
                CompressedSize = data.Length,
                Data = data
            });
        }