static void ReadString(const char *s, unsigned size, AString &result) { char temp[NFileHeader::kRecordSize + 1]; MyStrNCpy(temp, s, size); temp[size] = '\0'; result = temp; }
HRESULT COutArchive::WriteHeaderReal(const CItem &item) { char record[NFileHeader::kRecordSize]; char *cur = record; int i; for (i = 0; i < NFileHeader::kRecordSize; i++) record[i] = 0; // RETURN_IF_NOT_TRUE(CopyString(header.Name, item.Name, NFileHeader::kNameSize)); if (item.Name.Length() > NFileHeader::kNameSize) return E_FAIL; MyStrNCpy(cur, item.Name, NFileHeader::kNameSize); cur += NFileHeader::kNameSize; RETURN_IF_NOT_TRUE(MakeOctalString8(cur, item.Mode)); cur += 8; RETURN_IF_NOT_TRUE(MakeOctalString8(cur, item.UID)); cur += 8; RETURN_IF_NOT_TRUE(MakeOctalString8(cur, item.GID)); cur += 8; RETURN_IF_NOT_TRUE(MakeOctalString12(cur, item.Size)); cur += 12; RETURN_IF_NOT_TRUE(MakeOctalString12(cur, item.MTime)); cur += 12; memmove(cur, NFileHeader::kCheckSumBlanks, 8); cur += 8; *cur++ = item.LinkFlag; RETURN_IF_NOT_TRUE(CopyString(cur, item.LinkName, NFileHeader::kNameSize)); cur += NFileHeader::kNameSize; memmove(cur, item.Magic, 8); cur += 8; RETURN_IF_NOT_TRUE(CopyString(cur, item.UserName, NFileHeader::kUserNameSize)); cur += NFileHeader::kUserNameSize; RETURN_IF_NOT_TRUE(CopyString(cur, item.GroupName, NFileHeader::kGroupNameSize)); cur += NFileHeader::kUserNameSize; if (item.DeviceMajorDefined) RETURN_IF_NOT_TRUE(MakeOctalString8(cur, item.DeviceMajor)); cur += 8; if (item.DeviceMinorDefined) RETURN_IF_NOT_TRUE(MakeOctalString8(cur, item.DeviceMinor)); cur += 8; UInt32 checkSumReal = 0; for(i = 0; i < NFileHeader::kRecordSize; i++) checkSumReal += Byte(record[i]); RETURN_IF_NOT_TRUE(MakeOctalString8(record + 148, checkSumReal)); return WriteBytes(record, NFileHeader::kRecordSize); }