Example #1
0
        private void SavePackageInfo(MemoryStream fileStream)
        {
            var indexPositionData = EncodeDecoder.EncodeUInt32(m_packageInfo.IndexOffset);

            fileStream.Write(indexPositionData, 0, indexPositionData.Length);
            fileStream.Flush();
        }
Example #2
0
        public static IndexInfo Decode(byte[] data, ref int offset)
        {
            var info = new IndexInfo();

            info.Id         = EncodeDecoder.DecodeString(data, ref offset);
            info.FileName   = EncodeDecoder.DecodeString(data, ref offset);
            info.Path       = EncodeDecoder.DecodeString(data, ref offset);
            info.Offset     = EncodeDecoder.DecodeUInt32(data, ref offset);
            info.Length     = EncodeDecoder.DecodeUInt32(data, ref offset);
            info.PageLength = EncodeDecoder.DecodeUInt32(data, ref offset);
            info.Deleted    = EncodeDecoder.DecodeBoolean(data, ref offset);
            return(info);
        }
Example #3
0
        public static byte[] Encode(IndexInfo info)
        {
            var result = new List <byte>();

            result.AddRange(EncodeDecoder.EncodeString(info.Id));
            result.AddRange(EncodeDecoder.EncodeString(info.FileName));
            result.AddRange(EncodeDecoder.EncodeString(info.Path));
            result.AddRange(EncodeDecoder.EncodeUInt32(info.Offset));
            result.AddRange(EncodeDecoder.EncodeUInt32(info.Length));
            result.AddRange(EncodeDecoder.EncodeUInt32(info.PageLength));
            result.AddRange(EncodeDecoder.EncodeBoolean(info.Deleted));
            return(result.ToArray());
        }
Example #4
0
        private Mogo.Util.PackageInfo GetPackageInfo(FileStream fileStream, long fileSize)
        {
            Mogo.Util.PackageInfo info = new Mogo.Util.PackageInfo();
            if (fileSize < Mogo.Util.PackageInfo.GetPackageSize())
            {
                return(new Mogo.Util.PackageInfo());
            }
            fileStream.Position = fileSize - Mogo.Util.PackageInfo.GetPackageSize();
            byte[] buffer = new byte[Mogo.Util.PackageInfo.GetPackageSize()];
            fileStream.Read(buffer, 0, Mogo.Util.PackageInfo.GetPackageSize());
            int index = 0;

            info.IndexOffset = EncodeDecoder.DecodeUInt32(buffer, ref index);
            return(info);
        }
Example #5
0
        /// <summary>
        /// 获取包信息。
        /// </summary>
        /// <param name="fileSize"></param>
        private PackageInfo GetPackageInfo(MemoryStream fileStream, long fileSize)
        {
            var packageInfo = new PackageInfo();

            if (fileSize < PackageInfo.GetPackageSize())
            {
                return(new PackageInfo());
            }

            fileStream.Position = fileSize - PackageInfo.GetPackageSize();//索引信息起始位置存放在文件结尾处。
            var lengthData = new Byte[PackageInfo.GetPackageSize()];

            fileStream.Read(lengthData, 0, PackageInfo.GetPackageSize());
            var index = 0;

            packageInfo.IndexOffset = EncodeDecoder.DecodeUInt32(lengthData, ref index);//获取索引信息起始位置
            return(packageInfo);
        }
Example #6
0
 private void SavePackageInfo(FileStream fileStream)
 {
     byte[] buffer = EncodeDecoder.EncodeUInt32(this.m_packageInfo.IndexOffset);
     fileStream.Write(buffer, 0, buffer.Length);
     fileStream.Flush();
 }
Example #7
0
 public static IndexInfo Decode(byte[] data, ref int offset)
 {
     return(new IndexInfo {
         Id = EncodeDecoder.DecodeString(data, ref offset), FileName = EncodeDecoder.DecodeString(data, ref offset), Path = EncodeDecoder.DecodeString(data, ref offset), Offset = EncodeDecoder.DecodeUInt32(data, ref offset), Length = EncodeDecoder.DecodeUInt32(data, ref offset), PageLength = EncodeDecoder.DecodeUInt32(data, ref offset), Deleted = EncodeDecoder.DecodeBoolean(data, ref offset)
     });
 }