//public bool MDDWriter(String localPath) public void MDDWriter(String localPath) { FilesRecordWriter FileRecrd /*Files with dynamic variables Record*/; //RecordWriter DynVarRecrd /*Dynamic Variables Record of each file*/; DynamicVarRecordWriter DynVarRecrd /*Dynamic Variables Record of each file*/; UInt32 counter = 0; UInt32 loopCntr = 0; UInt32 numFileRecrds = 0; FileRecrd = new FilesRecordWriter(localPath); DynVarRecrd = new DynamicVarRecordWriter(localPath); UInt16 flags; List<FileRecord> FileRcrdList = new List<FileRecord>(); foreach (MPFSFileRecord file in files) { counter=0; loopCntr=0; if(file.dynVarCntr >0) { FileRcrdList.Add(new FileRecord ((UInt16)file.nameHash, (UInt32)file.fileRecordOffset, (UInt32)file.dynVarCntr)); numFileRecrds++; DynVarRecrd.Write((byte)(file.fileRecordLength)); DynVarRecrd.Write((byte)(file.fileRecordLength>>8)); DynVarRecrd.Write((byte)(file.fileRecordLength>>16)); DynVarRecrd.Write((byte)(file.fileRecordLength>>24)); flags = 0; if (file.hasIndex) flags |= MPFS2_FLAG_HASINDEX; if (file.isZipped) flags |= MPFS2_FLAG_ISZIPPED; DynVarRecrd.Write((byte)(flags)); DynVarRecrd.Write((byte)(flags>>8)); /* loopCntr = (UInt16)file.FileName.Length; flags = 0x00; while (loopCntr != (UInt32)flags) { DynVarRecrd.Write((byte)file.FileName[flags]); flags += 1; } */ loopCntr=0; while(loopCntr!=file.dynVarCntr) { DynVarRecrd.Write((byte)(file.dynVarOffsetAndIndexID[0+counter])); DynVarRecrd.Write((byte)(file.dynVarOffsetAndIndexID[1+counter])); DynVarRecrd.Write((byte)(file.dynVarOffsetAndIndexID[2+counter])); DynVarRecrd.Write((byte)(file.dynVarOffsetAndIndexID[3+counter])); DynVarRecrd.Write((byte)(file.dynVarOffsetAndIndexID[4 + counter])); DynVarRecrd.Write((byte)(file.dynVarOffsetAndIndexID[5 + counter])); DynVarRecrd.Write((byte)(file.dynVarOffsetAndIndexID[6 + counter])); DynVarRecrd.Write((byte)(file.dynVarOffsetAndIndexID[7 + counter])); counter+=8; loopCntr+=1; } } } FileRcrdList.Sort(delegate(FileRecord FR1, FileRecord FR2) { return FR1.nameHash.CompareTo(FR2.nameHash); } ); FileRecrd.Write((byte)(numFileRecrds)); FileRecrd.Write((byte)(numFileRecrds>>8)); FileRecrd.Write((byte)(numFileRecrds>>16)); FileRecrd.Write((byte)(numFileRecrds>>24)); FileRcrdList.ForEach(delegate(FileRecord FR) { FileRecrd.Write((byte)(FR.nameHash)); FileRecrd.Write((byte)(FR.nameHash>>8)); FileRecrd.Write((byte)(FR.fileRecordOffset)); FileRecrd.Write((byte)(FR.fileRecordOffset>>8)); FileRecrd.Write((byte)(FR.fileRecordOffset>>16)); FileRecrd.Write((byte)(FR.fileRecordOffset>>24)); FileRecrd.Write((byte)(FR.dynVarCntr)); FileRecrd.Write((byte)(FR.dynVarCntr>>8)); FileRecrd.Write((byte)(FR.dynVarCntr>>16)); FileRecrd.Write((byte)(FR.dynVarCntr>>24)); } ); log.Add("\r\nGENERATED MPFS2 IMAGE: " + FileRecrd.ImageLength + " bytes"); FileRecrd.Close(); DynVarRecrd.Close(); }
//public bool MDDWriter(String localPath) public void MDDWriter(String localPath) { FilesRecordWriter FileRecrd /*Files with dynamic variables Record*/; //RecordWriter DynVarRecrd /*Dynamic Variables Record of each file*/; DynamicVarRecordWriter DynVarRecrd /*Dynamic Variables Record of each file*/; UInt32 counter = 0; UInt32 loopCntr = 0; UInt32 numFileRecrds = 0; FileRecrd = new FilesRecordWriter(localPath); DynVarRecrd = new DynamicVarRecordWriter(localPath); UInt16 flags; List <FileRecord> FileRcrdList = new List <FileRecord>(); foreach (PVFSFileRecord file in files) { counter = 0; loopCntr = 0; if (file.dynVarCntr > 0) { FileRcrdList.Add(new FileRecord((UInt16)file.nameHash, (UInt32)file.fileRecordOffset, (UInt32)file.dynVarCntr)); numFileRecrds++; DynVarRecrd.Write((byte)(file.fileRecordLength)); DynVarRecrd.Write((byte)(file.fileRecordLength >> 8)); DynVarRecrd.Write((byte)(file.fileRecordLength >> 16)); DynVarRecrd.Write((byte)(file.fileRecordLength >> 24)); flags = 0; if (file.hasIndex) { flags |= PVFS2_FLAG_HASINDEX; } if (file.isZipped) { flags |= PVFS2_FLAG_ISZIPPED; } DynVarRecrd.Write((byte)(flags)); DynVarRecrd.Write((byte)(flags >> 8)); loopCntr = 0; while (loopCntr != file.dynVarCntr) { DynVarRecrd.Write((byte)(file.dynVarOffsetAndIndexID[0 + counter])); DynVarRecrd.Write((byte)(file.dynVarOffsetAndIndexID[1 + counter])); DynVarRecrd.Write((byte)(file.dynVarOffsetAndIndexID[2 + counter])); DynVarRecrd.Write((byte)(file.dynVarOffsetAndIndexID[3 + counter])); DynVarRecrd.Write((byte)(file.dynVarOffsetAndIndexID[4 + counter])); DynVarRecrd.Write((byte)(file.dynVarOffsetAndIndexID[5 + counter])); DynVarRecrd.Write((byte)(file.dynVarOffsetAndIndexID[6 + counter])); DynVarRecrd.Write((byte)(file.dynVarOffsetAndIndexID[7 + counter])); counter += 8; loopCntr += 1; } } } FileRcrdList.Sort(delegate(FileRecord FR1, FileRecord FR2) { return(FR1.nameHash.CompareTo(FR2.nameHash)); } ); FileRecrd.Write((byte)(numFileRecrds)); FileRecrd.Write((byte)(numFileRecrds >> 8)); FileRecrd.Write((byte)(numFileRecrds >> 16)); FileRecrd.Write((byte)(numFileRecrds >> 24)); FileRcrdList.ForEach(delegate(FileRecord FR) { FileRecrd.Write((byte)(FR.nameHash)); FileRecrd.Write((byte)(FR.nameHash >> 8)); FileRecrd.Write((byte)(FR.fileRecordOffset)); FileRecrd.Write((byte)(FR.fileRecordOffset >> 8)); FileRecrd.Write((byte)(FR.fileRecordOffset >> 16)); FileRecrd.Write((byte)(FR.fileRecordOffset >> 24)); FileRecrd.Write((byte)(FR.dynVarCntr)); FileRecrd.Write((byte)(FR.dynVarCntr >> 8)); FileRecrd.Write((byte)(FR.dynVarCntr >> 16)); FileRecrd.Write((byte)(FR.dynVarCntr >> 24)); } ); log.Add("\r\nGENERATED WEBFS IMAGE: " + FileRecrd.ImageLength + " bytes"); FileRecrd.Close(); DynVarRecrd.Close(); }