Exemple #1
0
 /// <summary>
 /// 压缩数据;
 /// </summary>
 /// <param name="bytes">要压缩的数据;</param>
 /// <returns>压缩后的数据;</returns>
 public static byte[] Compress(byte[] bytes)
 {
     if (_zipHelper == null)
     {
         throw new Exception("Zip helper is invalid.");
     }
     return(_zipHelper.Compress(bytes));
 }
Exemple #2
0
            /// <summary>
            /// 压缩数据。
            /// </summary>
            /// <param name="bytes">要压缩的数据。</param>
            /// <returns>压缩后的数据。</returns>
            public static byte[] Compress(byte[] bytes)
            {
                if (s_ZipHelper == null)
                {
                    throw new GameFrameworkException("Zip helper is invalid.");
                }

                return(s_ZipHelper.Compress(bytes));
            }
Exemple #3
0
            public static byte[] Compress(byte[] bytes)
            {
                if (s_ZipHelper == null)
                {
                    throw;
                }

                return(s_ZipHelper.Compress(bytes));
            }
Exemple #4
0
        /// <summary>
        /// 压缩数据。
        /// </summary>
        /// <param name="bytes">要压缩的数据的二进制流。</param>
        /// <param name="offset">要压缩的数据的二进制流的偏移。</param>
        /// <param name="length">要压缩的数据的二进制流的长度。</param>
        /// <param name="compressedStream">压缩后的数据的二进制流。</param>
        /// <returns>是否压缩数据成功。</returns>
        public static bool Compress(byte[] bytes, int offset, int length, Stream compressedStream)
        {
            if (s_ZipHelper == null)
            {
                Debug.LogError("Zip helper is invalid.");
                return(false);
            }

            if (bytes == null)
            {
                Debug.LogError("Bytes is invalid.");
                return(false);
            }

            if (offset < 0 || length <= 0 || offset + length > bytes.Length)
            {
                Debug.LogError("Offset or length is invalid.");
                return(false);
            }

            if (compressedStream == null)
            {
                Debug.LogError("Compressed stream is invalid.");
                return(false);
            }

            try
            {
                return(s_ZipHelper.Compress(bytes, offset, length, compressedStream));
            }
            catch (Exception exception)
            {
                //if (exception is GameFrameworkException)
                //{
                //    throw;
                //}

                Debug.LogError(string.Format("Can not compress with exception '{0}'.", exception.ToString()));
            }
            return(false);
        }
Exemple #5
0
            /// <summary>
            /// 压缩数据。
            /// </summary>
            /// <param name="bytes">要压缩的数据的二进制流。</param>
            /// <param name="offset">要压缩的数据的二进制流的偏移。</param>
            /// <param name="length">要压缩的数据的二进制流的长度。</param>
            /// <param name="compressedStream">压缩后的数据的二进制流。</param>
            /// <returns>是否压缩数据成功。</returns>
            public static bool Compress(byte[] bytes, int offset, int length, Stream compressedStream)
            {
                if (s_ZipHelper == null)
                {
                    throw new GameFrameworkException("Zip helper is invalid.");
                }

                if (bytes == null)
                {
                    throw new GameFrameworkException("Bytes is invalid.");
                }

                if (offset < 0 || length < 0 || offset + length > bytes.Length)
                {
                    throw new GameFrameworkException("Offset or length is invalid.");
                }

                if (compressedStream == null)
                {
                    throw new GameFrameworkException("Compressed stream is invalid.");
                }

                try
                {
                    return(s_ZipHelper.Compress(bytes, offset, length, compressedStream));
                }
                catch (Exception exception)
                {
                    if (exception is GameFrameworkException)
                    {
                        throw;
                    }

                    throw new GameFrameworkException(Text.Format("Can not compress with exception '{0}'.", exception.ToString()), exception);
                }
            }
Exemple #6
0
            /// <summary>
            /// 压缩数据。
            /// </summary>
            /// <param name="bytes">要压缩的数据。</param>
            /// <returns>压缩后的数据。</returns>
            public static byte[] Compress(byte[] bytes)
            {
                if (s_ZipHelper == null)
                {
                    throw new GameFrameworkException("Zip helper is invalid.");
                }

                try
                {
                    return(s_ZipHelper.Compress(bytes));
                }
                catch (Exception exception)
                {
                    if (exception is GameFrameworkException)
                    {
                        throw;
                    }

                    throw new GameFrameworkException(Text.Format("Can not compress bytes with exception '{0}'.", exception.ToString()), exception);
                }
            }