コード例 #1
0
        public static void SaveTo(IWritableArchive writableArchive, Stream stream, CompressionType compressionType)
        {
            CompressionInfo info = new CompressionInfo();

            info.Type = compressionType;
            writableArchive.SaveTo(stream, info);
        }
コード例 #2
0
        static void Main(string[] args)
        {
            var exeFileName      = Path.GetFileName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName);
            var dir              = System.Environment.CurrentDirectory;
            var userdir          = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments);
            var dirName          = Path.GetFileName(dir);
            var solutionFileName = Directory.GetFiles(dir, ".sln", SearchOption.AllDirectories);

            foreach (var item in solutionFileName)
            {
                IgnoreExt.Add(Path.GetFileNameWithoutExtension(item) + ".sdf");
                IgnoreExt.Add(Path.GetFileNameWithoutExtension(item) + ".opensdf");
            }
            IgnoreExt.Add(exeFileName);

            var filename = Path.Combine(userdir, dirName + DateTime.Now.ToString("_yyyyMMdd_HHmmss") + ".zip");
            var fs       = File.Open(filename, FileMode.CreateNew);
            var ci       = new CompressionInfo();

            ci.Type = CompressionType.LZMA;
            ci.DeflateCompressionLevel = CompressionLevel.BestCompression;
            using (ZipWriter w = new ZipWriter(fs, ci, ""))
            {
                var cDir = new DirectoryInfo(dir);
                ReadFolder(cDir, dir, w);
            }
            fs.Dispose();

            OpenFolder(filename);
        }
コード例 #3
0
 public void SaveTo(Stream stream, CompressionInfo compressionType)
 {
     //reset streams of new entries
     //newEntries.Cast<IWritableArchiveEntry>().ForEach(x => x.Stream.Seek(0, SeekOrigin.Begin));
     Utility.ForEach <IWritableArchiveEntry>(newEntries.Cast <IWritableArchiveEntry>(), (x) => x.Stream.Seek(0, SeekOrigin.Begin));
     SaveTo(stream, compressionType, OldEntries, newEntries);
 }
コード例 #4
0
        public ZipCompressionInfo(CompressionInfo compressionInfo)
        {
            switch (compressionInfo.Type)
            {
            case CompressionType.None:
                this.Compression = ZipCompressionMethod.None;
                return;

            case CompressionType.BZip2:
                this.Compression = ZipCompressionMethod.BZip2;
                return;

            case CompressionType.PPMd:
                this.Compression = ZipCompressionMethod.PPMd;
                return;

            case CompressionType.Deflate:
                this.DeflateCompressionLevel = compressionInfo.DeflateCompressionLevel;
                this.Compression             = ZipCompressionMethod.Deflate;
                return;

            case CompressionType.LZMA:
                this.Compression = ZipCompressionMethod.LZMA;
                return;
            }
            throw new InvalidFormatException("Invalid compression method: " + compressionInfo.Type);
        }
コード例 #5
0
        /// <summary>
        /// Create an archive from a directory. It will iterate through all directories recursively.
        /// </summary>
        /// <param name="folderPath">Folder/directory to archive</param>
        /// <param name="outputFile">Ouput path, including file name, of the resulting archive</param>
        /// <param name="useZip">true for zip format; false for tar.gz format</param>
        static public void CreateArchive(string folderPath, string outputFile, bool useZip)
        {
            using (var outputStream = File.OpenWrite(outputFile))
            {
                ArchiveType atype;
                var         cinfo = new CompressionInfo();

                if (useZip)
                {
                    atype      = ArchiveType.Zip;
                    cinfo.Type = CompressionType.Deflate;
                    cinfo.DeflateCompressionLevel = SharpCompress.Compressor.Deflate.CompressionLevel.Default;
                }
                else
                {
                    atype      = ArchiveType.Tar;
                    cinfo.Type = CompressionType.GZip;
                    cinfo.DeflateCompressionLevel = SharpCompress.Compressor.Deflate.CompressionLevel.Default;
                }

                using (var awriter = WriterFactory.Open(outputStream, atype, cinfo))
                {
                    awriter.WriteAll(folderPath, "*", SearchOption.AllDirectories);
                }
            }
        }
コード例 #6
0
        public static IWriter Open(Stream stream, ArchiveType archiveType, CompressionType compressionType)
        {
            CompressionInfo compressionInfo = new CompressionInfo();

            compressionInfo.Type = compressionType;
            return(Open(stream, archiveType, compressionInfo));
        }
コード例 #7
0
 public static void SaveTo <TEntry, TVolume>(this AbstractWritableArchive <TEntry, TVolume> writableArchive,
                                             string filePath, CompressionInfo compressionInfo)
     where TEntry : IArchiveEntry
     where TVolume : IVolume
 {
     writableArchive.SaveTo(new FileInfo(filePath), compressionInfo);
 }
コード例 #8
0
ファイル: ZipWriter.cs プロジェクト: RainsSoft/sharpcompress
        private int WriteHeader(string filename, DateTime?modificationTime, CompressionInfo compressionInfo)
        {
            ZipCompressionInfo info = (compressionInfo != null) ? new ZipCompressionInfo(compressionInfo) : this.zipCompressionInfo;

            byte[] bytes = ArchiveEncoding.Default.GetBytes(filename);
            base.OutputStream.Write(BitConverter.GetBytes((uint)0x4034b50), 0, 4);
            byte[] buffer = new byte[2];
            buffer[0] = 0x3f;
            base.OutputStream.Write(buffer, 0, 2);
            HeaderFlags flags = (ArchiveEncoding.Default == Encoding.UTF8) ? HeaderFlags.UTF8 : ((HeaderFlags)0);

            if (!base.OutputStream.CanSeek)
            {
                flags = (HeaderFlags)((ushort)(flags | HeaderFlags.UsePostDataDescriptor));
                if (info.Compression == ZipCompressionMethod.LZMA)
                {
                    flags = (HeaderFlags)((ushort)(flags | HeaderFlags.Bit1));
                }
            }
            base.OutputStream.Write(BitConverter.GetBytes((ushort)flags), 0, 2);
            base.OutputStream.Write(BitConverter.GetBytes((ushort)info.Compression), 0, 2);
            base.OutputStream.Write(BitConverter.GetBytes(Utility.DateTimeToDosTime(modificationTime)), 0, 4);
            buffer = new byte[12];
            base.OutputStream.Write(buffer, 0, 12);
            base.OutputStream.Write(BitConverter.GetBytes((ushort)bytes.Length), 0, 2);
            base.OutputStream.Write(BitConverter.GetBytes((ushort)0), 0, 2);
            base.OutputStream.Write(bytes, 0, bytes.Length);
            return(30 + bytes.Length);
        }
コード例 #9
0
 public void SaveTo(Stream stream, CompressionInfo compressionType)
 {
     Utility.ForEach <IWritableArchiveEntry>(Enumerable.Cast <IWritableArchiveEntry>(this.newEntries), delegate(IWritableArchiveEntry x) {
         x.Stream.Seek(0L, SeekOrigin.Begin);
     });
     this.SaveTo(stream, compressionType, this.OldEntries, this.newEntries);
 }
コード例 #10
0
        private int WriteHeader(string filename, DateTime?modificationTime, CompressionInfo compressionInfo = null)
        {
            var explicitZipCompressionInfo = compressionInfo != null ? new ZipCompressionInfo(compressionInfo) : this.zipCompressionInfo;

            byte[] encodedFilename = ArchiveEncoding.Default.GetBytes(filename);

            OutputStream.Write(BitConverter.GetBytes(ZipHeaderFactory.ENTRY_HEADER_BYTES), 0, 4);
            OutputStream.Write(new byte[] { 63, 0 }, 0, 2); //version
            HeaderFlags flags = ArchiveEncoding.Default == Encoding.UTF8 ? HeaderFlags.UTF8 : (HeaderFlags)0;

            if (!OutputStream.CanSeek)
            {
                flags |= HeaderFlags.UsePostDataDescriptor;
                if (explicitZipCompressionInfo.Compression == ZipCompressionMethod.LZMA)
                {
                    flags |= HeaderFlags.Bit1; // eos marker
                }
            }
            OutputStream.Write(BitConverter.GetBytes((ushort)flags), 0, 2);
            OutputStream.Write(BitConverter.GetBytes((ushort)explicitZipCompressionInfo.Compression), 0, 2); // zipping method
            OutputStream.Write(BitConverter.GetBytes(modificationTime.DateTimeToDosTime()), 0, 4);
            // zipping date and time
            OutputStream.Write(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0, 12);
            // unused CRC, un/compressed size, updated later
            OutputStream.Write(BitConverter.GetBytes((ushort)encodedFilename.Length), 0, 2); // filename length
            OutputStream.Write(BitConverter.GetBytes((ushort)0), 0, 2);                      // extra length
            OutputStream.Write(encodedFilename, 0, encodedFilename.Length);

            return(6 + 2 + 2 + 4 + 12 + 2 + 2 + encodedFilename.Length);
        }
コード例 #11
0
        public TarWriter(Stream destination, CompressionInfo compressionInfo)
            : base(ArchiveType.Tar)
        {
            if (!destination.CanWrite)
            {
                throw new ArgumentException("Tars require writable streams.");
            }
            switch (compressionInfo.Type)
            {
            case CompressionType.None:
                break;

            case CompressionType.BZip2:
            {
                destination = new BZip2Stream(destination, CompressionMode.Compress, false);
            }
            break;

            case CompressionType.GZip:
            {
                destination = new GZipStream(destination, CompressionMode.Compress, false);
            }
            break;

            default:
            {
                throw new InvalidFormatException("Tar does not support compression: " + compressionInfo.Type);
            }
            }
            InitalizeStream(destination, false);
        }
コード例 #12
0
        public static IWriter Open(Stream stream, ArchiveType archiveType, CompressionInfo compressionInfo)
        {
            switch (archiveType)
            {
            case ArchiveType.GZip:
            {
                if (compressionInfo.Type != CompressionType.GZip)
                {
                    throw new InvalidFormatException("GZip archives only support GZip compression type.");
                }
                return(new GZipWriter(stream));
            }

            case ArchiveType.Zip:
            {
                return(new ZipWriter(stream, compressionInfo, null));
            }

            case ArchiveType.Tar:
            {
                return(new TarWriter(stream, compressionInfo));
            }

            default:
            {
                throw new NotSupportedException("Archive Type does not have a Writer: " + archiveType);
            }
            }
        }
コード例 #13
0
        public static void CompressAsZip(string srcFolder, string tarZipFile, ZipCompressType type = ZipCompressType.DEFLATE)
        {
            CompressionInfo info = new CompressionInfo();

            switch (type)
            {
            case ZipCompressType.None: info.Type = CompressionType.None; break;

            case ZipCompressType.DEFLATE: info.Type = CompressionType.Deflate; break;

            case ZipCompressType.BZip2: info.Type = CompressionType.BZip2; break;

            case ZipCompressType.LZMA: info.Type = CompressionType.LZMA; break;

            case ZipCompressType.PPMd: info.Type = CompressionType.PPMd; break;

            default: info.Type = CompressionType.Deflate; break;
            }
            using (var archive = ArchiveFactory.Create(ArchiveType.Zip))
            {
                archive.AddAllFromDirectory(srcFolder);
                var fs = File.Open(tarZipFile, FileMode.CreateNew);
                archive.SaveTo(fs, info);
                fs.Close();
            }
        }
コード例 #14
0
        public IEnumerable <CompressionInfo> Get()
        {
            var path = _env.ContentRootPath;

            path = Path.Combine(path, "Files");
            string pathInfo = Path.Combine(path, "Info");

            string pathHistorial = Path.Combine(pathInfo, "Historial.txt");

            if (!System.IO.File.Exists(pathHistorial))
            {
                System.IO.File.Create(pathHistorial);
            }
            string cadenaHistorial = System.IO.File.ReadAllText(pathHistorial);

            string[] cadenas = cadenaHistorial.Split('/');
            List <CompressionInfo> InfoList = new List <CompressionInfo>();

            foreach (var item in cadenas)
            {
                CompressionInfo compInfo = new CompressionInfo();
                string[]        valores  = item.Split(';');

                compInfo.originalName        = valores[0];
                compInfo.compressedFilePath  = valores[1];
                compInfo.compressionRatio    = Convert.ToDouble(valores[2]);
                compInfo.compressionFactor   = Convert.ToDouble(valores[3]);
                compInfo.reductionPercentage = Convert.ToDouble(valores[4]);

                InfoList.Add(compInfo);
            }

            return(InfoList);
        }
コード例 #15
0
 /// <summary>
 /// Checks to see if we currently support compressing to the requested compression type.
 /// </summary>
 /// <param name="compression">The compression type to check</param>
 /// <returns>Whether or not it is supported.  This is not related to whether <u>decompression</u> of this method is supported or not.</returns>
 public static bool SupportsCompression(CompressionInfo compression)
 {
     if (compression == CompressionInfo.JPIP || compression == CompressionInfo.MPEG2 || compression == CompressionInfo.RLE)
     {
         return(false);
     }
     return(true);
 }
コード例 #16
0
        public static void SaveTo <TEntry, TVolume>(this AbstractWritableArchive <TEntry, TVolume> writableArchive, Stream stream, CompressionType compressionType) where TEntry : IArchiveEntry where TVolume : IVolume
        {
            CompressionInfo info = new CompressionInfo {
                Type = compressionType
            };

            writableArchive.SaveTo(stream, info);
        }
コード例 #17
0
ファイル: ZipWriter.cs プロジェクト: RainsSoft/sharpcompress
 public ZipWriter(Stream destination, CompressionInfo compressionInfo, string zipComment) : base(ArchiveType.Zip)
 {
     this.ppmdProperties     = new PpmdProperties();
     this.entries            = new List <ZipCentralDirectoryEntry>();
     this.zipComment         = zipComment ?? string.Empty;
     this.zipCompressionInfo = new ZipCompressionInfo(compressionInfo);
     base.InitalizeStream(destination, false);
 }
コード例 #18
0
        public ZipWriter(Stream destination, CompressionInfo compressionInfo, string zipComment)
            : base(ArchiveType.Zip)
        {
            this.zipComment = zipComment ?? string.Empty;

            this.zipCompressionInfo = new ZipCompressionInfo(compressionInfo);
            InitalizeStream(destination, false);
        }
コード例 #19
0
 public static void SaveTo(this IWritableArchive writableArchive,
                           FileInfo fileInfo, CompressionInfo compressionInfo)
 {
     using (var stream = fileInfo.Open(FileMode.Create, FileAccess.Write))
     {
         writableArchive.SaveTo(stream, compressionInfo);
     }
 }
コード例 #20
0
ファイル: WriterFactory.cs プロジェクト: radiomonter/Tanki_X
 public static IWriter Open(Stream stream, ArchiveType archiveType, CompressionInfo compressionInfo)
 {
     if (archiveType != ArchiveType.Tar)
     {
         throw new NotSupportedException("Archive Type does not have a Writer: " + archiveType);
     }
     return(new TarWriter(stream, compressionInfo));
 }
コード例 #21
0
        internal ZipWriter(Stream destination, CompressionInfo compressionInfo, string zipComment, string password = null, bool leaveOpen = false)
            : base(ArchiveType.Zip)
        {
            this.zipComment = zipComment ?? string.Empty;

            this.zipCompressionInfo = new ZipCompressionInfo(compressionInfo);
            this.password           = password;

            InitalizeStream(destination, !leaveOpen);
        }
コード例 #22
0
 public static void SaveTo <TEntry, TVolume>(this AbstractWritableArchive <TEntry, TVolume> writableArchive,
                                             FileInfo fileInfo, CompressionInfo compressionInfo)
     where TEntry : IArchiveEntry
     where TVolume : IVolume
 {
     using (var stream = fileInfo.Open(FileMode.Create, FileAccess.Write))
     {
         writableArchive.SaveTo(stream, compressionInfo);
     }
 }
コード例 #23
0
        static void Main(string[] args)
        {
            string          testStr     = "This is a dummy text";
            string          outFile     = "output.jelly";
            CompressionInfo encodedFile = HuffmanCompressor.Encode(testStr, outFile);

            Console.WriteLine($"Successfully created : {encodedFile}");
            Console.WriteLine("Decoding..");
            string decodedText = HuffmanCompressor.Decode(outFile);

            Console.WriteLine(decodedText);
        }
コード例 #24
0
 static void PrintCompressionInfo(CompressionInfo compressionInfo)
 {
     Console.WriteLine("\n\nCompression info:");
     Console.WriteLine("HasCompressedImage: {0}", compressionInfo.HasCompressedImage);
     Console.WriteLine("CompressionStatus: {0} ({0:D})", compressionInfo.CompressionStatus);
     Console.WriteLine("Lossy: {0}", compressionInfo.Lossy);
     Console.WriteLine("Width: {0}", compressionInfo.Width);
     Console.WriteLine("Height: {0}", compressionInfo.Height);
     Console.WriteLine("PixelType: {0} ({0:D}) ", compressionInfo.PixelType);
     Console.WriteLine("DecompressedImageSize: {0}", compressionInfo.DecompressedImageSize);
     Console.WriteLine("DecompressedPayloadSize: {0}", compressionInfo.DecompressedPayloadSize);
 }
コード例 #25
0
        /// <summary>
        /// Initializes the archiving operation and waits for the result.
        /// </summary>
        /// <param name="key">The type of the archive.</param>
        /// <param name="archiveName">The name of the archive.</param>
        private async Task <Result> InitOperation(Archives.ArchiveType key, string archiveName)
        {
            SetOperationActive(true);
            var totalSize = await _controller.CheckFileSizes(_selectedFiles);

            var info = new CompressionInfo(key, totalSize)
            {
                ArchiveName   = archiveName,
                SelectedFiles = _selectedFiles
            };

            return(await _controller.StartButtonAction(OnProgressUpdate, info));
        }
コード例 #26
0
ファイル: NativeHelper.cs プロジェクト: zmyer/service-fabric
 public static extern IntPtr FCICreate(
     [MarshalAs(UnmanagedType.LPStruct)] CabError erf,
     FCIFilePlacedMethod filePlaced,
     MemAllocMethod malloc,
     MemFreeMethod free,
     FCIOpenMethod open,
     FCIReadMethod read,
     FCIWriteMethod write,
     FCICloseMethod close,
     FCISeekMethod seek,
     FCIDeleteMethod delete,
     FCIGetTempFileMethod getTempFile,
     [In, Out][MarshalAs(UnmanagedType.LPStruct)] CompressionInfo cab,
     IntPtr data);
コード例 #27
0
ファイル: TarArchive.cs プロジェクト: RainsSoft/sharpcompress
 protected override void SaveTo(Stream stream, CompressionInfo compressionInfo, IEnumerable <TarArchiveEntry> oldEntries, IEnumerable <TarArchiveEntry> newEntries)
 {
     using (TarWriter writer = new TarWriter(stream, compressionInfo))
     {
         foreach (TarArchiveEntry entry in Enumerable.Where <TarArchiveEntry>(Enumerable.Concat <TarArchiveEntry>(oldEntries, newEntries), delegate(TarArchiveEntry x) {
             return(!x.IsDirectory);
         }))
         {
             using (Stream stream2 = entry.OpenEntryStream())
             {
                 writer.Write(entry.Key, stream2, entry.LastModifiedTime, new long?(entry.Size));
             }
         }
     }
 }
コード例 #28
0
ファイル: ZipArchive.cs プロジェクト: RainsSoft/sharpcompress
 protected override void SaveTo(Stream stream, CompressionInfo compressionInfo, IEnumerable <ZipArchiveEntry> oldEntries, IEnumerable <ZipArchiveEntry> newEntries)
 {
     using (ZipWriter writer = new ZipWriter(stream, compressionInfo, string.Empty))
     {
         foreach (ZipArchiveEntry entry in Enumerable.Where <ZipArchiveEntry>(Enumerable.Concat <ZipArchiveEntry>(oldEntries, newEntries), delegate(ZipArchiveEntry x) {
             return(!x.IsDirectory);
         }))
         {
             using (Stream stream2 = entry.OpenEntryStream())
             {
                 writer.Write(entry.Key, stream2, entry.LastModifiedTime, string.Empty, null);
             }
         }
     }
 }
コード例 #29
0
ファイル: ZipArchive.cs プロジェクト: tiansfather/TFA.Vote
 protected override void SaveTo(Stream stream, CompressionInfo compressionInfo,
                                IEnumerable <ZipArchiveEntry> oldEntries,
                                IEnumerable <ZipArchiveEntry> newEntries)
 {
     using (var writer = new ZipWriter(stream, compressionInfo, string.Empty))
     {
         foreach (var entry in oldEntries.Concat(newEntries)
                  .Where(x => !x.IsDirectory))
         {
             using (var entryStream = entry.OpenEntryStream())
             {
                 writer.Write(entry.Key, entryStream, entry.LastModifiedTime, string.Empty);
             }
         }
     }
 }
コード例 #30
0
 protected override void SaveTo(Stream stream, CompressionInfo compressionInfo,
                                IEnumerable <TarArchiveEntry> oldEntries,
                                IEnumerable <TarArchiveEntry> newEntries)
 {
     using (var writer = new TarWriter(stream, compressionInfo))
     {
         foreach (var entry in oldEntries.Concat(newEntries)
                  .Where(x => !x.IsDirectory))
         {
             using (var entryStream = entry.OpenEntryStream())
             {
                 writer.Write(entry.FilePath, entryStream, entry.LastModifiedTime, entry.Size);
             }
         }
     }
 }
コード例 #31
0
ファイル: DobozDecoder.cs プロジェクト: jinjingcai2014/LibZ
		/// <summary>Decodes the specified input.</summary>
		/// <param name="input">The input.</param>
		/// <param name="inputOffset">The input offset.</param>
		/// <param name="inputLength">Length of the input.</param>
		/// <returns>Decoded buffer.</returns>
		public static byte[] Decode(
			byte[] input, int inputOffset, int inputLength)
		{
			CheckArguments(
				input, inputOffset, ref inputLength);

#if DOBOZ_SAFE
			var src = input;
#else
			fixed (byte* src = input)
#endif
			{
				var info = new CompressionInfo();
				if (GetCompressionInfo(src, inputOffset, inputLength, ref info) != Result.RESULT_OK)
					throw new ArgumentException("Corrupted input data");

				var outputLength = info.uncompressedSize;
				var output = new byte[outputLength];

#if DOBOZ_SAFE
				var dst = output;
#else
				fixed (byte* dst = output)
#endif
				{
					if (Decompress(src, inputOffset, inputLength, dst, 0, outputLength) != Result.RESULT_OK)
						throw new ArgumentException("Corrupted data");

					return output;
				}
			}
		}
コード例 #32
0
ファイル: DobozDecoder.cs プロジェクト: jinjingcai2014/LibZ
		/// <summary>Decodes the specified input.</summary>
		/// <param name="input">The input.</param>
		/// <param name="inputOffset">The input offset.</param>
		/// <param name="inputLength">Length of the input.</param>
		/// <param name="output">The output.</param>
		/// <param name="outputOffset">The output offset.</param>
		/// <param name="outputLength">Length of the output.</param>
		/// <returns>Number of decoded bytes.</returns>
		public static int Decode(
			byte[] input, int inputOffset, int inputLength,
			byte[] output, int outputOffset, int outputLength)
		{
			CheckArguments(
				input, inputOffset, ref inputLength,
				output, outputOffset, ref outputLength);

#if DOBOZ_SAFE
			var src = input;
#else
			fixed (byte* src = input)
#endif
			{
				var info = new CompressionInfo();
				if (GetCompressionInfo(src, inputOffset, inputLength, ref info) != Result.RESULT_OK)
					throw new ArgumentException("Corrupted input data");

				if (outputLength < info.uncompressedSize)
					throw new ArgumentException("Output buffer is too small");

				outputLength = info.uncompressedSize;

#if DOBOZ_SAFE
				var dst = output;
#else
				fixed (byte* dst = output)
#endif
				{
					if (Decompress(src, inputOffset, inputLength, dst, outputOffset, outputLength) != Result.RESULT_OK)
						throw new ArgumentException("Corrupted data");
					return outputLength;
				}
			}
		}
コード例 #33
0
ファイル: DobozDecoder.cs プロジェクト: jinjingcai2014/LibZ
		private static Result GetCompressionInfo(byte[] source, int sourceOffset, int sourceSize, ref CompressionInfo compressionInfo)
コード例 #34
0
ファイル: DobozDecoder.cs プロジェクト: jinjingcai2014/LibZ
		private static Result GetCompressionInfo(byte* source, int sourceOffset, int sourceSize, ref CompressionInfo compressionInfo)
#endif
		{
			Debug.Assert(source != null);

			// Decode the header
			var header = new Header();
			var headerSize = 0;
			var decodeHeaderResult = DecodeHeader(ref header, source, sourceOffset, sourceSize, ref headerSize);

			if (decodeHeaderResult != Result.RESULT_OK)
			{
				return decodeHeaderResult;
			}

			// Return the requested info
			compressionInfo.uncompressedSize = header.uncompressedSize;
			compressionInfo.compressedSize = header.compressedSize;
			compressionInfo.version = header.version;

			return Result.RESULT_OK;
		}
コード例 #35
0
ファイル: DobozDecoder.cs プロジェクト: jinjingcai2014/LibZ
		/// <summary>Gets the uncompressed length.</summary>
		/// <param name="input">The buffer.</param>
		/// <param name="inputOffset">The buffer offset.</param>
		/// <param name="inputLength">Length of the buffer.</param>
		/// <returns>Length of uncompressed data.</returns>
		public static int _UncompressedLength(byte[] input, int inputOffset, int inputLength)
		{
			CheckArguments(
				input, inputOffset, ref inputLength);

#if DOBOZ_SAFE
			var src = input;
#else
			fixed (byte* src = input)
#endif
			{
				var info = new CompressionInfo();
				if (GetCompressionInfo(src, inputOffset, inputLength, ref info) != Result.RESULT_OK)
					throw new ArgumentException("Corrupted input data");

				return info.uncompressedSize;
			}
		}