示例#1
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);
        }
示例#2
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);
        }
示例#3
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);
        }
示例#4
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)
     });
 }