//============================================================ // <T>压缩方法</T> //============================================================ public void NotCompress(int size) { if (0 == size) { throw new FFatalException("Size is zero."); } // 构建缓冲数据 byte[] bytes = new byte[_length + RInt.SIZE_16K]; FByteFile file = new FByteFile(); // 计算分割块数 int splitCount = _length / size; if (0 != (_length % size)) { splitCount++; } // 写入压缩前数据总长度 file.WriteInt32(_length); // 写入分割块数 file.WriteInt32(splitCount); // 分段压缩数据 //int position = 0; int remain = _length; for (int n = 0; n < splitCount; n++) { //int compressLength = RCompressLzma.Compress(bytes,0,bytes.Length,_memory,position,Math.Min(size,remain)); //if(0 == compressLength) { // throw new FFatalException("Compress failure. (compress_length={0})",compressLength); //} //position += size; //remain -= size; //// 输出压缩后数据 //file.WriteInt32(compressLength); //file.WriteBytes(bytes,0,compressLength); } Clear(); WriteBytes(file.ToArray(), 0, file.Length); }
//============================================================ // <T>加载文件夹信息</T> // // @param config 文件路径。 //============================================================ public void ExportAll() { // 加载文件 FByteFile file = new FByteFile(); file.WriteInt32(_frames.Count); foreach (INamePair <FRcFrame> pair in _frames) { FRcFrame frame = pair.Value; // 打开顶层容器 frame.Open(); // 序列化顶层容器 frame.Serialize(file); } // 保存文件 file.SaveFile(_exportFileName); }
//============================================================ // <T>存储所有信息到文件中。</T> //============================================================ public void StoreFiles() { // 保存属性 FByteFile file = new FByteFile(); // 写入个数 int count = _infos.Count; file.WriteInt32(count); // 保存所有程序信息 for (int n = 0; n < count; n++) { FApplicationInfo info = _infos.Get(n); file.WriteString(info.Name); // 保存程序信息 string fileName = RFile.MakeFileName(_storagePath, info.Name + ".ser"); info.SaveFile(fileName); } // 保存文件 string configName = RFile.MakeFileName(_storagePath, "applications.ser"); file.SaveFile(configName); }