This commit is contained in:
Igor Pavlov
2003-12-11 00:00:00 +00:00
committed by Kornel Lesiński
commit 8c1b5c7b7e
982 changed files with 118799 additions and 0 deletions

80
7zip/Archive/Tar/DllExports.cpp Executable file
View File

@@ -0,0 +1,80 @@
// DLLExports.cpp
#include "StdAfx.h"
#include <initguid.h>
#include "Common/ComTry.h"
#include "Windows/PropVariant.h"
#include "../../ICoder.h"
#include "TarHandler.h"
// {23170F69-40C1-278A-1000-000110040000}
DEFINE_GUID(CLSID_CTarHandler,
0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x10, 0x04, 0x00, 0x00);
extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
{
return TRUE;
}
STDAPI CreateObject(
const GUID *classID,
const GUID *interfaceID,
void **outObject)
{
COM_TRY_BEGIN
*outObject = 0;
if (*classID != CLSID_CTarHandler)
return CLASS_E_CLASSNOTAVAILABLE;
int needIn = *interfaceID == IID_IInArchive;
int needOut = *interfaceID == IID_IOutArchive;
if (needIn || needOut)
{
NArchive::NTar::CHandler *temp = new NArchive::NTar::CHandler;
if (needIn)
{
CMyComPtr<IInArchive> inArchive = (IInArchive *)temp;
*outObject = inArchive.Detach();
}
else
{
CMyComPtr<IOutArchive> outArchive = (IOutArchive *)temp;
*outObject = outArchive.Detach();
}
}
else
return E_NOINTERFACE;
COM_TRY_END
return S_OK;
}
STDAPI GetHandlerProperty(PROPID propID, PROPVARIANT *value)
{
NWindows::NCOM::CPropVariant propVariant;
switch(propID)
{
case NArchive::kName:
propVariant = L"Tar";
break;
case NArchive::kClassID:
{
if ((value->bstrVal = ::SysAllocStringByteLen(
(const char *)&CLSID_CTarHandler, sizeof(GUID))) != 0)
value->vt = VT_BSTR;
return S_OK;
}
case NArchive::kExtension:
propVariant = L"tar";
break;
case NArchive::kUpdate:
propVariant = true;
break;
case NArchive::kKeepName:
propVariant = false;
break;
}
propVariant.Detach(value);
return S_OK;
}

3
7zip/Archive/Tar/StdAfx.cpp Executable file
View File

@@ -0,0 +1,3 @@
// StdAfx.cpp
#include "stdafx.h"

9
7zip/Archive/Tar/StdAfx.h Executable file
View File

@@ -0,0 +1,9 @@
// stdafx.h
#ifndef __STDAFX_H
#define __STDAFX_H
#include <windows.h>
#include <time.h>
#endif

7
7zip/Archive/Tar/Tar.def Executable file
View File

@@ -0,0 +1,7 @@
; Tar.def
LIBRARY Tar.dll
EXPORTS
CreateObject PRIVATE
GetHandlerProperty PRIVATE

269
7zip/Archive/Tar/Tar.dsp Executable file
View File

@@ -0,0 +1,269 @@
# Microsoft Developer Studio Project File - Name="Tar" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=Tar - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "Tar.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "Tar.mak" CFG="Tar - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "Tar - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "Tar - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "Tar - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TAR_EXPORTS" /YX /FD /c
# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TAR_EXPORTS" /Yu"StdAfx.h" /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "NDEBUG"
# ADD RSC /l 0x419 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"C:\Program Files\7-Zip\Formats\tar.dll" /opt:NOWIN98
# SUBTRACT LINK32 /pdb:none
!ELSEIF "$(CFG)" == "Tar - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TAR_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /Gz /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "TAR_EXPORTS" /Yu"StdAfx.h" /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x419 /d "_DEBUG"
# ADD RSC /l 0x419 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"C:\Program Files\7-Zip\Formats\tar.dll" /pdbtype:sept
!ENDIF
# Begin Target
# Name "Tar - Win32 Release"
# Name "Tar - Win32 Debug"
# Begin Group "Spec"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\DllExports.cpp
# End Source File
# Begin Source File
SOURCE=.\resource.h
# End Source File
# Begin Source File
SOURCE=.\resource.rc
# End Source File
# Begin Source File
SOURCE=.\StdAfx.cpp
# ADD CPP /Yc"StdAfx.h"
# End Source File
# Begin Source File
SOURCE=.\StdAfx.h
# End Source File
# Begin Source File
SOURCE=.\Tar.def
# End Source File
# Begin Source File
SOURCE=.\Tar.ico
# End Source File
# End Group
# Begin Group "Common"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\..\..\Common\NewHandler.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\NewHandler.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\String.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\String.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\StringConvert.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\StringConvert.h
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\Vector.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\Common\Vector.h
# End Source File
# End Group
# Begin Group "Windows"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\..\..\Windows\PropVariant.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\Windows\PropVariant.h
# End Source File
# End Group
# Begin Group "Compress"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\..\Compress\Copy\CopyCoder.cpp
# End Source File
# Begin Source File
SOURCE=..\..\Compress\Copy\CopyCoder.h
# End Source File
# End Group
# Begin Group "Engine"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\TarHandler.cpp
# End Source File
# Begin Source File
SOURCE=.\TarHandler.h
# End Source File
# Begin Source File
SOURCE=.\TarHandlerOut.cpp
# End Source File
# Begin Source File
SOURCE=.\TarHeader.cpp
# End Source File
# Begin Source File
SOURCE=.\TarHeader.h
# End Source File
# Begin Source File
SOURCE=.\TarIn.cpp
# End Source File
# Begin Source File
SOURCE=.\TarIn.h
# End Source File
# Begin Source File
SOURCE=.\TarItem.h
# End Source File
# Begin Source File
SOURCE=.\TarOut.cpp
# End Source File
# Begin Source File
SOURCE=.\TarOut.h
# End Source File
# Begin Source File
SOURCE=.\TarUpdate.cpp
# End Source File
# Begin Source File
SOURCE=.\TarUpdate.h
# End Source File
# End Group
# Begin Group "Archive Common"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\Common\ItemNameUtils.cpp
# End Source File
# Begin Source File
SOURCE=..\Common\ItemNameUtils.h
# End Source File
# End Group
# Begin Group "7zip Common"
# PROP Default_Filter ""
# Begin Source File
SOURCE=..\..\Common\LimitedStreams.cpp
# End Source File
# Begin Source File
SOURCE=..\..\Common\LimitedStreams.h
# End Source File
# Begin Source File
SOURCE=..\..\Common\ProgressUtils.cpp
# End Source File
# Begin Source File
SOURCE=..\..\Common\ProgressUtils.h
# End Source File
# End Group
# End Target
# End Project

29
7zip/Archive/Tar/Tar.dsw Executable file
View File

@@ -0,0 +1,29 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "Tar"=.\Tar.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

281
7zip/Archive/Tar/TarHandler.cpp Executable file
View File

@@ -0,0 +1,281 @@
// Tar/Handler.cpp
#include "StdAfx.h"
#include "TarHandler.h"
#include "TarIn.h"
#include "Common/Defs.h"
#include "Common/StringConvert.h"
#include "Common/NewHandler.h"
#include "Common/ComTry.h"
#include "Windows/Time.h"
#include "Windows/PropVariant.h"
#include "../../Common/ProgressUtils.h"
#include "../../Common/LimitedStreams.h"
#include "../../Compress/Copy/CopyCoder.h"
#include "../Common/ItemNameUtils.h"
using namespace NWindows;
using namespace NTime;
namespace NArchive {
namespace NTar {
STATPROPSTG kProperties[] =
{
{ NULL, kpidPath, VT_BSTR},
{ NULL, kpidIsFolder, VT_BOOL},
{ NULL, kpidSize, VT_UI8},
{ NULL, kpidPackedSize, VT_UI8},
{ NULL, kpidLastWriteTime, VT_FILETIME},
{ NULL, kpidUser, VT_BSTR},
{ NULL, kpidGroup, VT_BSTR},
};
STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value)
{
value->vt = VT_EMPTY;
return S_OK;
}
STDMETHODIMP CHandler::GetNumberOfProperties(UINT32 *numProperties)
{
*numProperties = sizeof(kProperties) / sizeof(kProperties[0]);
return S_OK;
}
STDMETHODIMP CHandler::GetPropertyInfo(UINT32 index,
BSTR *name, PROPID *propID, VARTYPE *varType)
{
if(index >= sizeof(kProperties) / sizeof(kProperties[0]))
return E_INVALIDARG;
const STATPROPSTG &srcItem = kProperties[index];
*propID = srcItem.propid;
*varType = srcItem.vt;
*name = 0;
return S_OK;
}
STDMETHODIMP CHandler::GetNumberOfArchiveProperties(UINT32 *numProperties)
{
*numProperties = 0;
return S_OK;
}
STDMETHODIMP CHandler::GetArchivePropertyInfo(UINT32 index,
BSTR *name, PROPID *propID, VARTYPE *varType)
{
return E_INVALIDARG;
}
STDMETHODIMP CHandler::Open(IInStream *stream,
const UINT64 *maxCheckStartPosition,
IArchiveOpenCallback *openArchiveCallback)
{
COM_TRY_BEGIN
bool mustBeClosed = true;
// try
{
CInArchive archive;
if(archive.Open(stream) != S_OK)
return S_FALSE;
_items.Clear();
if (openArchiveCallback != NULL)
{
RINOK(openArchiveCallback->SetTotal(NULL, NULL));
UINT64 numFiles = _items.Size();
RINOK(openArchiveCallback->SetCompleted(&numFiles, NULL));
}
while(true)
{
CItemEx item;
bool filled;
HRESULT result = archive.GetNextItem(filled, item);
if (result == S_FALSE)
return S_FALSE;
if (result != S_OK)
return S_FALSE;
if (!filled)
break;
_items.Add(item);
archive.SkeepDataRecords(item.Size);
if (openArchiveCallback != NULL)
{
UINT64 numFiles = _items.Size();
RINOK(openArchiveCallback->SetCompleted(&numFiles, NULL));
}
}
if (_items.Size() == 0)
return S_FALSE;
_inStream = stream;
}
/*
catch(...)
{
return S_FALSE;
}
*/
return S_OK;
COM_TRY_END
}
STDMETHODIMP CHandler::Close()
{
_inStream.Release();
return S_OK;
}
STDMETHODIMP CHandler::GetNumberOfItems(UINT32 *numItems)
{
*numItems = _items.Size();
return S_OK;
}
STDMETHODIMP CHandler::GetProperty(UINT32 index, PROPID propID, PROPVARIANT *value)
{
COM_TRY_BEGIN
NWindows::NCOM::CPropVariant propVariant;
const NArchive::NTar::CItemEx &item = _items[index];
switch(propID)
{
case kpidPath:
propVariant = (const wchar_t *)NItemName::GetOSName2(
MultiByteToUnicodeString(item.Name, CP_OEMCP));
break;
case kpidIsFolder:
propVariant = item.IsDirectory();
break;
case kpidSize:
case kpidPackedSize:
propVariant = (UINT64)item.Size;
break;
case kpidLastWriteTime:
{
FILETIME utcFileTime;
if (item.ModificationTime != 0)
NTime::UnixTimeToFileTime(item.ModificationTime, utcFileTime);
else
{
utcFileTime.dwLowDateTime = 0;
utcFileTime.dwHighDateTime = 0;
}
propVariant = utcFileTime;
break;
}
case kpidUser:
propVariant = (const wchar_t *)
MultiByteToUnicodeString(item.UserName, CP_OEMCP);
break;
case kpidGroup:
propVariant = (const wchar_t *)
MultiByteToUnicodeString(item.GroupName, CP_OEMCP);
break;
}
propVariant.Detach(value);
return S_OK;
COM_TRY_END
}
STDMETHODIMP CHandler::Extract(const UINT32* indices, UINT32 numItems,
INT32 _aTestMode, IArchiveExtractCallback *extractCallback)
{
COM_TRY_BEGIN
bool testMode = (_aTestMode != 0);
bool allFilesMode = (numItems == UINT32(-1));
if (allFilesMode)
numItems = _items.Size();
UINT64 totalSize = 0;
if(numItems == 0)
return S_OK;
UINT32 i;
for(i = 0; i < numItems; i++)
totalSize += _items[allFilesMode ? i : indices[i]].Size;
extractCallback->SetTotal(totalSize);
UINT64 currentTotalSize = 0;
UINT64 currentItemSize;
CMyComPtr<ICompressCoder> copyCoder;
for(i = 0; i < numItems; i++, currentTotalSize += currentItemSize)
{
RINOK(extractCallback->SetCompleted(&currentTotalSize));
CMyComPtr<ISequentialOutStream> realOutStream;
INT32 askMode;
askMode = testMode ? NArchive::NExtract::NAskMode::kTest :
NArchive::NExtract::NAskMode::kExtract;
INT32 index = allFilesMode ? i : indices[i];
const CItemEx &item = _items[index];
RINOK(extractCallback->GetStream(index, &realOutStream, askMode));
currentItemSize = item.Size;
if(item.IsDirectory())
{
RINOK(extractCallback->PrepareOperation(askMode));
RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
continue;
}
if(!testMode && (!realOutStream))
{
continue;
}
RINOK(extractCallback->PrepareOperation(askMode));
{
if (testMode)
{
RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
continue;
}
RINOK(_inStream->Seek(item.GetDataPosition(), STREAM_SEEK_SET, NULL));
CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
CMyComPtr<ISequentialInStream> inStream(streamSpec);
streamSpec->Init(_inStream, item.Size);
CLocalProgress *localProgressSpec = new CLocalProgress;
CMyComPtr<ICompressProgressInfo> progress = localProgressSpec;
localProgressSpec->Init(extractCallback, false);
CLocalCompressProgressInfo *localCompressProgressSpec =
new CLocalCompressProgressInfo;
CMyComPtr<ICompressProgressInfo> compressProgress = localCompressProgressSpec;
localCompressProgressSpec->Init(progress,
&currentTotalSize, &currentTotalSize);
if(!copyCoder)
{
copyCoder = new NCompress::CCopyCoder;
}
try
{
RINOK(copyCoder->Code(inStream, realOutStream,
NULL, NULL, compressProgress));
}
catch(...)
{
realOutStream.Release();
RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kDataError));
continue;
}
realOutStream.Release();
RINOK(extractCallback->SetOperationResult(NArchive::NExtract::NOperationResult::kOK));
}
}
return S_OK;
COM_TRY_END
}
}}

58
7zip/Archive/Tar/TarHandler.h Executable file
View File

@@ -0,0 +1,58 @@
// Tar/Handler.h
#pragma once
#ifndef __TAR_HANDLER_H
#define __TAR_HANDLER_H
#include "Common/MyCom.h"
#include "../IArchive.h"
#include "TarItem.h"
namespace NArchive {
namespace NTar {
class CHandler:
public IInArchive,
public IOutArchive,
public CMyUnknownImp
{
public:
MY_UNKNOWN_IMP2(
IInArchive,
IOutArchive
)
STDMETHOD(Open)(IInStream *stream,
const UINT64 *maxCheckStartPosition,
IArchiveOpenCallback *openArchiveCallback);
STDMETHOD(Close)();
STDMETHOD(GetNumberOfItems)(UINT32 *numItems);
STDMETHOD(GetProperty)(UINT32 index, PROPID propID, PROPVARIANT *value);
STDMETHOD(Extract)(const UINT32* indices, UINT32 numItems,
INT32 testMode, IArchiveExtractCallback *extractCallback);
STDMETHOD(GetArchiveProperty)(PROPID propID, PROPVARIANT *value);
STDMETHOD(GetNumberOfProperties)(UINT32 *numProperties);
STDMETHOD(GetPropertyInfo)(UINT32 index,
BSTR *name, PROPID *propID, VARTYPE *varType);
STDMETHOD(GetNumberOfArchiveProperties)(UINT32 *numProperties);
STDMETHOD(GetArchivePropertyInfo)(UINT32 index,
BSTR *name, PROPID *propID, VARTYPE *varType);
// IOutArchive
STDMETHOD(UpdateItems)(IOutStream *outStream, UINT32 numItems,
IArchiveUpdateCallback *updateCallback);
STDMETHOD(GetFileTimeType)(UINT32 *type);
private:
CObjectVector<CItemEx> _items;
CMyComPtr<IInStream> _inStream;
};
}}
#endif

View File

@@ -0,0 +1,122 @@
// Tar/HandlerOut.cpp
#include "StdAfx.h"
#include "Common/StringConvert.h"
#include "Common/ComTry.h"
#include "Windows/PropVariant.h"
#include "Windows/Time.h"
#include "../Common/ItemNameUtils.h"
#include "TarHandler.h"
#include "TarUpdate.h"
using namespace NWindows;
using namespace NCOM;
using namespace NTime;
namespace NArchive {
namespace NTar {
STDMETHODIMP CHandler::GetFileTimeType(UINT32 *type)
{
*type = NFileTimeType::kUnix;
return S_OK;
}
STDMETHODIMP CHandler::UpdateItems(IOutStream *outStream, UINT32 numItems,
IArchiveUpdateCallback *updateCallback)
{
COM_TRY_BEGIN
CObjectVector<CUpdateItemInfo> updateItems;
for(UINT32 i = 0; i < numItems; i++)
{
CUpdateItemInfo updateItem;
INT32 newData;
INT32 newProperties;
UINT32 indexInArchive;
if (!updateCallback)
return E_FAIL;
RINOK(updateCallback->GetUpdateItemInfo(i,
&newData, &newProperties, &indexInArchive));
updateItem.NewProperties = IntToBool(newProperties);
updateItem.NewData = IntToBool(newData);
updateItem.IndexInArchive = indexInArchive;
updateItem.IndexInClient = i;
if (IntToBool(newProperties))
{
FILETIME utcTime;
UString name;
bool isDirectoryStatusDefined;
UINT32 attributes;
{
NCOM::CPropVariant propVariant;
RINOK(updateCallback->GetProperty(i, kpidAttributes, &propVariant));
if (propVariant.vt == VT_EMPTY)
attributes = 0;
else if (propVariant.vt != VT_UI4)
return E_INVALIDARG;
else
attributes = propVariant.ulVal;
}
{
NCOM::CPropVariant propVariant;
RINOK(updateCallback->GetProperty(i, kpidLastWriteTime, &propVariant));
if (propVariant.vt != VT_FILETIME)
return E_INVALIDARG;
utcTime = propVariant.filetime;
}
{
NCOM::CPropVariant propVariant;
RINOK(updateCallback->GetProperty(i, kpidPath, &propVariant));
if (propVariant.vt == VT_EMPTY)
name.Empty();
else if (propVariant.vt != VT_BSTR)
return E_INVALIDARG;
else
name = propVariant.bstrVal;
}
{
NCOM::CPropVariant propVariant;
RINOK(updateCallback->GetProperty(i, kpidIsFolder, &propVariant));
if (propVariant.vt == VT_EMPTY)
isDirectoryStatusDefined = false;
else if (propVariant.vt != VT_BOOL)
return E_INVALIDARG;
else
{
updateItem.IsDirectory = (propVariant.boolVal != VARIANT_FALSE);
isDirectoryStatusDefined = true;
}
}
updateItem.Name = UnicodeStringToMultiByte(
NItemName::MakeLegalName(name), CP_OEMCP);
if (!isDirectoryStatusDefined)
updateItem.IsDirectory = ((attributes & FILE_ATTRIBUTE_DIRECTORY) != 0);
if (updateItem.IsDirectory)
updateItem.Name += '/';
if(!FileTimeToUnixTime(utcTime, updateItem.Time))
return E_INVALIDARG;
}
if (IntToBool(newData))
{
UINT64 size;
{
NCOM::CPropVariant propVariant;
RINOK(updateCallback->GetProperty(i, kpidSize, &propVariant));
if (propVariant.vt != VT_UI8)
return E_INVALIDARG;
size = *(UINT64 *)(&propVariant.uhVal);
}
updateItem.Size = size;
}
updateItems.Add(updateItem);
}
return UpdateArchive(_inStream, outStream, _items, updateItems, updateCallback);
COM_TRY_END
}
}}

25
7zip/Archive/Tar/TarHeader.cpp Executable file
View File

@@ -0,0 +1,25 @@
// Archive/Tar/Header.h
#include "StdAfx.h"
#include "TarHeader.h"
namespace NArchive {
namespace NTar {
namespace NFileHeader {
// The checksum field is filled with this while the checksum is computed.
const char *kCheckSumBlanks = " "; // 8 blanks, no null
const char *kLongLink = "././@LongLink";
// 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 *kGNUTar = "GNUtar "; // 7 chars and a null
const char *kEmpty = "\0\0\0\0\0\0\0\0"; // 7 chars and a null
}
}}}

107
7zip/Archive/Tar/TarHeader.h Executable file
View File

@@ -0,0 +1,107 @@
// Archive/Tar/Header.h
#pragma once
#ifndef __ARCHIVE_TAR_HEADER_H
#define __ARCHIVE_TAR_HEADER_H
#include "Common/Types.h"
namespace NArchive {
namespace NTar {
#pragma pack( push, PragmaTarHeaders)
#pragma pack( push, 1)
namespace NFileHeader
{
const int kRecordSize = 512;
const int kNameSize = 100;
const int kUserNameSize = 32;
const int kGroupNameSize = 32;
struct CHeader
{
char Name[kNameSize];
char Mode[8];
char UID[8];
char GID[8];
char Size[12];
char ModificationTime[12];
char CheckSum[8];
char LinkFlag;
char LinkName[kNameSize];
char Magic[8];
char UserName[kUserNameSize];
char GroupName[kGroupNameSize];
char DeviceMajor[8];
char DeviceMinor[8];
/*
BYTE Padding[kRecordSize - (kNameSize + 8 + 8 + 12 + 12 + 8 + 1 + kNameSize + 8 +
kUserNameSize + kGroupNameSize + 8 + 8)];
*/
};
union CRecord
{
CHeader Header;
BYTE Padding[kRecordSize];
};
namespace NMode
{
const int kSetUID = 04000; // Set UID on execution
const int kSetGID = 02000; // Set GID on execution
const int kSaveText = 01000; // Save text (sticky bit)
}
namespace NFilePermissions
{
const int kUserRead = 00400; // read by owner
const int kUserWrite = 00200; // write by owner
const int kUserExecute = 00100; // execute/search by owner
const int kGroupRead = 00040; // read by group
const int kGroupWrite = 00020; // write by group
const int kGroupExecute = 00010; // execute/search by group
const int kOtherRead = 00004; // read by other
const int kOtherWrite = 00002; // write by other
const int kOtherExecute = 00001; // execute/search by other
}
// The linkflag defines the type of file
namespace NLinkFlag
{
const char kOldNormal = '\0'; // Normal disk file, Unix compatible
const char kNormal = '0'; // Normal disk file
const char kLink = '1'; // Link to previously dumped file
const char kSymbolicLink = '2'; // Symbolic link
const char kCharacter = '3'; // Character special file
const char kBlock = '4'; // Block special file
const char kDirectory = '5'; // Directory
const char kFIFO = '6'; // FIFO special file
const char kContiguous = '7'; // Contiguous file
}
// Further link types may be defined later.
// The checksum field is filled with this while the checksum is computed.
extern const char *kCheckSumBlanks;// = " "; // 8 blanks, no null
extern const char *kLongLink; // = "././@LongLink";
// 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 *kGNUTar; // = "GNUtar "; // 7 chars and a null
extern const char *kEmpty; // = "GNUtar "; // 7 chars and a null
}
}
#pragma pack(pop)
#pragma pack(pop, PragmaTarHeaders)
}}
#endif

191
7zip/Archive/Tar/TarIn.cpp Executable file
View File

@@ -0,0 +1,191 @@
// Archive/TarIn.cpp
#include "StdAfx.h"
#include "TarIn.h"
#include "TarHeader.h"
#include "Windows/Defs.h"
namespace NArchive {
namespace NTar {
HRESULT CInArchive::ReadBytes(void *data, UINT32 size, UINT32 &processedSize)
{
RINOK(m_Stream->Read(data, size, &processedSize));
m_Position += processedSize;
return S_OK;
}
HRESULT CInArchive::Open(IInStream *inStream)
{
RINOK(inStream->Seek(0, STREAM_SEEK_CUR, &m_Position));
m_Stream = inStream;
return S_OK;
}
static UINT32 OctalToNumber(const char *srcString)
{
char *endPtr;
return(strtoul(srcString, &endPtr, 8));
}
static bool CheckOctalString(const char *srcString, int numChars)
{
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;
}
#define ReturnIfBadOctal(x, y) { if (!CheckOctalString((x), (y))) return S_FALSE; }
static bool IsRecordLast(const NFileHeader::CRecord &record)
{
for (int i = 0; i < sizeof(record); i++)
if (record.Padding[i] != 0)
return false;
return true;
}
HRESULT CInArchive::GetNextItemReal(bool &filled, CItemEx &item)
{
item.LongLinkSize = 0;
NFileHeader::CRecord record;
filled = false;
UINT32 processedSize;
item.HeaderPosition = m_Position;
RINOK(ReadBytes(&record, sizeof(record), processedSize));
if (processedSize == 0 ||
(processedSize == sizeof(record) && IsRecordLast(record)))
return S_OK;
if (processedSize < sizeof(record))
return S_FALSE;
NFileHeader::CHeader &header = record.Header;
char tempString[NFileHeader::kNameSize + 1];
strncpy(tempString, header.Name, NFileHeader::kNameSize);
tempString[NFileHeader::kNameSize] = '\0';
item.Name = tempString;
int i;
for (i = 0; i < item.Name.Length(); i++)
if (((BYTE)item.Name[i]) < 0x20)
return S_FALSE;
item.LinkFlag = header.LinkFlag;
BYTE linkFlag = item.LinkFlag;
ReturnIfBadOctal(header.Mode, 8);
ReturnIfBadOctal(header.UID, 8);
ReturnIfBadOctal(header.GID, 8);
ReturnIfBadOctal(header.Size, 12);
ReturnIfBadOctal(header.ModificationTime, 12);
ReturnIfBadOctal(header.CheckSum, 8);
ReturnIfBadOctal(header.DeviceMajor, 8);
ReturnIfBadOctal(header.DeviceMinor, 8);
item.Mode = OctalToNumber(header.Mode);
item.UID = OctalToNumber(header.UID);
item.GID = OctalToNumber(header.GID);
item.Size = OctalToNumber(header.Size);
if (item.LinkFlag == NFileHeader::NLinkFlag::kLink)
item.Size = 0;
item.ModificationTime = OctalToNumber(header.ModificationTime);
item.LinkName = header.LinkName;
memmove(item.Magic, header.Magic, 8);
item.UserName = header.UserName;
item.GroupName = header.GroupName;
item.DeviceMajorDefined = (header.DeviceMajor[0] != 0);
if (item.DeviceMajorDefined)
item.DeviceMajor = OctalToNumber(header.DeviceMajor);
item.DeviceMinorDefined = (header.DeviceMinor[0] != 0);
if (item.DeviceMinorDefined)
item.DeviceMinor = OctalToNumber(header.DeviceMinor);
UINT32 checkSum = OctalToNumber(header.CheckSum);
memmove(header.CheckSum, NFileHeader::kCheckSumBlanks, 8);
UINT32 checkSumReal = 0;
for(i = 0; i < NFileHeader::kRecordSize; i++)
checkSumReal += BYTE(record.Padding[i]);
if (checkSumReal != checkSum)
return S_FALSE;
filled = true;
return S_OK;
}
HRESULT CInArchive::GetNextItem(bool &filled, CItemEx &item)
{
RINOK(GetNextItemReal(filled, item));
if (!filled)
return S_OK;
// GNUtar extension
if (item.LinkFlag == 'L')
{
if (item.Name.Compare(NFileHeader::kLongLink) != 0)
return S_FALSE;
UINT64 headerPosition = item.HeaderPosition;
UINT32 processedSize;
AString fullName;
char *buffer = fullName.GetBuffer((UINT32)item.Size + 1);
RINOK(ReadBytes(buffer, (UINT32)item.Size, processedSize));
buffer[item.Size] = '\0';
fullName.ReleaseBuffer();
if (processedSize != item.Size)
return S_FALSE;
RINOK(Skeep((0 - item.Size) & 0x1FF));
RINOK(GetNextItemReal(filled, item));
item.Name = fullName;
item.LongLinkSize = item.HeaderPosition - headerPosition;
item.HeaderPosition = headerPosition;
}
else if (item.LinkFlag > '7' || (item.LinkFlag < '0' && item.LinkFlag != 0))
return S_FALSE;
return S_OK;
}
HRESULT CInArchive::Skeep(UINT64 numBytes)
{
UINT64 newPostion;
RINOK(m_Stream->Seek(numBytes, STREAM_SEEK_CUR, &newPostion));
m_Position += numBytes;
if (m_Position != newPostion)
return E_FAIL;
return S_OK;
}
HRESULT CInArchive::SkeepDataRecords(UINT64 dataSize)
{
return Skeep((dataSize + 511) &
#if ( __GNUC__)
0xFFFFFFFFFFFFFE00LL
#else
0xFFFFFFFFFFFFFE00
#endif
);
}
}}

32
7zip/Archive/Tar/TarIn.h Executable file
View File

@@ -0,0 +1,32 @@
// Archive/TarIn.h
#pragma once
#ifndef __ARCHIVE_TAR_IN_H
#define __ARCHIVE_TAR_IN_H
#include "Common/MyCom.h"
#include "../../IStream.h"
#include "TarItem.h"
namespace NArchive {
namespace NTar {
class CInArchive
{
CMyComPtr<IInStream> m_Stream;
UINT64 m_Position;
HRESULT ReadBytes(void *data, UINT32 size, UINT32 &processedSize);
public:
HRESULT Open(IInStream *inStream);
HRESULT GetNextItemReal(bool &filled, CItemEx &itemInfo);
HRESULT GetNextItem(bool &filled, CItemEx &itemInfo);
HRESULT Skeep(UINT64 numBytes);
HRESULT SkeepDataRecords(UINT64 dataSize);
};
}}
#endif

67
7zip/Archive/Tar/TarItem.h Executable file
View File

@@ -0,0 +1,67 @@
// Archive/Tar/Item.h
#pragma once
#ifndef __ARCHIVE_TAR_ITEM_H
#define __ARCHIVE_TAR_ITEM_H
#include <time.h>
#include "Common/Types.h"
#include "Common/String.h"
#include "TarHeader.h"
namespace NArchive {
namespace NTar {
class CItem
{
public:
AString Name;
UINT32 Mode;
UINT32 UID;
UINT32 GID;
UINT64 Size;
time_t ModificationTime;
char LinkFlag;
AString LinkName;
char Magic[8];
AString UserName;
AString GroupName;
bool DeviceMajorDefined;
UINT32 DeviceMajor;
bool DeviceMinorDefined;
UINT32 DeviceMinor;
bool IsDirectory() const
{
if (LinkFlag == NFileHeader::NLinkFlag::kDirectory)
return true;
if (LinkFlag == NFileHeader::NLinkFlag::kOldNormal ||
LinkFlag == NFileHeader::NLinkFlag::kNormal)
{
if (Name.IsEmpty())
return false;
#ifdef WIN32
return (*CharPrevExA(CP_OEMCP, Name, &Name[Name.Length()], 0) == '/');
#else
return (Name[Name.Length() - 1) == '/');
#endif
}
return false;
}
};
class CItemEx: public CItem
{
public:
UINT64 HeaderPosition;
UINT64 LongLinkSize;
UINT64 GetDataPosition() const { return HeaderPosition + LongLinkSize + NFileHeader::kRecordSize; };
UINT64 GetFullSize() const { return LongLinkSize + NFileHeader::kRecordSize + Size; };
};
}}
#endif

155
7zip/Archive/Tar/TarOut.cpp Executable file
View File

@@ -0,0 +1,155 @@
// Archive/TarOut.cpp
#include "StdAfx.h"
#include "TarOut.h"
#include "TarHeader.h"
#include "Windows/Defs.h"
namespace NArchive {
namespace NTar {
HRESULT COutArchive::WriteBytes(const void *buffer, UINT32 size)
{
UINT32 processedSize;
RINOK(m_Stream->Write(buffer, size, &processedSize));
if(processedSize != size)
return E_FAIL;
return S_OK;
}
void COutArchive::Create(ISequentialOutStream *outStream)
{
m_Stream = outStream;
}
static AString MakeOctalString(UINT64 value)
{
char s[32];
_ui64toa(value, s, 8);
return AString(s) + ' ';
}
static bool MakeOctalString8(char *s, UINT32 value)
{
AString tempString = MakeOctalString(value);
const int kMaxSize = 8;
if (tempString.Length() >= kMaxSize)
return false;
int numSpaces = kMaxSize - (tempString.Length() + 1);
for(int i = 0; i < numSpaces; i++)
s[i] = ' ';
strcpy(s + numSpaces, tempString);
return true;
}
static bool MakeOctalString12(char *s, UINT64 value)
{
AString tempString = MakeOctalString(value);
const int kMaxSize = 12;
if (tempString.Length() > kMaxSize)
return false;
int numSpaces = kMaxSize - tempString.Length();
for(int i = 0; i < numSpaces; i++)
s[i] = ' ';
memmove(s + numSpaces, (const char *)tempString, tempString.Length());
return true;
}
static bool CopyString(char *dest, const AString &src, int maxSize)
{
if (src.Length() >= maxSize)
return false;
strcpy(dest, src);
return true;
}
#define RETURN_IF_NOT_TRUE(x) { if (!(x)) return E_FAIL; }
HRESULT COutArchive::WriteHeaderReal(const CItem &item)
{
NFileHeader::CRecord record;
int i;
for (i = 0; i < NFileHeader::kRecordSize; i++)
record.Padding[i] = 0;
NFileHeader::CHeader &header = record.Header;
// RETURN_IF_NOT_TRUE(CopyString(header.Name, item.Name, NFileHeader::kNameSize));
if (item.Name.Length() > NFileHeader::kNameSize)
return E_FAIL;
strncpy(header.Name, item.Name, NFileHeader::kNameSize);
RETURN_IF_NOT_TRUE(CopyString(header.LinkName, item.LinkName, NFileHeader::kNameSize));
RETURN_IF_NOT_TRUE(CopyString(header.UserName, item.UserName, NFileHeader::kUserNameSize));
RETURN_IF_NOT_TRUE(CopyString(header.GroupName, item.GroupName, NFileHeader::kGroupNameSize));
RETURN_IF_NOT_TRUE(MakeOctalString8(header.Mode, item.Mode));
RETURN_IF_NOT_TRUE(MakeOctalString8(header.UID, item.UID));
RETURN_IF_NOT_TRUE(MakeOctalString8(header.GID, item.GID));
RETURN_IF_NOT_TRUE(MakeOctalString12(header.Size, item.Size));
RETURN_IF_NOT_TRUE(MakeOctalString12(header.ModificationTime, item.ModificationTime));
header.LinkFlag = item.LinkFlag;
memmove(header.Magic, item.Magic, 8);
if (item.DeviceMajorDefined)
RETURN_IF_NOT_TRUE(MakeOctalString8(header.DeviceMajor, item.DeviceMajor));
if (item.DeviceMinorDefined)
RETURN_IF_NOT_TRUE(MakeOctalString8(header.DeviceMinor, item.DeviceMinor));
memmove(header.CheckSum, NFileHeader::kCheckSumBlanks, 8);
UINT32 checkSumReal = 0;
for(i = 0; i < NFileHeader::kRecordSize; i++)
checkSumReal += BYTE(record.Padding[i]);
RETURN_IF_NOT_TRUE(MakeOctalString8(header.CheckSum, checkSumReal));
return WriteBytes(&record, sizeof(record));
}
HRESULT COutArchive::WriteHeader(const CItem &item)
{
int nameSize = item.Name.Length();
if (nameSize < NFileHeader::kNameSize)
return WriteHeaderReal(item);
CItem modifiedItem = item;
int nameStreamSize = nameSize + 1;
modifiedItem.Size = nameStreamSize;
modifiedItem.LinkFlag = 'L';
modifiedItem.Name = NFileHeader::kLongLink;
modifiedItem.LinkName.Empty();
RINOK(WriteHeaderReal(modifiedItem));
RINOK(WriteBytes(item.Name, nameStreamSize));
RINOK(FillDataResidual(nameStreamSize));
modifiedItem = item;
modifiedItem.Name = item.Name.Left(NFileHeader::kNameSize - 1);
return WriteHeaderReal(modifiedItem);
}
HRESULT COutArchive::FillDataResidual(UINT64 dataSize)
{
UINT32 lastRecordSize = UINT32(dataSize & (NFileHeader::kRecordSize - 1));
if (lastRecordSize == 0)
return S_OK;
UINT32 residualSize = NFileHeader::kRecordSize - lastRecordSize;
BYTE residualBytes[NFileHeader::kRecordSize];
for (UINT32 i = 0; i < residualSize; i++)
residualBytes[i] = 0;
return WriteBytes(residualBytes, residualSize);
}
HRESULT COutArchive::WriteFinishHeader()
{
NFileHeader::CRecord record;
for (int i = 0; i < NFileHeader::kRecordSize; i++)
record.Padding[i] = 0;
return WriteBytes(&record, sizeof(record));
}
}}

30
7zip/Archive/Tar/TarOut.h Executable file
View File

@@ -0,0 +1,30 @@
// Archive/TarOut.h
#pragma once
#ifndef __ARCHIVE_TAR_OUT_H
#define __ARCHIVE_TAR_OUT_H
#include "TarItem.h"
#include "Common/MyCom.h"
#include "../../IStream.h"
namespace NArchive {
namespace NTar {
class COutArchive
{
CMyComPtr<ISequentialOutStream> m_Stream;
HRESULT WriteBytes(const void *buffer, UINT32 size);
public:
void Create(ISequentialOutStream *outStream);
HRESULT WriteHeaderReal(const CItem &item);
HRESULT WriteHeader(const CItem &item);
HRESULT FillDataResidual(UINT64 dataSize);
HRESULT WriteFinishHeader();
};
}}
#endif

156
7zip/Archive/Tar/TarUpdate.cpp Executable file
View File

@@ -0,0 +1,156 @@
// TarUpdate.cpp
#include "StdAfx.h"
#include "Common/Defs.h"
#include "Common/StringConvert.h"
#include "Windows/Defs.h"
#include "../../Common/ProgressUtils.h"
#include "../../Common/LimitedStreams.h"
#include "../../Compress/Copy/CopyCoder.h"
#include "TarOut.h"
#include "TarUpdate.h"
static const UINT64 kOneItemComplexity = 512;
namespace NArchive {
namespace NTar {
static HRESULT CopyBlock(ISequentialInStream *inStream,
ISequentialOutStream *outStream, ICompressProgressInfo *progress,
UINT64 *totalSize = NULL)
{
NCompress::CCopyCoder *copyCoderSpec = new NCompress::CCopyCoder;
CMyComPtr<ICompressCoder> copyCoder = copyCoderSpec;
HRESULT result = copyCoder->Code(inStream, outStream, NULL, NULL, progress);
if (totalSize != NULL)
*totalSize = copyCoderSpec->TotalSize;
return result;
}
HRESULT UpdateArchive(IInStream *inStream, ISequentialOutStream *outStream,
const CObjectVector<NArchive::NTar::CItemEx> &inputItems,
const CObjectVector<CUpdateItemInfo> &updateItems,
IArchiveUpdateCallback *updateCallback)
{
COutArchive outArchive;
outArchive.Create(outStream);
UINT64 complexity = 0;
int i;
for(i = 0; i < updateItems.Size(); i++)
{
const CUpdateItemInfo &updateItem = updateItems[i];
if (updateItem.NewData)
complexity += updateItem.Size;
else
complexity += inputItems[updateItem.IndexInArchive].GetFullSize();
complexity += kOneItemComplexity;
}
RINOK(updateCallback->SetTotal(complexity));
complexity = 0;
for(i = 0; i < updateItems.Size(); i++)
{
RINOK(updateCallback->SetCompleted(&complexity));
CLocalProgress *localProgressSpec = new CLocalProgress;
CMyComPtr<ICompressProgressInfo> localProgress = localProgressSpec;
localProgressSpec->Init(updateCallback, true);
CLocalCompressProgressInfo *localCompressProgressSpec = new CLocalCompressProgressInfo;
CMyComPtr<ICompressProgressInfo> compressProgress = localCompressProgressSpec;
localCompressProgressSpec->Init(localProgress, &complexity, NULL);
const CUpdateItemInfo &updateItem = updateItems[i];
CItem item;
if (updateItem.NewProperties)
{
item.Mode = 0777;
item.Name = (updateItem.Name);
if (updateItem.IsDirectory)
{
item.LinkFlag = NFileHeader::NLinkFlag::kDirectory;
item.Size = 0;
}
else
{
item.LinkFlag = NFileHeader::NLinkFlag::kNormal;
item.Size = updateItem.Size;
}
item.ModificationTime = updateItem.Time;
item.DeviceMajorDefined = false;
item.DeviceMinorDefined = false;
item.UID = 0;
item.GID = 0;
memmove(item.Magic, NFileHeader::NMagic::kEmpty, 8);
}
else
{
const CItemEx &existItemInfo = inputItems[updateItem.IndexInArchive];
item = existItemInfo;
}
if (updateItem.NewData)
{
item.Size = updateItem.Size;
}
else
{
const CItemEx &existItemInfo = inputItems[updateItem.IndexInArchive];
item.Size = existItemInfo.Size;
}
if (updateItem.NewData || updateItem.NewProperties)
{
RINOK(outArchive.WriteHeader(item));
}
if (updateItem.NewData)
{
CMyComPtr<IInStream> fileInStream;
RINOK(updateCallback->GetStream(updateItem.IndexInClient, &fileInStream));
if (!updateItem.IsDirectory)
{
UINT64 totalSize;
RINOK(CopyBlock(fileInStream, outStream, compressProgress, &totalSize));
if (totalSize != item.Size)
return E_FAIL;
RINOK(outArchive.FillDataResidual(item.Size));
}
complexity += updateItem.Size;
RINOK(updateCallback->SetOperationResult(
NArchive::NUpdate::NOperationResult::kOK));
}
else
{
CLimitedSequentialInStream *streamSpec = new CLimitedSequentialInStream;
CMyComPtr<CLimitedSequentialInStream> inStreamLimited(streamSpec);
const CItemEx &existItemInfo = inputItems[updateItem.IndexInArchive];
if (updateItem.NewProperties)
{
RINOK(inStream->Seek(existItemInfo.GetDataPosition(),
STREAM_SEEK_SET, NULL));
streamSpec->Init(inStream, existItemInfo.Size);
}
else
{
RINOK(inStream->Seek(existItemInfo.HeaderPosition,
STREAM_SEEK_SET, NULL));
streamSpec->Init(inStream, existItemInfo.GetFullSize());
}
RINOK(CopyBlock(inStreamLimited, outStream, compressProgress));
RINOK(outArchive.FillDataResidual(existItemInfo.Size));
complexity += existItemInfo.GetFullSize();
}
complexity += kOneItemComplexity;
}
return outArchive.WriteFinishHeader();
}
}}

38
7zip/Archive/Tar/TarUpdate.h Executable file
View File

@@ -0,0 +1,38 @@
// Tar/Update.h
#pragma once
#ifndef __TAR_UPDATE_H
#define __TAR_UPDATE_H
#include "Common/Vector.h"
#include "Common/Types.h"
#include "Common/String.h"
#include "../IArchive.h"
#include "TarItem.h"
namespace NArchive {
namespace NTar {
struct CUpdateItemInfo
{
bool NewData;
bool NewProperties;
int IndexInArchive;
int IndexInClient;
time_t Time;
UINT64 Size;
AString Name;
bool IsDirectory;
};
HRESULT UpdateArchive(IInStream *inStream, ISequentialOutStream *outStream,
const CObjectVector<CItemEx> &inputItems,
const CObjectVector<CUpdateItemInfo> &updateItems,
IArchiveUpdateCallback *updateCallback);
}}
#endif

16
7zip/Archive/Tar/resource.h Executable file
View File

@@ -0,0 +1,16 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by resource.rc
//
#define IDI_ICON1 101
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 102
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

130
7zip/Archive/Tar/resource.rc Executable file
View File

@@ -0,0 +1,130 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// Russian resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS)
#ifdef _WIN32
LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
#pragma code_page(1251)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // Russian resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ICON1 ICON DISCARDABLE "Tar.ico"
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,9,2,0
PRODUCTVERSION 3,9,2,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x40004L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "Comments", "\0"
VALUE "CompanyName", "Igor Pavlov\0"
VALUE "FileDescription", "Tar Plugin for 7-Zip\0"
VALUE "FileVersion", "3, 9, 2, 0\0"
VALUE "InternalName", "tar\0"
VALUE "LegalCopyright", "Copyright (C) 1999-2003 Igor Pavlov\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename", "tar.dll\0"
VALUE "PrivateBuild", "\0"
VALUE "ProductName", "7-Zip\0"
VALUE "ProductVersion", "3, 9, 2, 0\0"
VALUE "SpecialBuild", "\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
#endif // !_MAC
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

BIN
7zip/Archive/Tar/tar.ico Executable file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB