This commit is contained in:
Igor Pavlov
2010-11-02 00:00:00 +00:00
committed by Kornel Lesiński
parent 2eb60a0598
commit c65230d858
101 changed files with 4557 additions and 541 deletions

View File

@@ -609,7 +609,7 @@ STDMETHODIMP CAgent::GetArcProp(UInt32 level, PROPID propID, PROPVARIANT *value)
CArc &arc = _archiveLink.Arcs[level];
switch(propID)
{
case kpidType: prop = _codecs->Formats[arc.FormatIndex].Name; break;
case kpidType: prop = GetTypeOfArc(arc); break;
case kpidPath: prop = arc.Path; break;
default: return arc.Archive->GetArchiveProperty(propID, value);
}

View File

@@ -206,6 +206,27 @@ public:
const CArc &GetArc() { return _archiveLink.Arcs.Back(); }
IInArchive *GetArchive() { if ( _archiveLink.Arcs.IsEmpty()) return 0; return GetArc().Archive; }
bool CanUpdate() const { return _archiveLink.Arcs.Size() <= 1; }
UString GetTypeOfArc(const CArc &arc) const { return _codecs->Formats[arc.FormatIndex].Name; }
UString GetErrorMessage() const
{
UString s;
for (int i = _archiveLink.Arcs.Size() - 1; i >= 0; i--)
{
const CArc &arc = _archiveLink.Arcs[i];
if (arc.ErrorMessage.IsEmpty())
continue;
if (!s.IsEmpty())
s += L"--------------------\n";
s += arc.ErrorMessage;
s += L"\n\n[";
s += GetTypeOfArc(arc);
s += L"] ";
s += arc.Path;
s += L"\n";
}
return s;
}
};
#ifdef NEW_FOLDER_INTERFACE

View File

@@ -228,6 +228,15 @@ HRESULT DecompressArchives(
}
#endif
for (int v = 0; v < archiveLink.Arcs.Size(); v++)
{
const UString &s = archiveLink.Arcs[v].ErrorMessage;
if (!s.IsEmpty())
{
RINOK(extractCallback->MessageError(s));
}
}
CArc &arc = archiveLink.Arcs.Back();
arc.MTimeDefined = (!options.StdInMode && !fi.IsDevice);
arc.MTime = fi.MTime;

View File

@@ -2,6 +2,8 @@
#include "StdAfx.h"
#include "../../../../C/Types.h"
#include "Common/Wildcard.h"
#include "ExtractingFilePath.h"

View File

@@ -111,6 +111,7 @@ HRESULT CArc::OpenStream(
IArchiveOpenCallback *callback)
{
Archive.Release();
ErrorMessage.Empty();
const UString fileName = ExtractFileNameFromPath(Path);
UString extension;
{
@@ -298,6 +299,13 @@ HRESULT CArc::OpenStream(
if (result == S_FALSE)
continue;
RINOK(result);
{
NCOM::CPropVariant prop;
archive->GetArchiveProperty(kpidError, &prop);
if (prop.vt != VT_EMPTY)
ErrorMessage = (prop.vt == VT_BSTR) ? prop.bstrVal : L"Unknown error";
}
Archive = archive;
const CArcInfoEx &format = codecs->Formats[FormatIndex];

View File

@@ -24,6 +24,7 @@ struct CArc
int SubfileIndex;
FILETIME MTime;
bool MTimeDefined;
UString ErrorMessage;
CArc(): MTimeDefined(false) {}

View File

@@ -45,6 +45,7 @@ static const char g_WinAttrib[17] = "RHS8DAdNTsrCOnE_";
16 VIRTUAL
*/
static const char kPosixTypes[16] = { '0', 'p', 'c', '3', 'd', '5', 'b', '7', '-', '9', 'l', 'B', 's', 'D', 'E', 'F' };
#define MY_ATTR_CHAR(a, n, c) ((a )& (1 << (n))) ? c : L'-';
UString ConvertPropertyToString(const PROPVARIANT &prop, PROPID propID, bool full)
@@ -92,17 +93,21 @@ UString ConvertPropertyToString(const PROPVARIANT &prop, PROPID propID, bool ful
UString res;
UInt32 a = prop.ulVal;
wchar_t temp[16];
temp[0] = MY_ATTR_CHAR(a, 14, L'd');
temp[0] = kPosixTypes[(a >> 12) & 0xF];
for (int i = 6; i >= 0; i -= 3)
{
temp[7 - i] = MY_ATTR_CHAR(a, i + 2, L'r');
temp[8 - i] = MY_ATTR_CHAR(a, i + 1, L'w');
temp[9 - i] = MY_ATTR_CHAR(a, i + 0, L'x');
}
if ((a & 0x800) != 0) temp[3] = ((a & (1 << 6)) ? 's' : 'S');
if ((a & 0x400) != 0) temp[6] = ((a & (1 << 3)) ? 's' : 'S');
if ((a & 0x200) != 0) temp[9] = ((a & (1 << 0)) ? 't' : 'T');
temp[10] = 0;
res = temp;
a &= ~0x1FF;
a &= ~0xC000;
a &= ~(UInt32)0xFFFF;
if (a != 0)
{
ConvertUInt32ToHex(a, temp);

View File

@@ -29,7 +29,7 @@ struct CPropIdToName
const wchar_t *Name;
};
static CPropIdToName kPropIdToName[] =
static const CPropIdToName kPropIdToName[] =
{
{ kpidPath, L"Path" },
{ kpidName, L"Name" },
@@ -82,6 +82,7 @@ static CPropIdToName kPropIdToName[] =
{ kpidSectorSize, L"Sector Size" },
{ kpidPosixAttrib, L"Mode" },
{ kpidLink, L"Link" },
{ kpidError, L"Error" },
{ kpidTotalSize, L"Total Size" },
{ kpidFreeSpace, L"Free Space" },
@@ -505,6 +506,8 @@ HRESULT ListArchives(CCodecs *codecs, const CIntVector &formatIndices,
g_StdOut << "--\n";
PrintPropPair(L"Path", arc.Path);
PrintPropPair(L"Type", codecs->Formats[arc.FormatIndex].Name);
if (!arc.ErrorMessage.IsEmpty())
PrintPropPair(L"Error", arc.ErrorMessage);
UInt32 numProps;
IInArchive *archive = arc.Archive;
if (archive->GetNumberOfArchiveProperties(&numProps) == S_OK)

View File

@@ -26,7 +26,6 @@
#ifdef EXTERNAL_CODECS
#include "../Common/LoadCodecs.h"
#endif
#include "../Common/PropIDUtils.h"
#include "BenchCon.h"
#include "ExtractCallbackConsole.h"
@@ -457,8 +456,8 @@ int Main2(
<< "Compressed: " << stat.PackSize << endl;
if (options.CalcCrc)
{
wchar_t s[16];
ConvertUInt32ToHex(stat.CrcSum, s);
char s[16];
ConvertUInt32ToHexWithZeros(stat.CrcSum, s);
stdStream << "CRC: " << s << endl;
}
}

View File

@@ -53,7 +53,7 @@ BSC32=bscmake.exe
# 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\Far2\Plugins\7-Zip\7-ZipFar.dll" /opt:NOWIN98
# 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\Far\Plugins\7-Zip\7-ZipFar.dll" /opt:NOWIN98
# SUBTRACT LINK32 /pdb:none
!ELSEIF "$(CFG)" == "Far - Win32 Debug"
@@ -80,7 +80,7 @@ BSC32=bscmake.exe
# 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\Far2\Plugins\7-Zip\7-ZipFar.dll" /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\Far\Plugins\7-Zip\7-ZipFar.dll" /pdbtype:sept
!ENDIF

View File

@@ -61,7 +61,7 @@ struct PluginPanelItem
char **CustomColumnData;
int CustomColumnNumber;
DWORD_PTR UserData;
DWORD CRC32;
DWORD CRC32;
DWORD_PTR Reserved[2];
};
@@ -484,34 +484,34 @@ enum OPERATION_MODES {
/*
EXTERN_C_BEGIN
void WINAPI _export ClosePluginW(HANDLE hPlugin);
int WINAPI _export CompareW(HANDLE hPlugin,const struct PluginPanelItem *Item1,const struct PluginPanelItem *Item2,unsigned int Mode);
int WINAPI _export ConfigureW(int ItemNumber);
int WINAPI _export DeleteFilesW(HANDLE hPlugin,struct PluginPanelItem *PanelItem,int ItemsNumber,int OpMode);
void WINAPI _export ExitFARW(void);
void WINAPI _export FreeFindDataW(HANDLE hPlugin,struct PluginPanelItem *PanelItem,int ItemsNumber);
void WINAPI _export FreeVirtualFindDataW(HANDLE hPlugin,struct PluginPanelItem *PanelItem,int ItemsNumber);
int WINAPI _export GetFilesW(HANDLE hPlugin,struct PluginPanelItem *PanelItem,int ItemsNumber,int Move,const wchar_t **DestPath,int OpMode);
int WINAPI _export GetFindDataW(HANDLE hPlugin,struct PluginPanelItem **pPanelItem,int *pItemsNumber,int OpMode);
int WINAPI _export GetMinFarVersionW(void);
void WINAPI _export GetOpenPluginInfoW(HANDLE hPlugin,struct OpenPluginInfo *Info);
void WINAPI _export GetPluginInfoW(struct PluginInfo *Info);
int WINAPI _export GetVirtualFindDataW(HANDLE hPlugin,struct PluginPanelItem **pPanelItem,int *pItemsNumber,const wchar_t *Path);
int WINAPI _export MakeDirectoryW(HANDLE hPlugin,const wchar_t **Name,int OpMode);
HANDLE WINAPI _export OpenFilePluginW(const wchar_t *Name,const unsigned char *Data,int DataSize,int OpMode);
HANDLE WINAPI _export OpenPluginW(int OpenFrom,INT_PTR Item);
int WINAPI _export ProcessDialogEventW(int Event,void *Param);
int WINAPI _export ProcessEditorEventW(int Event,void *Param);
int WINAPI _export ProcessEditorInputW(const INPUT_RECORD *Rec);
int WINAPI _export ProcessEventW(HANDLE hPlugin,int Event,void *Param);
int WINAPI _export ProcessHostFileW(HANDLE hPlugin,struct PluginPanelItem *PanelItem,int ItemsNumber,int OpMode);
int WINAPI _export ProcessKeyW(HANDLE hPlugin,int Key,unsigned int ControlState);
int WINAPI _export ProcessSynchroEventW(int Event,void *Param);
int WINAPI _export ProcessViewerEventW(int Event,void *Param);
int WINAPI _export PutFilesW(HANDLE hPlugin,struct PluginPanelItem *PanelItem,int ItemsNumber,int Move,const wchar_t *SrcPath,int OpMode);
int WINAPI _export SetDirectoryW(HANDLE hPlugin,const wchar_t *Dir,int OpMode);
int WINAPI _export SetFindListW(HANDLE hPlugin,const struct PluginPanelItem *PanelItem,int ItemsNumber);
void WINAPI _export SetStartupInfoW(const struct PluginStartupInfo *Info);
void WINAPI _export ClosePluginW(HANDLE hPlugin);
int WINAPI _export CompareW(HANDLE hPlugin,const struct PluginPanelItem *Item1,const struct PluginPanelItem *Item2,unsigned int Mode);
int WINAPI _export ConfigureW(int ItemNumber);
int WINAPI _export DeleteFilesW(HANDLE hPlugin,struct PluginPanelItem *PanelItem,int ItemsNumber,int OpMode);
void WINAPI _export ExitFARW(void);
void WINAPI _export FreeFindDataW(HANDLE hPlugin,struct PluginPanelItem *PanelItem,int ItemsNumber);
void WINAPI _export FreeVirtualFindDataW(HANDLE hPlugin,struct PluginPanelItem *PanelItem,int ItemsNumber);
int WINAPI _export GetFilesW(HANDLE hPlugin,struct PluginPanelItem *PanelItem,int ItemsNumber,int Move,const wchar_t **DestPath,int OpMode);
int WINAPI _export GetFindDataW(HANDLE hPlugin,struct PluginPanelItem **pPanelItem,int *pItemsNumber,int OpMode);
int WINAPI _export GetMinFarVersionW(void);
void WINAPI _export GetOpenPluginInfoW(HANDLE hPlugin,struct OpenPluginInfo *Info);
void WINAPI _export GetPluginInfoW(struct PluginInfo *Info);
int WINAPI _export GetVirtualFindDataW(HANDLE hPlugin,struct PluginPanelItem **pPanelItem,int *pItemsNumber,const wchar_t *Path);
int WINAPI _export MakeDirectoryW(HANDLE hPlugin,const wchar_t **Name,int OpMode);
HANDLE WINAPI _export OpenFilePluginW(const wchar_t *Name,const unsigned char *Data,int DataSize,int OpMode);
HANDLE WINAPI _export OpenPluginW(int OpenFrom,INT_PTR Item);
int WINAPI _export ProcessDialogEventW(int Event,void *Param);
int WINAPI _export ProcessEditorEventW(int Event,void *Param);
int WINAPI _export ProcessEditorInputW(const INPUT_RECORD *Rec);
int WINAPI _export ProcessEventW(HANDLE hPlugin,int Event,void *Param);
int WINAPI _export ProcessHostFileW(HANDLE hPlugin,struct PluginPanelItem *PanelItem,int ItemsNumber,int OpMode);
int WINAPI _export ProcessKeyW(HANDLE hPlugin,int Key,unsigned int ControlState);
int WINAPI _export ProcessSynchroEventW(int Event,void *Param);
int WINAPI _export ProcessViewerEventW(int Event,void *Param);
int WINAPI _export PutFilesW(HANDLE hPlugin,struct PluginPanelItem *PanelItem,int ItemsNumber,int Move,const wchar_t *SrcPath,int OpMode);
int WINAPI _export SetDirectoryW(HANDLE hPlugin,const wchar_t *Dir,int OpMode);
int WINAPI _export SetFindListW(HANDLE hPlugin,const struct PluginPanelItem *PanelItem,int ItemsNumber);
void WINAPI _export SetStartupInfoW(const struct PluginStartupInfo *Info);
EXTERN_C_END
*/

View File

@@ -366,7 +366,8 @@ static HANDLE MyOpenFilePluginW(const wchar_t *name)
// ::OutputDebugStringA("before OpenArchive\n");
archiveHandler = new CAgent;
CAgent *agent = new CAgent;
archiveHandler = agent;
CMyComBSTR archiveType;
HRESULT result = archiveHandler->Open(NULL,
GetUnicodeString(fullName, CP_OEMCP), UString(), &archiveType, openArchiveCallback);
@@ -381,6 +382,10 @@ static HANDLE MyOpenFilePluginW(const wchar_t *name)
return INVALID_HANDLE_VALUE;
}
UString errorMessage = agent->GetErrorMessage();
if (!errorMessage.IsEmpty())
PrintErrorMessage("7-Zip", UnicodeStringToMultiByte(errorMessage, CP_OEMCP));
// ::OutputDebugStringA("after OpenArchive\n");
CPlugin *plugin = new CPlugin(

View File

@@ -326,7 +326,8 @@ static CPROPIDToName kPROPIDToName[] =
{ kpidSectorSize, NMessageID::kSectorSize },
{ kpidPosixAttrib, NMessageID::kPosixAttrib },
{ kpidLink, NMessageID::kLink },
{ kpidError, NMessageID::kError },
{ kpidTotalSize, NMessageID::kTotalSize },
{ kpidFreeSpace, NMessageID::kFreeSpace },
{ kpidClusterSize, NMessageID::kClusterSize },
@@ -628,17 +629,20 @@ void CPlugin::GetOpenPluginInfo(struct OpenPluginInfo *info)
if (getProps->GetArcNumProps(level, &numProps) == S_OK)
{
InsertSeparator(m_InfoLines, numItems);
for (Int32 i = -2; i < (Int32)numProps && numItems < kNumInfoLinesMax; i++)
for (Int32 i = -3; i < (Int32)numProps && numItems < kNumInfoLinesMax; i++)
{
CMyComBSTR name;
PROPID propID;
VARTYPE vt;
if (i == -2)
propID = kpidPath;
else if (i == -1)
propID = kpidType;
else if (getProps->GetArcPropInfo(level, i, &name, &propID, &vt) != S_OK)
continue;
switch (i)
{
case -3: propID = kpidPath; break;
case -2: propID = kpidType; break;
case -1: propID = kpidError; break;
default:
if (getProps->GetArcPropInfo(level, i, &name, &propID, &vt) != S_OK)
continue;
}
NCOM::CPropVariant prop;
if (getProps->GetArcProp(level, propID, &prop) != S_OK)
continue;

View File

@@ -9,6 +9,7 @@
#include "Windows/FileDir.h"
#include "Windows/FileFind.h"
#include "Windows/Process.h"
#include "Windows/PropVariant.h"
#include "Windows/Thread.h"
#include "../Common/ExtractingFilePath.h"
@@ -113,6 +114,46 @@ HRESULT CPanel::OpenItemAsArchive(IInStream *inStream,
_flatMode = _flatModeForArc;
CMyComPtr<IGetFolderArcProps> getFolderArcProps;
_folder.QueryInterface(IID_IGetFolderArcProps, &getFolderArcProps);
if (getFolderArcProps)
{
CMyComPtr<IFolderArcProps> arcProps;
getFolderArcProps->GetFolderArcProps(&arcProps);
if (arcProps)
{
UString s;
UInt32 numLevels;
if (arcProps->GetArcNumLevels(&numLevels) != S_OK)
numLevels = 0;
for (UInt32 level2 = 0; level2 < numLevels; level2++)
{
UInt32 level = numLevels - 1 - level2;
PROPID propIDs[] = { kpidError, kpidPath, kpidType } ;
UString values[3];
for (Int32 i = 0; i < 3; i++)
{
CMyComBSTR name;
NCOM::CPropVariant prop;
if (arcProps->GetArcProp(level, propIDs[i], &prop) != S_OK)
continue;
if (prop.vt != VT_EMPTY)
values[i] = (prop.vt == VT_BSTR) ? prop.bstrVal : L"?";
}
if (!values[0].IsEmpty())
{
if (!s.IsEmpty())
s += L"--------------------\n";
s += values[0]; s += L"\n\n[";
s += values[2]; s += L"] ";
s += values[1]; s += L"\n";
}
}
if (!s.IsEmpty())
MessageBox(s);
}
}
return S_OK;
}

View File

@@ -188,17 +188,20 @@ void CPanel::Properties()
if (getProps->GetArcNumProps(level, &numProps) == S_OK)
{
message += kSeparator;
for (Int32 i = -2; i < (Int32)numProps; i++)
for (Int32 i = -3; i < (Int32)numProps; i++)
{
CMyComBSTR name;
PROPID propID;
VARTYPE vt;
if (i == -2)
propID = kpidPath;
else if (i == -1)
propID = kpidType;
else if (getProps->GetArcPropInfo(level, i, &name, &propID, &vt) != S_OK)
continue;
switch (i)
{
case -3: propID = kpidPath; break;
case -2: propID = kpidType; break;
case -1: propID = kpidError; break;
default:
if (getProps->GetArcPropInfo(level, i, &name, &propID, &vt) != S_OK)
continue;
}
NCOM::CPropVariant prop;
if (getProps->GetArcProp(level, propID, &prop) != S_OK)
continue;

View File

@@ -61,17 +61,19 @@ int CALLBACK CompareItems2(LPARAM lParam1, LPARAM lParam2, LPARAM lpData)
// PROPID propID = panel->_properties[panel->_sortIndex].ID;
PROPID propID = panel->_sortID;
NCOM::CPropVariant propVariant1, propVariant2;
NCOM::CPropVariant prop1, prop2;
// Name must be first property
panel->_folder->GetProperty((UINT32)lParam1, propID, &propVariant1);
panel->_folder->GetProperty((UINT32)lParam2, propID, &propVariant2);
if (propVariant1.vt != propVariant2.vt)
return 0; // It means some BUG
if (propVariant1.vt == VT_BSTR)
panel->_folder->GetProperty((UINT32)lParam1, propID, &prop1);
panel->_folder->GetProperty((UINT32)lParam2, propID, &prop2);
if (prop1.vt != prop2.vt)
{
return _wcsicmp(propVariant1.bstrVal, propVariant2.bstrVal);
return MyCompare(prop1.vt, prop2.vt);
}
return propVariant1.Compare(propVariant2);
if (prop1.vt == VT_BSTR)
{
return _wcsicmp(prop1.bstrVal, prop2.bstrVal);
}
return prop1.Compare(prop2);
// return 0;
}

View File

@@ -2,6 +2,8 @@
#include "StdAfx.h"
#include "../../../../C/Types.h"
#include "ProgramLocation.h"
#include "Windows/DLL.h"
@@ -20,4 +22,3 @@ bool GetProgramFolderPath(UString &folder)
folder = folder.Left(pos + 1);
return true;
}

View File

@@ -75,6 +75,7 @@ static CPropertyIDNamePair kPropertyIDNamePairs[] =
{ kpidSectorSize, IDS_PROP_SECTOR_SIZE, 0x02000234 },
{ kpidPosixAttrib, IDS_PROP_POSIX_ATTRIB, 0x02000235 },
{ kpidLink, IDS_PROP_LINK, 0x02000236 },
{ kpidError, IDS_PROP_ERROR, 0x02000605 },
{ kpidTotalSize, IDS_PROP_TOTAL_SIZE, 0x03031100 },
{ kpidFreeSpace, IDS_PROP_FREE_SPACE, 0x03031101 },

View File

@@ -56,4 +56,5 @@ BEGIN
IDS_PROP_SECTOR_SIZE "Sector Size"
IDS_PROP_POSIX_ATTRIB "Mode"
IDS_PROP_LINK "Link"
IDS_PROP_ERROR "Error"
END

View File

@@ -50,3 +50,4 @@
#define IDS_PROP_SECTOR_SIZE 52
#define IDS_PROP_POSIX_ATTRIB 53
#define IDS_PROP_LINK 54
#define IDS_PROP_ERROR 55

View File

@@ -1038,7 +1038,13 @@ void CCompressDialog::SetDictionary()
if (i == 20 && j > 0)
continue;
UInt32 dictionary = (1 << i) + (j << (i - 1));
if (dictionary > (1 << 30))
if (dictionary >
#ifdef _WIN64
(1 << 30)
#else
(1 << 29)
#endif
)
continue;
AddDictionarySize(dictionary);
UInt64 decomprSize;