4.27 beta

This commit is contained in:
Igor Pavlov
2005-09-21 00:00:00 +00:00
committed by Kornel Lesiński
parent 31e7b924e8
commit d66cf2fcf3
393 changed files with 17345 additions and 4743 deletions

View File

@@ -8,9 +8,9 @@
#include "../../ICoder.h"
#include "TarHandler.h"
// {23170F69-40C1-278A-1000-000110040000}
// {23170F69-40C1-278A-1000-000110EE0000}
DEFINE_GUID(CLSID_CTarHandler,
0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x04, 0x00, 0x00);
0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0xEE, 0x00, 0x00);
extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)

View File

@@ -162,6 +162,14 @@ SOURCE=..\..\..\Common\StringConvert.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\StringToInt.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\StringToInt.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\Vector.cpp
# End Source File
# Begin Source File
@@ -276,6 +284,14 @@ SOURCE=..\..\Common\ProgressUtils.cpp
SOURCE=..\..\Common\ProgressUtils.h
# End Source File
# Begin Source File
SOURCE=..\..\Common\StreamUtils.cpp
# End Source File
# Begin Source File
SOURCE=..\..\Common\StreamUtils.h
# End Source File
# End Group
# End Target
# End Project

View File

@@ -16,7 +16,7 @@ namespace NFileHeader {
// The magic field is filled with this if uname and gname are valid.
namespace NMagic
{
const char *kUsTar = "ustar "; // 7 chars and a null
const char *kUsTar = "ustar"; // 5 chars
const char *kGNUTar = "GNUtar "; // 7 chars and a null
const char *kEmpty = "\0\0\0\0\0\0\0\0"; // 7 chars and a null
}

View File

@@ -14,6 +14,7 @@ namespace NFileHeader
const int kNameSize = 100;
const int kUserNameSize = 32;
const int kGroupNameSize = 32;
const int kPrefixSize = 155;
/*
struct CHeader
@@ -32,6 +33,7 @@ namespace NFileHeader
char GroupName[kGroupNameSize];
char DeviceMajor[8];
char DeviceMinor[8];
char Prefix[155];
};
union CRecord
{
@@ -84,7 +86,7 @@ namespace NFileHeader
// The magic field is filled with this if uname and gname are valid.
namespace NMagic
{
extern const char *kUsTar; // = "ustar "; // 7 chars and a null
extern const char *kUsTar; // = "ustar"; // 5 chars
extern const char *kGNUTar; // = "GNUtar "; // 7 chars and a null
extern const char *kEmpty; // = "GNUtar "; // 7 chars and a null
}

View File

@@ -5,14 +5,17 @@
#include "TarIn.h"
#include "TarHeader.h"
#include "Common/StringToInt.h"
#include "Windows/Defs.h"
#include "../../Common/StreamUtils.h"
namespace NArchive {
namespace NTar {
HRESULT CInArchive::ReadBytes(void *data, UInt32 size, UInt32 &processedSize)
{
RINOK(m_Stream->Read(data, size, &processedSize));
RINOK(ReadStream(m_Stream, data, size, &processedSize));
m_Position += processedSize;
return S_OK;
}
@@ -24,28 +27,28 @@ HRESULT CInArchive::Open(IInStream *inStream)
return S_OK;
}
static UInt32 OctalToNumber(const char *srcString)
static bool OctalToNumber(const char *srcString, int size, UInt64 &res)
{
char *endPtr;
return(strtoul(srcString, &endPtr, 8));
char sz[32];
strncpy(sz, srcString, size);
sz[size] = 0;
const char *end;
int i;
for (i = 0; sz[i] == ' '; i++);
res = ConvertOctStringToUInt64(sz + i, &end);
return (*end == ' ' || *end == 0);
}
static bool CheckOctalString(const char *srcString, int numChars)
static bool OctalToNumber32(const char *srcString, int size, UInt32 &res)
{
for(int i = 0; i < numChars; i++)
{
char c = srcString[i];
if (c == 0)
return true;
if (c >= '0' && c <= '7')
continue;
if (c != ' ')
return false;
}
return true;
UInt64 res64;
if (!OctalToNumber(srcString, size, res64))
return false;
res = (UInt32)res64;
return (res64 <= 0xFFFFFFFF);
}
#define ReturnIfBadOctal(x, y) { if (!CheckOctalString((x), (y))) return S_FALSE; }
#define RIF(x) { if (!(x)) return S_FALSE; }
static bool IsRecordLast(const char *record)
{
@@ -57,9 +60,9 @@ static bool IsRecordLast(const char *record)
static void ReadString(const char *s, int size, AString &result)
{
if (size > NFileHeader::kNameSize)
if (size > NFileHeader::kRecordSize)
size = NFileHeader::kNameSize;
char tempString[NFileHeader::kNameSize + 1];
char tempString[NFileHeader::kRecordSize + 1];
strncpy(tempString, s, size);
tempString[size] = '\0';
result = tempString;
@@ -114,28 +117,23 @@ HRESULT CInArchive::GetNextItemReal(bool &filled, CItemEx &item)
item.Name += c;
}
ReturnIfBadOctal(cur, 8);
item.Mode = OctalToNumber(cur);
RIF(OctalToNumber32(cur, 8, item.Mode));
cur += 8;
ReturnIfBadOctal(cur, 8);
item.UID = OctalToNumber(cur);
RIF(OctalToNumber32(cur, 8, item.UID));
cur += 8;
ReturnIfBadOctal(cur, 8);
item.GID = OctalToNumber(cur);
RIF(OctalToNumber32(cur, 8, item.GID));
cur += 8;
ReturnIfBadOctal(cur, 12);
item.Size = OctalToNumber(cur);
RIF(OctalToNumber(cur, 12, item.Size));
cur += 12;
ReturnIfBadOctal(cur, 12);
item.ModificationTime = OctalToNumber(cur);
RIF(OctalToNumber32(cur, 12, item.ModificationTime));
cur += 12;
ReturnIfBadOctal(cur, 8);
UInt32 checkSum = OctalToNumber(cur);
UInt32 checkSum;
RIF(OctalToNumber32(cur, 8, checkSum));
memmove(cur, NFileHeader::kCheckSumBlanks, 8);
cur += 8;
@@ -153,17 +151,19 @@ HRESULT CInArchive::GetNextItemReal(bool &filled, CItemEx &item)
ReadString(cur, NFileHeader::kUserNameSize, item.GroupName);
cur += NFileHeader::kUserNameSize;
ReturnIfBadOctal(cur, 8);
item.DeviceMajorDefined = (cur[0] != 0);
if (item.DeviceMajorDefined)
item.DeviceMajor = OctalToNumber(cur);
RIF(OctalToNumber32(cur, 8, item.DeviceMajor));
cur += 8;
ReturnIfBadOctal(cur, 8);
item.DeviceMinorDefined = (cur[0] != 0);
if (item.DeviceMinorDefined)
item.DeviceMinor = OctalToNumber(cur);
RIF(OctalToNumber32(cur, 8, item.DeviceMinor));
cur += 8;
AString prefix;
ReadString(cur, NFileHeader::kPrefixSize, prefix);
cur += NFileHeader::kPrefixSize;
if (!prefix.IsEmpty() && item.IsMagic())
item.Name = prefix + AString('/') + item.Name;
if (item.LinkFlag == NFileHeader::NLinkFlag::kLink)
item.Size = 0;

View File

@@ -45,6 +45,14 @@ public:
}
return false;
}
bool IsMagic() const
{
for (int i = 0; i < 5; i++)
if (Magic[i] != NFileHeader::NMagic::kUsTar[i])
return false;
return true;
}
};
class CItemEx: public CItem

View File

@@ -7,6 +7,7 @@
#include "Common/IntToString.h"
#include "Windows/Defs.h"
#include "../../Common/StreamUtils.h"
namespace NArchive {
namespace NTar {
@@ -14,7 +15,7 @@ namespace NTar {
HRESULT COutArchive::WriteBytes(const void *buffer, UInt32 size)
{
UInt32 processedSize;
RINOK(m_Stream->Write(buffer, size, &processedSize));
RINOK(WriteStream(m_Stream, buffer, size, &processedSize));
if(processedSize != size)
return E_FAIL;
return S_OK;
@@ -165,10 +166,15 @@ HRESULT COutArchive::FillDataResidual(UInt64 dataSize)
HRESULT COutArchive::WriteFinishHeader()
{
char record[NFileHeader::kRecordSize];
for (int i = 0; i < NFileHeader::kRecordSize; i++)
Byte record[NFileHeader::kRecordSize];
int i;
for (i = 0; i < NFileHeader::kRecordSize; i++)
record[i] = 0;
return WriteBytes(record, NFileHeader::kRecordSize);
for (i = 0; i < 2; i++)
{
RINOK(WriteBytes(record, NFileHeader::kRecordSize));
}
return S_OK;
}
}}

View File

@@ -18,6 +18,7 @@ COMMON_OBJS = \
$O\NewHandler.obj \
$O\String.obj \
$O\StringConvert.obj \
$O\StringToInt.obj \
$O\Vector.obj \
WIN_OBJS = \
@@ -26,6 +27,7 @@ WIN_OBJS = \
7ZIP_COMMON_OBJS = \
$O\LimitedStreams.obj \
$O\ProgressUtils.obj \
$O\StreamUtils.obj \
AR_COMMON_OBJS = \
$O\ItemNameUtils.obj \