mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-13 06:11:32 -06:00
Update to 7-Zip 17.00 Beta
This commit is contained in:
@@ -523,6 +523,21 @@ static const wchar_t *GetExtension(const wchar_t *name)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int CAgentFolder::CompareItems3(UInt32 index1, UInt32 index2, PROPID propID)
|
||||
{
|
||||
NCOM::CPropVariant prop1, prop2;
|
||||
// Name must be first property
|
||||
GetProperty(index1, propID, &prop1);
|
||||
GetProperty(index2, propID, &prop2);
|
||||
if (prop1.vt != prop2.vt)
|
||||
return MyCompare(prop1.vt, prop2.vt);
|
||||
if (prop1.vt == VT_BSTR)
|
||||
return MyStringCompareNoCase(prop1.bstrVal, prop2.bstrVal);
|
||||
return prop1.Compare(prop2);
|
||||
}
|
||||
|
||||
|
||||
int CAgentFolder::CompareItems2(UInt32 index1, UInt32 index2, PROPID propID, Int32 propIsRaw)
|
||||
{
|
||||
unsigned realIndex1, realIndex2;
|
||||
@@ -651,21 +666,10 @@ int CAgentFolder::CompareItems2(UInt32 index1, UInt32 index2, PROPID propID, Int
|
||||
if (propIsRaw)
|
||||
return CompareRawProps(_agentSpec->_archiveLink.GetArchiveGetRawProps(), arcIndex1, arcIndex2, propID);
|
||||
|
||||
NCOM::CPropVariant prop1, prop2;
|
||||
// Name must be first property
|
||||
GetProperty(index1, propID, &prop1);
|
||||
GetProperty(index2, propID, &prop2);
|
||||
if (prop1.vt != prop2.vt)
|
||||
{
|
||||
return MyCompare(prop1.vt, prop2.vt);
|
||||
}
|
||||
if (prop1.vt == VT_BSTR)
|
||||
{
|
||||
return _wcsicmp(prop1.bstrVal, prop2.bstrVal);
|
||||
}
|
||||
return prop1.Compare(prop2);
|
||||
return CompareItems3(index1, index2, propID);
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP_(Int32) CAgentFolder::CompareItems(UInt32 index1, UInt32 index2, PROPID propID, Int32 propIsRaw)
|
||||
{
|
||||
try {
|
||||
@@ -811,23 +815,12 @@ STDMETHODIMP_(Int32) CAgentFolder::CompareItems(UInt32 index1, UInt32 index2, PR
|
||||
return CompareRawProps(_agentSpec->_archiveLink.GetArchiveGetRawProps(), arcIndex1, arcIndex2, propID);
|
||||
}
|
||||
|
||||
NCOM::CPropVariant prop1, prop2;
|
||||
// Name must be first property
|
||||
GetProperty(index1, propID, &prop1);
|
||||
GetProperty(index2, propID, &prop2);
|
||||
if (prop1.vt != prop2.vt)
|
||||
{
|
||||
return MyCompare(prop1.vt, prop2.vt);
|
||||
}
|
||||
if (prop1.vt == VT_BSTR)
|
||||
{
|
||||
return _wcsicmp(prop1.bstrVal, prop2.bstrVal);
|
||||
}
|
||||
return prop1.Compare(prop2);
|
||||
return CompareItems3(index1, index2, propID);
|
||||
|
||||
} catch(...) { return 0; }
|
||||
}
|
||||
|
||||
|
||||
HRESULT CAgentFolder::BindToFolder_Internal(unsigned proxyDirIndex, IFolderFolder **resultFolder)
|
||||
{
|
||||
/*
|
||||
@@ -1246,7 +1239,7 @@ STDMETHODIMP CAgentFolder::GetFolderProperty(PROPID propID, PROPVARIANT *value)
|
||||
case kpidNumSubFiles: prop = dir.NumSubFiles; break;
|
||||
// case kpidName: prop = dir.Name; break;
|
||||
// case kpidPath: prop = _proxy2->GetFullPathPrefix(_proxyDirIndex); break;
|
||||
case kpidType: prop = UString(L"7-Zip.") + _agentSpec->ArchiveType; break;
|
||||
case kpidType: prop = UString("7-Zip.") + _agentSpec->ArchiveType; break;
|
||||
case kpidCRC: if (dir.CrcIsDefined) prop = dir.Crc; break;
|
||||
}
|
||||
|
||||
@@ -1262,7 +1255,7 @@ STDMETHODIMP CAgentFolder::GetFolderProperty(PROPID propID, PROPVARIANT *value)
|
||||
case kpidNumSubFiles: prop = dir.NumSubFiles; break;
|
||||
case kpidName: prop = dir.Name; break;
|
||||
case kpidPath: prop = _proxy->GetDirPath_as_Prefix(_proxyDirIndex); break;
|
||||
case kpidType: prop = UString(L"7-Zip.") + _agentSpec->ArchiveType; break;
|
||||
case kpidType: prop = UString("7-Zip.") + _agentSpec->ArchiveType; break;
|
||||
case kpidCRC: if (dir.CrcIsDefined) prop = dir.Crc; break;
|
||||
}
|
||||
}
|
||||
@@ -1582,9 +1575,9 @@ STDMETHODIMP CAgent::Open(
|
||||
if (Read_ShowDeleted())
|
||||
{
|
||||
COptionalOpenProperties &optPair = optProps.AddNew();
|
||||
optPair.FormatName = L"ntfs";
|
||||
// optPair.Props.AddNew().Name = L"LS";
|
||||
optPair.Props.AddNew().Name = L"LD";
|
||||
optPair.FormatName = "ntfs";
|
||||
// optPair.Props.AddNew().Name = "LS";
|
||||
optPair.Props.AddNew().Name = "LD";
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
@@ -43,7 +43,8 @@ enum AGENT_OP
|
||||
AGENT_OP_Delete,
|
||||
AGENT_OP_CreateFolder,
|
||||
AGENT_OP_Rename,
|
||||
AGENT_OP_CopyFromFile
|
||||
AGENT_OP_CopyFromFile,
|
||||
AGENT_OP_Comment
|
||||
};
|
||||
|
||||
class CAgentFolder:
|
||||
@@ -101,6 +102,7 @@ public:
|
||||
|
||||
STDMETHOD(GetFolderArcProps)(IFolderArcProps **object);
|
||||
STDMETHOD_(Int32, CompareItems)(UInt32 index1, UInt32 index2, PROPID propID, Int32 propIsRaw);
|
||||
int CompareItems3(UInt32 index1, UInt32 index2, PROPID propID);
|
||||
int CompareItems2(UInt32 index1, UInt32 index2, PROPID propID, Int32 propIsRaw);
|
||||
|
||||
// IArchiveFolder
|
||||
@@ -205,6 +207,10 @@ public:
|
||||
const UInt32 *indices, UInt32 numItems, const wchar_t *newItemName,
|
||||
IFolderArchiveUpdateCallback *updateCallback100);
|
||||
|
||||
HRESULT CommentItem(ISequentialOutStream *outArchiveStream,
|
||||
const UInt32 *indices, UInt32 numItems, const wchar_t *newItemName,
|
||||
IFolderArchiveUpdateCallback *updateCallback100);
|
||||
|
||||
HRESULT UpdateOneFile(ISequentialOutStream *outArchiveStream,
|
||||
const UInt32 *indices, UInt32 numItems, const wchar_t *diskFilePath,
|
||||
IFolderArchiveUpdateCallback *updateCallback100);
|
||||
@@ -262,7 +268,7 @@ public:
|
||||
UString GetTypeOfArc(const CArc &arc) const
|
||||
{
|
||||
if (arc.FormatIndex < 0)
|
||||
return L"Parser";
|
||||
return UString("Parser");
|
||||
return g_CodecsObj->GetFormatNamePtr(arc.FormatIndex);
|
||||
}
|
||||
|
||||
@@ -277,12 +283,12 @@ public:
|
||||
if (arc.ErrorInfo.ErrorFormatIndex >= 0)
|
||||
{
|
||||
if (arc.ErrorInfo.ErrorFormatIndex == arc.FormatIndex)
|
||||
s2.AddAscii("Warning: The archive is open with offset");
|
||||
s2 += "Warning: The archive is open with offset";
|
||||
else
|
||||
{
|
||||
s2.AddAscii("Can not open the file as [");
|
||||
s2 += "Can not open the file as [";
|
||||
s2 += g_CodecsObj->GetFormatNamePtr(arc.ErrorInfo.ErrorFormatIndex);
|
||||
s2.AddAscii("] archive");
|
||||
s2 += "] archive";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -290,16 +296,16 @@ public:
|
||||
{
|
||||
if (!s2.IsEmpty())
|
||||
s2.Add_LF();
|
||||
s2.AddAscii("\n[");
|
||||
s2 += "\n[";
|
||||
s2 += GetTypeOfArc(arc);
|
||||
s2.AddAscii("]: ");
|
||||
s2 += "]: ";
|
||||
s2 += arc.ErrorInfo.ErrorMessage;
|
||||
}
|
||||
|
||||
if (!s2.IsEmpty())
|
||||
{
|
||||
if (!s.IsEmpty())
|
||||
s.AddAscii("--------------------\n");
|
||||
s += "--------------------\n";
|
||||
s += arc.Path;
|
||||
s.Add_LF();
|
||||
s += s2;
|
||||
|
||||
@@ -589,6 +589,55 @@ HRESULT CAgent::RenameItem(ISequentialOutStream *outArchiveStream,
|
||||
return CommonUpdate(outArchiveStream, updatePairs.Size(), updateCallback);
|
||||
}
|
||||
|
||||
|
||||
HRESULT CAgent::CommentItem(ISequentialOutStream *outArchiveStream,
|
||||
const UInt32 *indices, UInt32 numItems, const wchar_t *newItemName,
|
||||
IFolderArchiveUpdateCallback *updateCallback100)
|
||||
{
|
||||
if (!CanUpdate())
|
||||
return E_NOTIMPL;
|
||||
if (numItems != 1)
|
||||
return E_INVALIDARG;
|
||||
if (!_archiveLink.IsOpen)
|
||||
return E_FAIL;
|
||||
|
||||
CRecordVector<CUpdatePair2> updatePairs;
|
||||
CUpdateCallbackAgent updateCallbackAgent;
|
||||
updateCallbackAgent.SetCallback(updateCallback100);
|
||||
CArchiveUpdateCallback *updateCallbackSpec = new CArchiveUpdateCallback;
|
||||
CMyComPtr<IArchiveUpdateCallback> updateCallback(updateCallbackSpec);
|
||||
|
||||
const int mainRealIndex = _agentFolder->GetRealIndex(indices[0]);
|
||||
|
||||
if (mainRealIndex < 0)
|
||||
return E_NOTIMPL;
|
||||
|
||||
UInt32 numItemsInArchive;
|
||||
RINOK(GetArchive()->GetNumberOfItems(&numItemsInArchive));
|
||||
|
||||
UString newName = newItemName;
|
||||
|
||||
for (UInt32 i = 0; i < numItemsInArchive; i++)
|
||||
{
|
||||
CUpdatePair2 up2;
|
||||
up2.SetAs_NoChangeArcItem(i);
|
||||
if ((int)i == mainRealIndex)
|
||||
up2.NewProps = true;
|
||||
updatePairs.Add(up2);
|
||||
}
|
||||
|
||||
updateCallbackSpec->Callback = &updateCallbackAgent;
|
||||
updateCallbackSpec->UpdatePairs = &updatePairs;
|
||||
updateCallbackSpec->CommentIndex = mainRealIndex;
|
||||
updateCallbackSpec->Comment = &newName;
|
||||
|
||||
SetInArchiveInterfaces(this, updateCallbackSpec);
|
||||
|
||||
return CommonUpdate(outArchiveStream, updatePairs.Size(), updateCallback);
|
||||
}
|
||||
|
||||
|
||||
|
||||
HRESULT CAgent::UpdateOneFile(ISequentialOutStream *outArchiveStream,
|
||||
const UInt32 *indices, UInt32 numItems, const wchar_t *diskFilePath,
|
||||
IFolderArchiveUpdateCallback *updateCallback100)
|
||||
|
||||
@@ -316,7 +316,7 @@ HRESULT CProxyArc::Load(const CArc &arc, IProgress *progress)
|
||||
if (numLevels <= kLevelLimit)
|
||||
{
|
||||
if (numLevels == kLevelLimit)
|
||||
name.SetFromAscii("[LONG_PATH]");
|
||||
name = "[LONG_PATH]";
|
||||
else
|
||||
name.SetFrom(s + namePos, j - namePos);
|
||||
curItem = AddDir(curItem, -1, name);
|
||||
@@ -569,7 +569,7 @@ HRESULT CProxyArc2::Load(const CArc &arc, IProgress *progress)
|
||||
{
|
||||
// Dirs[1] - for alt streams of root dir
|
||||
CProxyDir2 &dir = Dirs.AddNew();
|
||||
dir.PathPrefix = L':';
|
||||
dir.PathPrefix = ':';
|
||||
}
|
||||
|
||||
Files.Alloc(numItems);
|
||||
|
||||
@@ -30,9 +30,11 @@ void CAgentFolder::GetPathParts(UStringVector &pathParts, bool &isAltStreamFolde
|
||||
static bool DeleteEmptyFolderAndEmptySubFolders(const FString &path)
|
||||
{
|
||||
NFind::CFileInfo fileInfo;
|
||||
FString pathPrefix = path + FCHAR_PATH_SEPARATOR;
|
||||
FString pathPrefix = path;
|
||||
pathPrefix.Add_PathSepar();
|
||||
{
|
||||
NFind::CEnumerator enumerator(pathPrefix + FCHAR_ANY_MASK);
|
||||
NFind::CEnumerator enumerator;
|
||||
enumerator.SetDirPrefix(pathPrefix);
|
||||
while (enumerator.Next(fileInfo))
|
||||
{
|
||||
if (fileInfo.IsDir())
|
||||
@@ -112,6 +114,9 @@ HRESULT CAgentFolder::CommonUpdateOperation(
|
||||
case AGENT_OP_Rename:
|
||||
result = _agentSpec->RenameItem(tailStream, indices, numItems, newItemName, updateCallback100);
|
||||
break;
|
||||
case AGENT_OP_Comment:
|
||||
result = _agentSpec->CommentItem(tailStream, indices, numItems, newItemName, updateCallback100);
|
||||
break;
|
||||
case AGENT_OP_CopyFromFile:
|
||||
result = _agentSpec->UpdateOneFile(tailStream, indices, numItems, newItemName, updateCallback100);
|
||||
break;
|
||||
@@ -274,7 +279,7 @@ HRESULT CAgentFolder::CommonUpdateOperation(
|
||||
{
|
||||
if (updateCallback100)
|
||||
{
|
||||
UString s2 = L"Error: ";
|
||||
UString s2 ("Error: ");
|
||||
s2 += s;
|
||||
RINOK(updateCallback100->UpdateErrorMessage(s2));
|
||||
return E_FAIL;
|
||||
@@ -304,13 +309,9 @@ STDMETHODIMP CAgentFolder::CopyFrom(Int32 moveMode,
|
||||
STDMETHODIMP CAgentFolder::CopyFromFile(UInt32 destIndex, const wchar_t *itemPath, IProgress *progress)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
CUIntVector indices;
|
||||
indices.Add(destIndex);
|
||||
{
|
||||
return CommonUpdateOperation(AGENT_OP_CopyFromFile, false, itemPath,
|
||||
&NUpdateArchive::k_ActionSet_Add,
|
||||
&indices.Front(), indices.Size(), progress);
|
||||
}
|
||||
return CommonUpdateOperation(AGENT_OP_CopyFromFile, false, itemPath,
|
||||
&NUpdateArchive::k_ActionSet_Add,
|
||||
&destIndex, 1, progress);
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
@@ -347,10 +348,8 @@ STDMETHODIMP CAgentFolder::CreateFolder(const wchar_t *name, IProgress *progress
|
||||
STDMETHODIMP CAgentFolder::Rename(UInt32 index, const wchar_t *newName, IProgress *progress)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
CUIntVector indices;
|
||||
indices.Add(index);
|
||||
return CommonUpdateOperation(AGENT_OP_Rename, false, newName, NULL,
|
||||
&indices.Front(), indices.Size(), progress);
|
||||
&index, 1, progress);
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
@@ -359,8 +358,16 @@ STDMETHODIMP CAgentFolder::CreateFile(const wchar_t * /* name */, IProgress * /*
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP CAgentFolder::SetProperty(UInt32 /* index */, PROPID /* propID */,
|
||||
const PROPVARIANT * /* value */, IProgress * /* progress */)
|
||||
STDMETHODIMP CAgentFolder::SetProperty(UInt32 index, PROPID propID,
|
||||
const PROPVARIANT *value, IProgress *progress)
|
||||
{
|
||||
return E_NOTIMPL;
|
||||
COM_TRY_BEGIN
|
||||
if (propID != kpidComment || value->vt != VT_BSTR)
|
||||
return E_NOTIMPL;
|
||||
if (!_agentSpec || !_agentSpec->GetTypeOfArc(_agentSpec->GetArc()).IsEqualTo_Ascii_NoCase("zip"))
|
||||
return E_NOTIMPL;
|
||||
|
||||
return CommonUpdateOperation(AGENT_OP_Comment, false, value->bstrVal, NULL,
|
||||
&index, 1, progress);
|
||||
COM_TRY_END
|
||||
}
|
||||
|
||||
@@ -22,10 +22,10 @@ void CUpdateCallbackAgent::SetCallback(IFolderArchiveUpdateCallback *callback)
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT CUpdateCallbackAgent::SetNumItems(UInt64 numItems)
|
||||
HRESULT CUpdateCallbackAgent::SetNumItems(const CArcToDoStat &stat)
|
||||
{
|
||||
if (Callback)
|
||||
return Callback->SetNumFiles(numItems);
|
||||
return Callback->SetNumFiles(stat.Get_NumDataItems_Total());
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -82,9 +82,9 @@ HRESULT CUpdateCallbackAgent::OpenFileError(const FString &path, DWORD systemErr
|
||||
|
||||
if (Callback)
|
||||
{
|
||||
UString s = L"WARNING: ";
|
||||
UString s ("WARNING: ");
|
||||
s += NError::MyFormatMessage(systemError);
|
||||
s += L": ";
|
||||
s += ": ";
|
||||
s += fs2us(path);
|
||||
RINOK(Callback->UpdateErrorMessage(s));
|
||||
return S_FALSE;
|
||||
@@ -106,9 +106,9 @@ HRESULT CUpdateCallbackAgent::ReadingFileError(const FString &path, DWORD system
|
||||
}
|
||||
else if (Callback)
|
||||
{
|
||||
UString s = L"ERROR: ";
|
||||
UString s ("ERROR: ");
|
||||
s += NError::MyFormatMessage(systemError);
|
||||
s += L": ";
|
||||
s += ": ";
|
||||
s += fs2us(path);
|
||||
RINOK(Callback->UpdateErrorMessage(s));
|
||||
}
|
||||
|
||||
@@ -49,21 +49,35 @@ using namespace NDir;
|
||||
|
||||
#define kDllName "7z.dll"
|
||||
|
||||
static const char *kCopyrightString = "\n7-Zip " MY_VERSION
|
||||
" (" kDllName " client) "
|
||||
MY_COPYRIGHT " " MY_DATE "\n";
|
||||
static const char * const kCopyrightString =
|
||||
"\n"
|
||||
"7-Zip"
|
||||
" (" kDllName " client)"
|
||||
" " MY_VERSION
|
||||
" : " MY_COPYRIGHT_DATE
|
||||
"\n";
|
||||
|
||||
static const char *kHelpString =
|
||||
"Usage: Client7z.exe [a | l | x ] archive.7z [fileName ...]\n"
|
||||
static const char * const kHelpString =
|
||||
"Usage: 7zcl.exe [a | l | x] archive.7z [fileName ...]\n"
|
||||
"Examples:\n"
|
||||
" Client7z.exe a archive.7z f1.txt f2.txt : compress two files to archive.7z\n"
|
||||
" Client7z.exe l archive.7z : List contents of archive.7z\n"
|
||||
" Client7z.exe x archive.7z : eXtract files from archive.7z\n";
|
||||
" 7zcl.exe a archive.7z f1.txt f2.txt : compress two files to archive.7z\n"
|
||||
" 7zcl.exe l archive.7z : List contents of archive.7z\n"
|
||||
" 7zcl.exe x archive.7z : eXtract files from archive.7z\n";
|
||||
|
||||
|
||||
static AString FStringToConsoleString(const FString &s)
|
||||
static void Convert_UString_to_AString(const UString &s, AString &temp)
|
||||
{
|
||||
return GetOemString(fs2us(s));
|
||||
int codePage = CP_OEMCP;
|
||||
/*
|
||||
int g_CodePage = -1;
|
||||
int codePage = g_CodePage;
|
||||
if (codePage == -1)
|
||||
codePage = CP_OEMCP;
|
||||
if (codePage == CP_UTF8)
|
||||
ConvertUnicodeToUTF8(s, temp);
|
||||
else
|
||||
*/
|
||||
UnicodeStringToMultiByte2(temp, s, (UINT)codePage);
|
||||
}
|
||||
|
||||
static FString CmdStringToFString(const char *s)
|
||||
@@ -71,41 +85,53 @@ static FString CmdStringToFString(const char *s)
|
||||
return us2fs(GetUnicodeString(s));
|
||||
}
|
||||
|
||||
static void PrintString(const UString &s)
|
||||
static void Print(const char *s)
|
||||
{
|
||||
printf("%s", (LPCSTR)GetOemString(s));
|
||||
fputs(s, stdout);
|
||||
}
|
||||
|
||||
static void PrintString(const AString &s)
|
||||
static void Print(const AString &s)
|
||||
{
|
||||
printf("%s", (LPCSTR)s);
|
||||
Print(s.Ptr());
|
||||
}
|
||||
|
||||
static void Print(const UString &s)
|
||||
{
|
||||
AString as;
|
||||
Convert_UString_to_AString(s, as);
|
||||
Print(as);
|
||||
}
|
||||
|
||||
static void Print(const wchar_t *s)
|
||||
{
|
||||
Print(UString(s));
|
||||
}
|
||||
|
||||
static void PrintNewLine()
|
||||
{
|
||||
PrintString("\n");
|
||||
Print("\n");
|
||||
}
|
||||
|
||||
static void PrintStringLn(const AString &s)
|
||||
static void PrintStringLn(const char *s)
|
||||
{
|
||||
PrintString(s);
|
||||
Print(s);
|
||||
PrintNewLine();
|
||||
}
|
||||
|
||||
static void PrintError(const char *message)
|
||||
{
|
||||
Print("Error: ");
|
||||
PrintNewLine();
|
||||
Print(message);
|
||||
PrintNewLine();
|
||||
}
|
||||
|
||||
static void PrintError(const char *message, const FString &name)
|
||||
{
|
||||
printf("Error: %s", (LPCSTR)message);
|
||||
PrintNewLine();
|
||||
PrintString(FStringToConsoleString(name));
|
||||
PrintNewLine();
|
||||
PrintError(message);
|
||||
Print(name);
|
||||
}
|
||||
|
||||
static void PrintError(const AString &s)
|
||||
{
|
||||
PrintNewLine();
|
||||
PrintString(s);
|
||||
PrintNewLine();
|
||||
}
|
||||
|
||||
static HRESULT IsArchiveItemProp(IInArchive *archive, UInt32 index, PROPID propID, bool &result)
|
||||
{
|
||||
@@ -126,7 +152,7 @@ static HRESULT IsArchiveItemFolder(IInArchive *archive, UInt32 index, bool &resu
|
||||
}
|
||||
|
||||
|
||||
static const wchar_t *kEmptyFileAlias = L"[Content]";
|
||||
static const wchar_t * const kEmptyFileAlias = L"[Content]";
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
@@ -176,21 +202,25 @@ STDMETHODIMP CArchiveOpenCallback::CryptoGetTextPassword(BSTR *password)
|
||||
}
|
||||
|
||||
|
||||
|
||||
static const char * const kIncorrectCommand = "incorrect command";
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// Archive Extracting callback class
|
||||
|
||||
static const char *kTestingString = "Testing ";
|
||||
static const char *kExtractingString = "Extracting ";
|
||||
static const char *kSkippingString = "Skipping ";
|
||||
static const char * const kTestingString = "Testing ";
|
||||
static const char * const kExtractingString = "Extracting ";
|
||||
static const char * const kSkippingString = "Skipping ";
|
||||
|
||||
static const char * const kUnsupportedMethod = "Unsupported Method";
|
||||
static const char * const kCRCFailed = "CRC Failed";
|
||||
static const char * const kDataError = "Data Error";
|
||||
static const char * const kUnavailableData = "Unavailable data";
|
||||
static const char * const kUnexpectedEnd = "Unexpected end of data";
|
||||
static const char * const kDataAfterEnd = "There are some data after the end of the payload data";
|
||||
static const char * const kIsNotArc = "Is not archive";
|
||||
static const char * const kHeadersError = "Headers Error";
|
||||
|
||||
static const char *kUnsupportedMethod = "Unsupported Method";
|
||||
static const char *kCRCFailed = "CRC Failed";
|
||||
static const char *kDataError = "Data Error";
|
||||
static const char *kUnavailableData = "Unavailable data";
|
||||
static const char *kUnexpectedEnd = "Unexpected end of data";
|
||||
static const char *kDataAfterEnd = "There are some data after the end of the payload data";
|
||||
static const char *kIsNotArc = "Is not archive";
|
||||
static const char *kHeadersError = "Headers Error";
|
||||
|
||||
class CArchiveExtractCallback:
|
||||
public IArchiveExtractCallback,
|
||||
@@ -380,11 +410,11 @@ STDMETHODIMP CArchiveExtractCallback::PrepareOperation(Int32 askExtractMode)
|
||||
};
|
||||
switch (askExtractMode)
|
||||
{
|
||||
case NArchive::NExtract::NAskMode::kExtract: PrintString(kExtractingString); break;
|
||||
case NArchive::NExtract::NAskMode::kTest: PrintString(kTestingString); break;
|
||||
case NArchive::NExtract::NAskMode::kSkip: PrintString(kSkippingString); break;
|
||||
case NArchive::NExtract::NAskMode::kExtract: Print(kExtractingString); break;
|
||||
case NArchive::NExtract::NAskMode::kTest: Print(kTestingString); break;
|
||||
case NArchive::NExtract::NAskMode::kSkip: Print(kSkippingString); break;
|
||||
};
|
||||
PrintString(_filePath);
|
||||
Print(_filePath);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -397,7 +427,7 @@ STDMETHODIMP CArchiveExtractCallback::SetOperationResult(Int32 operationResult)
|
||||
default:
|
||||
{
|
||||
NumErrors++;
|
||||
PrintString(" : ");
|
||||
Print(" : ");
|
||||
const char *s = NULL;
|
||||
switch (operationResult)
|
||||
{
|
||||
@@ -428,15 +458,15 @@ STDMETHODIMP CArchiveExtractCallback::SetOperationResult(Int32 operationResult)
|
||||
}
|
||||
if (s)
|
||||
{
|
||||
PrintString("Error : ");
|
||||
PrintString(s);
|
||||
Print("Error : ");
|
||||
Print(s);
|
||||
}
|
||||
else
|
||||
{
|
||||
char temp[16];
|
||||
ConvertUInt32ToString(operationResult, temp);
|
||||
PrintString("Error #");
|
||||
PrintString(temp);
|
||||
Print("Error #");
|
||||
Print(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -602,10 +632,10 @@ HRESULT CArchiveUpdateCallback::Finilize()
|
||||
|
||||
static void GetStream2(const wchar_t *name)
|
||||
{
|
||||
PrintString("Compressing ");
|
||||
Print("Compressing ");
|
||||
if (name[0] == 0)
|
||||
name = kEmptyFileAlias;
|
||||
PrintString(name);
|
||||
Print(name);
|
||||
}
|
||||
|
||||
STDMETHODIMP CArchiveUpdateCallback::GetStream(UInt32 index, ISequentialInStream **inStream)
|
||||
@@ -631,7 +661,7 @@ STDMETHODIMP CArchiveUpdateCallback::GetStream(UInt32 index, ISequentialInStream
|
||||
{
|
||||
PrintNewLine();
|
||||
PrintError("WARNING: can't open file");
|
||||
// PrintString(NError::MyFormatMessageW(systemError));
|
||||
// Print(NError::MyFormatMessageW(systemError));
|
||||
return S_FALSE;
|
||||
}
|
||||
// return sysError;
|
||||
@@ -665,7 +695,7 @@ STDMETHODIMP CArchiveUpdateCallback::GetVolumeStream(UInt32 index, ISequentialOu
|
||||
while (res.Len() < 2)
|
||||
res.InsertAtFront(L'0');
|
||||
UString fileName = VolName;
|
||||
fileName += L'.';
|
||||
fileName += '.';
|
||||
fileName += res;
|
||||
fileName += VolExt;
|
||||
COutFileStream *streamSpec = new COutFileStream;
|
||||
@@ -704,11 +734,18 @@ int MY_CDECL main(int numArgs, const char *args[])
|
||||
|
||||
PrintStringLn(kCopyrightString);
|
||||
|
||||
if (numArgs < 3)
|
||||
if (numArgs < 2)
|
||||
{
|
||||
PrintStringLn(kHelpString);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (numArgs < 3)
|
||||
{
|
||||
PrintError(kIncorrectCommand);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
NDLL::CLibrary lib;
|
||||
if (!lib.Load(NDLL::GetModuleDirPrefix() + FTEXT(kDllName)))
|
||||
@@ -726,10 +763,10 @@ int MY_CDECL main(int numArgs, const char *args[])
|
||||
|
||||
char c;
|
||||
{
|
||||
AString command = args[1];
|
||||
AString command (args[1]);
|
||||
if (command.Len() != 1)
|
||||
{
|
||||
PrintError("incorrect command");
|
||||
PrintError(kIncorrectCommand);
|
||||
return 1;
|
||||
}
|
||||
c = (char)MyCharLower_Ascii(command[0]);
|
||||
@@ -742,7 +779,7 @@ int MY_CDECL main(int numArgs, const char *args[])
|
||||
// create archive command
|
||||
if (numArgs < 4)
|
||||
{
|
||||
PrintStringLn(kHelpString);
|
||||
PrintError(kIncorrectCommand);
|
||||
return 1;
|
||||
}
|
||||
CObjectVector<CDirItem> dirItems;
|
||||
@@ -839,7 +876,7 @@ int MY_CDECL main(int numArgs, const char *args[])
|
||||
{
|
||||
if (numArgs != 3)
|
||||
{
|
||||
PrintStringLn(kHelpString);
|
||||
PrintError(kIncorrectCommand);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -851,7 +888,7 @@ int MY_CDECL main(int numArgs, const char *args[])
|
||||
listCommand = false;
|
||||
else
|
||||
{
|
||||
PrintError("incorrect command");
|
||||
PrintError(kIncorrectCommand);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -899,17 +936,17 @@ int MY_CDECL main(int numArgs, const char *args[])
|
||||
archive->GetProperty(i, kpidSize, &prop);
|
||||
char s[32];
|
||||
ConvertPropVariantToShortString(prop, s);
|
||||
PrintString(s);
|
||||
PrintString(" ");
|
||||
Print(s);
|
||||
Print(" ");
|
||||
}
|
||||
{
|
||||
// Get name of file
|
||||
NCOM::CPropVariant prop;
|
||||
archive->GetProperty(i, kpidPath, &prop);
|
||||
if (prop.vt == VT_BSTR)
|
||||
PrintString(prop.bstrVal);
|
||||
Print(prop.bstrVal);
|
||||
else if (prop.vt != VT_EMPTY)
|
||||
PrintString("ERROR!");
|
||||
Print("ERROR!");
|
||||
}
|
||||
PrintNewLine();
|
||||
}
|
||||
@@ -919,10 +956,10 @@ int MY_CDECL main(int numArgs, const char *args[])
|
||||
// Extract command
|
||||
CArchiveExtractCallback *extractCallbackSpec = new CArchiveExtractCallback;
|
||||
CMyComPtr<IArchiveExtractCallback> extractCallback(extractCallbackSpec);
|
||||
extractCallbackSpec->Init(archive, FTEXT("")); // second parameter is output folder path
|
||||
extractCallbackSpec->Init(archive, FString()); // second parameter is output folder path
|
||||
extractCallbackSpec->PasswordIsDefined = false;
|
||||
// extractCallbackSpec->PasswordIsDefined = true;
|
||||
// extractCallbackSpec->Password = L"1";
|
||||
// extractCallbackSpec->Password = "1";
|
||||
|
||||
/*
|
||||
const wchar_t *names[] =
|
||||
|
||||
@@ -66,7 +66,7 @@ LINK32=link.exe
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c
|
||||
# ADD CPP /nologo /W4 /WX /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c
|
||||
# ADD CPP /nologo /MDd /W4 /WX /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x419 /d "_DEBUG"
|
||||
# ADD RSC /l 0x419 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
#include "../../MyVersionInfo.rc"
|
||||
|
||||
MY_VERSION_INFO_APP("7-Zip client", "7zcl")
|
||||
MY_VERSION_INFO_APP("7-Zip client" , "7zcl")
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "UpdateAction.h"
|
||||
|
||||
extern bool g_CaseSensitive;
|
||||
extern bool g_PathTrailReplaceMode;
|
||||
|
||||
#ifdef UNDER_CE
|
||||
|
||||
@@ -61,10 +62,10 @@ static bool StringToUInt32(const wchar_t *s, UInt32 &v)
|
||||
|
||||
CArcCmdLineException::CArcCmdLineException(const char *a, const wchar_t *u)
|
||||
{
|
||||
(*this) += MultiByteToUnicodeString(a);
|
||||
(*this) += a;
|
||||
if (u)
|
||||
{
|
||||
this->Add_LF();
|
||||
Add_LF();
|
||||
(*this) += u;
|
||||
}
|
||||
}
|
||||
@@ -133,10 +134,13 @@ enum Enum
|
||||
kHardLinks,
|
||||
kSymLinks,
|
||||
kNtSecurity,
|
||||
|
||||
kAltStreams,
|
||||
kReplaceColonForAltStream,
|
||||
kWriteToAltStreamIfColon,
|
||||
|
||||
kNameTrailReplace,
|
||||
|
||||
kDeleteAfterCompressing,
|
||||
kSetArcMTime
|
||||
|
||||
@@ -149,11 +153,11 @@ enum Enum
|
||||
|
||||
|
||||
static const wchar_t kRecursedIDChar = 'r';
|
||||
static const char *kRecursedPostCharSet = "0-";
|
||||
static const char * const kRecursedPostCharSet = "0-";
|
||||
|
||||
static const char *k_ArcNameMode_PostCharSet = "sea";
|
||||
static const char * const k_ArcNameMode_PostCharSet = "sea";
|
||||
|
||||
static const char *k_Stream_PostCharSet = "012";
|
||||
static const char * const k_Stream_PostCharSet = "012";
|
||||
|
||||
static inline const EArcNameMode ParseArcNameMode(int postCharIndex)
|
||||
{
|
||||
@@ -180,7 +184,7 @@ static const char kFileListID = '@';
|
||||
static const char kSomeCludePostStringMinSize = 2; // at least <@|!><N>ame must be
|
||||
static const char kSomeCludeAfterRecursedPostStringMinSize = 2; // at least <@|!><N>ame must be
|
||||
|
||||
static const char *kOverwritePostCharSet = "asut";
|
||||
static const char * const kOverwritePostCharSet = "asut";
|
||||
|
||||
static const NExtract::NOverwriteMode::EEnum k_OverwriteModes[] =
|
||||
{
|
||||
@@ -251,10 +255,13 @@ static const CSwitchForm kSwitchForms[] =
|
||||
{ "snh", NSwitchType::kMinus },
|
||||
{ "snl", NSwitchType::kMinus },
|
||||
{ "sni" },
|
||||
|
||||
{ "sns", NSwitchType::kMinus },
|
||||
{ "snr" },
|
||||
{ "snc" },
|
||||
|
||||
{ "snt", NSwitchType::kMinus },
|
||||
|
||||
{ "sdel" },
|
||||
{ "stl" }
|
||||
|
||||
@@ -263,17 +270,17 @@ static const CSwitchForm kSwitchForms[] =
|
||||
#endif
|
||||
};
|
||||
|
||||
static const wchar_t *kUniversalWildcard = L"*";
|
||||
static const char * const kUniversalWildcard = "*";
|
||||
static const unsigned kMinNonSwitchWords = 1;
|
||||
static const unsigned kCommandIndex = 0;
|
||||
|
||||
// static const char *kUserErrorMessage = "Incorrect command line";
|
||||
static const char *kCannotFindListFile = "Cannot find listfile";
|
||||
static const char *kIncorrectListFile = "Incorrect item in listfile.\nCheck charset encoding and -scs switch.";
|
||||
static const char *kTerminalOutError = "I won't write compressed data to a terminal";
|
||||
static const char *kSameTerminalError = "I won't write data and program's messages to same stream";
|
||||
static const char *kEmptyFilePath = "Empty file path";
|
||||
static const char *kCannotFindArchive = "Cannot find archive";
|
||||
// static const char * const kUserErrorMessage = "Incorrect command line";
|
||||
static const char * const kCannotFindListFile = "Cannot find listfile";
|
||||
static const char * const kIncorrectListFile = "Incorrect item in listfile.\nCheck charset encoding and -scs switch.";
|
||||
static const char * const kTerminalOutError = "I won't write compressed data to a terminal";
|
||||
static const char * const kSameTerminalError = "I won't write data and program's messages to same stream";
|
||||
static const char * const kEmptyFilePath = "Empty file path";
|
||||
static const char * const kCannotFindArchive = "Cannot find archive";
|
||||
|
||||
bool CArcCommand::IsFromExtractGroup() const
|
||||
{
|
||||
@@ -328,7 +335,7 @@ static const char *g_Commands = "audtexlbih";
|
||||
|
||||
static bool ParseArchiveCommand(const UString &commandString, CArcCommand &command)
|
||||
{
|
||||
UString s = commandString;
|
||||
UString s (commandString);
|
||||
s.MakeLower_Ascii();
|
||||
if (s.Len() == 1)
|
||||
{
|
||||
@@ -386,9 +393,9 @@ static void AddRenamePair(CObjectVector<CRenamePair> *renamePairs,
|
||||
val += pair.NewName;
|
||||
val.Add_LF();
|
||||
if (type == NRecursedType::kRecursed)
|
||||
val.AddAscii("-r");
|
||||
val += "-r";
|
||||
else if (type == NRecursedType::kWildcardOnlyRecursed)
|
||||
val.AddAscii("-r0");
|
||||
val += "-r0";
|
||||
throw CArcCmdLineException("Unsupported rename command:", val);
|
||||
}
|
||||
}
|
||||
@@ -422,23 +429,28 @@ static void AddToCensorFromNonSwitchesStrings(
|
||||
CObjectVector<CRenamePair> *renamePairs,
|
||||
unsigned startIndex,
|
||||
NWildcard::CCensor &censor,
|
||||
const UStringVector &nonSwitchStrings, NRecursedType::EEnum type,
|
||||
const UStringVector &nonSwitchStrings,
|
||||
int stopSwitchIndex,
|
||||
NRecursedType::EEnum type,
|
||||
bool wildcardMatching,
|
||||
bool thereAreSwitchIncludes, Int32 codePage)
|
||||
{
|
||||
if ((renamePairs || nonSwitchStrings.Size() == startIndex) && !thereAreSwitchIncludes)
|
||||
AddNameToCensor(censor, kUniversalWildcard, true, type,
|
||||
AddNameToCensor(censor, UString(kUniversalWildcard), true, type,
|
||||
true // wildcardMatching
|
||||
);
|
||||
|
||||
int oldIndex = -1;
|
||||
|
||||
if (stopSwitchIndex < 0)
|
||||
stopSwitchIndex = nonSwitchStrings.Size();
|
||||
|
||||
for (unsigned i = startIndex; i < nonSwitchStrings.Size(); i++)
|
||||
{
|
||||
const UString &s = nonSwitchStrings[i];
|
||||
if (s.IsEmpty())
|
||||
throw CArcCmdLineException(kEmptyFilePath);
|
||||
if (s[0] == kFileListID)
|
||||
if (i < (unsigned)stopSwitchIndex && s[0] == kFileListID)
|
||||
AddToCensorFromListFile(renamePairs, censor, s.Ptr(1), true, type, wildcardMatching, codePage);
|
||||
else if (renamePairs)
|
||||
{
|
||||
@@ -477,7 +489,7 @@ struct CEventSetEnd
|
||||
}
|
||||
};
|
||||
|
||||
const char *k_IncorrectMapCommand = "Incorrect Map command";
|
||||
static const char * const k_IncorrectMapCommand = "Incorrect Map command";
|
||||
|
||||
static const char *ParseMapWithPaths(
|
||||
NWildcard::CCensor &censor,
|
||||
@@ -485,7 +497,7 @@ static const char *ParseMapWithPaths(
|
||||
NRecursedType::EEnum commonRecursedType,
|
||||
bool wildcardMatching)
|
||||
{
|
||||
UString s = s2;
|
||||
UString s (s2);
|
||||
int pos = s.Find(L':');
|
||||
if (pos < 0)
|
||||
return k_IncorrectMapCommand;
|
||||
@@ -577,7 +589,7 @@ static void AddSwitchWildcardsToCensor(
|
||||
break;
|
||||
}
|
||||
|
||||
UString tail = name.Ptr(pos + 1);
|
||||
const UString tail = name.Ptr(pos + 1);
|
||||
|
||||
if (name[pos] == kImmediateNameID)
|
||||
AddNameToCensor(censor, tail, include, recursedType, wildcardMatching);
|
||||
@@ -610,7 +622,7 @@ static void ConvertToLongName(const UString &prefix, UString &name)
|
||||
if (name.IsEmpty() || DoesNameContainWildcard(name))
|
||||
return;
|
||||
NFind::CFileInfo fi;
|
||||
const FString path = us2fs(prefix + name);
|
||||
const FString path (us2fs(prefix + name));
|
||||
#ifndef UNDER_CE
|
||||
if (NFile::NName::IsDevicePath(path))
|
||||
return;
|
||||
@@ -693,11 +705,11 @@ static NUpdateArchive::NPairAction::EEnum GetUpdatePairActionType(int i)
|
||||
}
|
||||
*/
|
||||
|
||||
static const wchar_t *kUpdatePairStateIDSet = L"pqrxyzw";
|
||||
static const char * const kUpdatePairStateIDSet = "pqrxyzw";
|
||||
static const int kUpdatePairStateNotSupportedActions[] = {2, 2, 1, -1, -1, -1, -1};
|
||||
|
||||
static const unsigned kNumUpdatePairActions = 4;
|
||||
static const char *kUpdateIgnoreItselfPostStringID = "-";
|
||||
static const char * const kUpdateIgnoreItselfPostStringID = "-";
|
||||
static const wchar_t kUpdateNewArchivePostCharID = '!';
|
||||
|
||||
|
||||
@@ -707,8 +719,8 @@ static bool ParseUpdateCommandString2(const UString &command,
|
||||
for (unsigned i = 0; i < command.Len();)
|
||||
{
|
||||
wchar_t c = MyCharLower_Ascii(command[i]);
|
||||
int statePos = FindCharPosInString(kUpdatePairStateIDSet, c);
|
||||
if (statePos < 0)
|
||||
int statePos = FindCharPosInString(kUpdatePairStateIDSet, (char)c);
|
||||
if (c > 0x7F || statePos < 0)
|
||||
{
|
||||
postString = command.Ptr(i);
|
||||
return true;
|
||||
@@ -849,7 +861,6 @@ static void SetMethodOptions(const CParser &parser, CObjectVector<CProperty> &pr
|
||||
}
|
||||
}
|
||||
|
||||
CArcCmdLineParser::CArcCmdLineParser(): parser(ARRAY_SIZE(kSwitchForms)) {}
|
||||
|
||||
static inline void SetStreamMode(const CSwitchResult &sw, unsigned &res)
|
||||
{
|
||||
@@ -857,10 +868,11 @@ static inline void SetStreamMode(const CSwitchResult &sw, unsigned &res)
|
||||
res = sw.PostCharIndex;
|
||||
}
|
||||
|
||||
|
||||
void CArcCmdLineParser::Parse1(const UStringVector &commandStrings,
|
||||
CArcCmdLineOptions &options)
|
||||
{
|
||||
if (!parser.ParseStrings(kSwitchForms, commandStrings))
|
||||
if (!parser.ParseStrings(kSwitchForms, ARRAY_SIZE(kSwitchForms), commandStrings))
|
||||
throw CArcCmdLineException(parser.ErrorMessage, parser.ErrorLine);
|
||||
|
||||
options.IsInTerminal = MY_IS_TERMINAL(stdin);
|
||||
@@ -965,7 +977,7 @@ static Int32 FindCharset(const NCommandLineParser::CParser &parser, unsigned key
|
||||
if (!parser[keyIndex].ThereIs)
|
||||
return defaultVal;
|
||||
|
||||
UString name = parser[keyIndex].PostStrings.Back();
|
||||
UString name (parser[keyIndex].PostStrings.Back());
|
||||
UInt32 v;
|
||||
if (StringToUInt32(name, v))
|
||||
if (v < ((UInt32)1 << 16))
|
||||
@@ -1051,7 +1063,7 @@ static void SetBoolPair(NCommandLineParser::CParser &parser, unsigned switchID,
|
||||
void CArcCmdLineParser::Parse2(CArcCmdLineOptions &options)
|
||||
{
|
||||
const UStringVector &nonSwitchStrings = parser.NonSwitchStrings;
|
||||
unsigned numNonSwitchStrings = nonSwitchStrings.Size();
|
||||
const unsigned numNonSwitchStrings = nonSwitchStrings.Size();
|
||||
if (numNonSwitchStrings < kMinNonSwitchWords)
|
||||
throw CArcCmdLineException("The command must be specified");
|
||||
|
||||
@@ -1082,6 +1094,9 @@ void CArcCmdLineParser::Parse2(CArcCmdLineOptions &options)
|
||||
}
|
||||
}
|
||||
|
||||
if (parser[NKey::kNameTrailReplace].ThereIs)
|
||||
g_PathTrailReplaceMode = !parser[NKey::kNameTrailReplace].WithMinus;
|
||||
|
||||
NRecursedType::EEnum recursedType;
|
||||
if (parser[NKey::kRecursed].ThereIs)
|
||||
recursedType = GetRecursedTypeFromIndex(parser[NKey::kRecursed].PostCharIndex);
|
||||
@@ -1138,7 +1153,8 @@ void CArcCmdLineParser::Parse2(CArcCmdLineOptions &options)
|
||||
|
||||
AddToCensorFromNonSwitchesStrings(isRename ? &options.UpdateOptions.RenamePairs : NULL,
|
||||
curCommandIndex, options.Censor,
|
||||
nonSwitchStrings, recursedType, wildcardMatching,
|
||||
nonSwitchStrings, parser.StopSwitchIndex,
|
||||
recursedType, wildcardMatching,
|
||||
thereAreSwitchIncludes, codePage);
|
||||
|
||||
options.YesToAll = parser[NKey::kYes].ThereIs;
|
||||
|
||||
@@ -130,7 +130,6 @@ class CArcCmdLineParser
|
||||
{
|
||||
NCommandLineParser::CParser parser;
|
||||
public:
|
||||
CArcCmdLineParser();
|
||||
void Parse1(const UStringVector &commandStrings, CArcCmdLineOptions &options);
|
||||
void Parse2(CArcCmdLineOptions &options);
|
||||
};
|
||||
|
||||
@@ -5,7 +5,12 @@
|
||||
#undef sprintf
|
||||
#undef printf
|
||||
|
||||
// #include <stdio.h>
|
||||
// #include "../../../../C/CpuTicks.h"
|
||||
|
||||
#include "../../../../C/Alloc.h"
|
||||
#include "../../../../C/CpuArch.h"
|
||||
|
||||
|
||||
#include "../../../Common/ComTry.h"
|
||||
#include "../../../Common/IntToString.h"
|
||||
@@ -36,10 +41,14 @@ using namespace NWindows;
|
||||
using namespace NFile;
|
||||
using namespace NDir;
|
||||
|
||||
static const char *kCantAutoRename = "Can not create file with auto name";
|
||||
static const char *kCantRenameFile = "Can not rename existing file";
|
||||
static const char *kCantDeleteOutputFile = "Can not delete output file";
|
||||
static const char *kCantDeleteOutputDir = "Can not delete output folder";
|
||||
static const char * const kCantAutoRename = "Can not create file with auto name";
|
||||
static const char * const kCantRenameFile = "Can not rename existing file";
|
||||
static const char * const kCantDeleteOutputFile = "Can not delete output file";
|
||||
static const char * const kCantDeleteOutputDir = "Can not delete output folder";
|
||||
static const char * const kCantCreateHardLink = "Can not create hard link";
|
||||
static const char * const kCantCreateSymLink = "Can not create symbolic link";
|
||||
static const char * const kCantOpenOutFile = "Can not open output file";
|
||||
static const char * const kCantSetFileLen = "Can not set length for output file";
|
||||
|
||||
|
||||
#ifndef _SFX
|
||||
@@ -381,14 +390,13 @@ HRESULT CArchiveExtractCallback::GetUnpackSize()
|
||||
|
||||
static void AddPathToMessage(UString &s, const FString &path)
|
||||
{
|
||||
s.AddAscii(" : ");
|
||||
s += " : ";
|
||||
s += fs2us(path);
|
||||
}
|
||||
|
||||
HRESULT CArchiveExtractCallback::SendMessageError(const char *message, const FString &path)
|
||||
{
|
||||
UString s;
|
||||
s.AddAscii(message);
|
||||
UString s (message);
|
||||
AddPathToMessage(s, path);
|
||||
return _extractCallback2->MessageError(s);
|
||||
}
|
||||
@@ -396,11 +404,10 @@ HRESULT CArchiveExtractCallback::SendMessageError(const char *message, const FSt
|
||||
HRESULT CArchiveExtractCallback::SendMessageError_with_LastError(const char *message, const FString &path)
|
||||
{
|
||||
DWORD errorCode = GetLastError();
|
||||
UString s;
|
||||
s.AddAscii(message);
|
||||
UString s (message);
|
||||
if (errorCode != 0)
|
||||
{
|
||||
s.AddAscii(" : ");
|
||||
s += " : ";
|
||||
s += NError::MyFormatMessage(errorCode);
|
||||
}
|
||||
AddPathToMessage(s, path);
|
||||
@@ -409,8 +416,7 @@ HRESULT CArchiveExtractCallback::SendMessageError_with_LastError(const char *mes
|
||||
|
||||
HRESULT CArchiveExtractCallback::SendMessageError2(const char *message, const FString &path1, const FString &path2)
|
||||
{
|
||||
UString s;
|
||||
s.AddAscii(message);
|
||||
UString s (message);
|
||||
AddPathToMessage(s, path1);
|
||||
AddPathToMessage(s, path2);
|
||||
return _extractCallback2->MessageError(s);
|
||||
@@ -440,7 +446,7 @@ STDMETHODIMP CGetProp::GetProp(PROPID propID, PROPVARIANT *value)
|
||||
|
||||
static UString GetDirPrefixOf(const UString &src)
|
||||
{
|
||||
UString s = src;
|
||||
UString s (src);
|
||||
if (!s.IsEmpty())
|
||||
{
|
||||
if (IsPathSepar(s.Back()))
|
||||
@@ -514,7 +520,7 @@ bool CensorNode_CheckPath2(const NWildcard::CCensorNode &node, const CReadArcIte
|
||||
if (pathParts2.IsEmpty())
|
||||
pathParts2.AddNew();
|
||||
UString &back = pathParts2.Back();
|
||||
back += L':';
|
||||
back += ':';
|
||||
back += item.AltStreamName;
|
||||
bool include2;
|
||||
|
||||
@@ -541,7 +547,7 @@ bool CensorNode_CheckPath(const NWildcard::CCensorNode &node, const CReadArcItem
|
||||
|
||||
static FString MakePath_from_2_Parts(const FString &prefix, const FString &path)
|
||||
{
|
||||
FString s = prefix;
|
||||
FString s (prefix);
|
||||
#if defined(_WIN32) && !defined(UNDER_CE)
|
||||
if (!path.IsEmpty() && path[0] == ':' && !prefix.IsEmpty() && IsPathSepar(prefix.Back()))
|
||||
{
|
||||
@@ -596,6 +602,7 @@ HRESULT CArchiveExtractCallback::MyCopyFile(ISequentialOutStream *outStream)
|
||||
#endif
|
||||
*/
|
||||
|
||||
|
||||
STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStream **outStream, Int32 askExtractMode)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
@@ -616,6 +623,7 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStre
|
||||
|
||||
_curSize = 0;
|
||||
_curSizeDefined = false;
|
||||
_fileLengthWasSet = false;
|
||||
_index = index;
|
||||
|
||||
_diskFilePath.Empty();
|
||||
@@ -928,13 +936,13 @@ STDMETHODIMP CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStre
|
||||
}
|
||||
GetProp_Spec->Arc = _arc;
|
||||
GetProp_Spec->IndexInArc = index;
|
||||
UString name = MakePathFromParts(pathParts);
|
||||
UString name (MakePathFromParts(pathParts));
|
||||
|
||||
#ifdef SUPPORT_ALT_STREAMS
|
||||
if (_item.IsAltStream)
|
||||
{
|
||||
if (!pathParts.IsEmpty() || (!_removePartsForAltStreams && _pathMode != NExtract::NPathMode::kNoPathsAlt))
|
||||
name += L':';
|
||||
name += ':';
|
||||
name += _item.AltStreamName;
|
||||
}
|
||||
#endif
|
||||
@@ -986,7 +994,7 @@ if (askExtractMode == NArchive::NExtract::NAskMode::kExtract && !_testMode)
|
||||
|
||||
if (_item.IsAltStream)
|
||||
{
|
||||
UString s = _item.AltStreamName;
|
||||
UString s (_item.AltStreamName);
|
||||
Correct_AltStream_Name(s);
|
||||
bool needColon = true;
|
||||
|
||||
@@ -1002,13 +1010,13 @@ if (askExtractMode == NArchive::NExtract::NAskMode::kExtract && !_testMode)
|
||||
|
||||
UString &name = pathParts.Back();
|
||||
if (needColon)
|
||||
name += (wchar_t)(_ntOptions.ReplaceColonForAltStream ? L'_' : L':');
|
||||
name += (char)(_ntOptions.ReplaceColonForAltStream ? '_' : ':');
|
||||
name += s;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
UString processedPath = MakePathFromParts(pathParts);
|
||||
UString processedPath (MakePathFromParts(pathParts));
|
||||
|
||||
if (!isAnti)
|
||||
{
|
||||
@@ -1035,7 +1043,7 @@ if (askExtractMode == NArchive::NExtract::NAskMode::kExtract && !_testMode)
|
||||
}
|
||||
|
||||
|
||||
FString fullProcessedPath = us2fs(processedPath);
|
||||
FString fullProcessedPath (us2fs(processedPath));
|
||||
if (_pathMode != NExtract::NPathMode::kAbsPaths
|
||||
|| !NName::IsAbsolutePath(processedPath))
|
||||
{
|
||||
@@ -1051,8 +1059,8 @@ if (askExtractMode == NArchive::NExtract::NAskMode::kExtract && !_testMode)
|
||||
{
|
||||
const CIndexToPathPair &pair = _renamedFiles[renIndex];
|
||||
fullProcessedPath = pair.Path;
|
||||
fullProcessedPath += (FChar)':';
|
||||
UString s = _item.AltStreamName;
|
||||
fullProcessedPath += ':';
|
||||
UString s (_item.AltStreamName);
|
||||
Correct_AltStream_Name(s);
|
||||
fullProcessedPath += us2fs(s);
|
||||
}
|
||||
@@ -1086,7 +1094,7 @@ if (askExtractMode == NArchive::NExtract::NAskMode::kExtract && !_testMode)
|
||||
case NExtract::NOverwriteMode::kAsk:
|
||||
{
|
||||
int slashPos = fullProcessedPath.ReverseFind_PathSepar();
|
||||
FString realFullProcessedPath = fullProcessedPath.Left(slashPos + 1) + fileInfo.Name;
|
||||
FString realFullProcessedPath (fullProcessedPath.Left(slashPos + 1) + fileInfo.Name);
|
||||
|
||||
Int32 overwriteResult;
|
||||
RINOK(_extractCallback2->AskOverwrite(
|
||||
@@ -1119,7 +1127,7 @@ if (askExtractMode == NArchive::NExtract::NAskMode::kExtract && !_testMode)
|
||||
}
|
||||
else if (_overwriteMode == NExtract::NOverwriteMode::kRenameExisting)
|
||||
{
|
||||
FString existPath = fullProcessedPath;
|
||||
FString existPath (fullProcessedPath);
|
||||
if (!AutoRenamePath(existPath))
|
||||
{
|
||||
RINOK(SendMessageError(kCantAutoRename, fullProcessedPath));
|
||||
@@ -1165,7 +1173,7 @@ if (askExtractMode == NArchive::NExtract::NAskMode::kExtract && !_testMode)
|
||||
int colonPos = NName::FindAltStreamColon(fullProcessedPath);
|
||||
if (colonPos >= 0 && fullProcessedPath[(unsigned)colonPos + 1] != 0)
|
||||
{
|
||||
FString parentFsPath = fullProcessedPath;
|
||||
FString parentFsPath (fullProcessedPath);
|
||||
parentFsPath.DeleteFrom(colonPos);
|
||||
NFind::CFileInfo parentFi;
|
||||
if (parentFi.Find(parentFsPath))
|
||||
@@ -1222,7 +1230,7 @@ if (askExtractMode == NArchive::NExtract::NAskMode::kExtract && !_testMode)
|
||||
{
|
||||
if (!MyCreateHardLink(fullProcessedPath, existPath))
|
||||
{
|
||||
RINOK(SendMessageError2("Can not create hard link", fullProcessedPath, existPath));
|
||||
RINOK(SendMessageError2(kCantCreateHardLink, fullProcessedPath, existPath));
|
||||
// return S_OK;
|
||||
}
|
||||
}
|
||||
@@ -1270,7 +1278,7 @@ if (askExtractMode == NArchive::NExtract::NAskMode::kExtract && !_testMode)
|
||||
else
|
||||
if (!NFile::NIO::SetReparseData(fullProcessedPath, _item.IsDir, data, (DWORD)data.Size()))
|
||||
{
|
||||
RINOK(SendMessageError_with_LastError("Can not create symbolic link", fullProcessedPath));
|
||||
RINOK(SendMessageError_with_LastError(kCantCreateSymLink, fullProcessedPath));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1304,7 +1312,7 @@ if (askExtractMode == NArchive::NExtract::NAskMode::kExtract && !_testMode)
|
||||
{
|
||||
if (!MyCreateHardLink(fullProcessedPath, hl))
|
||||
{
|
||||
RINOK(SendMessageError2("Can not create hard link", fullProcessedPath, hl));
|
||||
RINOK(SendMessageError2(kCantCreateHardLink, fullProcessedPath, hl));
|
||||
return S_OK;
|
||||
}
|
||||
needWriteFile = false;
|
||||
@@ -1323,11 +1331,24 @@ if (askExtractMode == NArchive::NExtract::NAskMode::kExtract && !_testMode)
|
||||
{
|
||||
// if (::GetLastError() != ERROR_FILE_EXISTS || !isSplit)
|
||||
{
|
||||
RINOK(SendMessageError_with_LastError("Can not open output file", fullProcessedPath));
|
||||
RINOK(SendMessageError_with_LastError(kCantOpenOutFile, fullProcessedPath));
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
|
||||
if (_ntOptions.PreAllocateOutFile && !_isSplit && _curSizeDefined && _curSize > (1 << 12))
|
||||
{
|
||||
// UInt64 ticks = GetCpuTicks();
|
||||
bool res = _outFileStreamSpec->File.SetLength(_curSize);
|
||||
_fileLengthWasSet = res;
|
||||
_outFileStreamSpec->File.SeekToBegin();
|
||||
// ticks = GetCpuTicks() - ticks;
|
||||
// printf("\nticks = %10d\n", (unsigned)ticks);
|
||||
if (!res)
|
||||
{
|
||||
RINOK(SendMessageError_with_LastError(kCantSetFileLen, fullProcessedPath));
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_ALT_STREAMS
|
||||
if (isRenamed && !_item.IsAltStream)
|
||||
@@ -1456,14 +1477,24 @@ STDMETHODIMP CArchiveExtractCallback::SetOperationResult(Int32 opRes)
|
||||
|
||||
if (_outFileStream)
|
||||
{
|
||||
HRESULT hres = S_OK;
|
||||
_outFileStreamSpec->SetTime(
|
||||
(WriteCTime && _fi.CTimeDefined) ? &_fi.CTime : NULL,
|
||||
(WriteATime && _fi.ATimeDefined) ? &_fi.ATime : NULL,
|
||||
(WriteMTime && _fi.MTimeDefined) ? &_fi.MTime : (_arc->MTimeDefined ? &_arc->MTime : NULL));
|
||||
_curSize = _outFileStreamSpec->ProcessedSize;
|
||||
const UInt64 processedSize = _outFileStreamSpec->ProcessedSize;
|
||||
if (_fileLengthWasSet && _curSize > processedSize)
|
||||
{
|
||||
bool res = _outFileStreamSpec->File.SetLength(processedSize);
|
||||
_fileLengthWasSet = res;
|
||||
if (!res)
|
||||
hres = SendMessageError_with_LastError(kCantSetFileLen, us2fs(_item.Path));
|
||||
}
|
||||
_curSize = processedSize;
|
||||
_curSizeDefined = true;
|
||||
RINOK(_outFileStreamSpec->Close());
|
||||
_outFileStream.Release();
|
||||
RINOK(hres);
|
||||
}
|
||||
|
||||
#ifdef _USE_SECURITY_CODE
|
||||
@@ -1525,23 +1556,19 @@ STDMETHODIMP CArchiveExtractCallback::ReportExtractResult(UInt32 indexType, UInt
|
||||
if (_folderArchiveExtractCallback2)
|
||||
{
|
||||
bool isEncrypted = false;
|
||||
wchar_t temp[16];
|
||||
UString s2;
|
||||
const wchar_t *s = NULL;
|
||||
UString s;
|
||||
|
||||
if (indexType == NArchive::NEventIndexType::kInArcIndex && index != (UInt32)(Int32)-1)
|
||||
{
|
||||
CReadArcItem item;
|
||||
RINOK(_arc->GetItem(index, item));
|
||||
s2 = item.Path;
|
||||
s = s2;
|
||||
s = item.Path;
|
||||
RINOK(Archive_GetItemBoolProp(_arc->Archive, index, kpidEncrypted, isEncrypted));
|
||||
}
|
||||
else
|
||||
{
|
||||
temp[0] = '#';
|
||||
ConvertUInt32ToString(index, temp + 1);
|
||||
s = temp;
|
||||
s = '#';
|
||||
s.Add_UInt32(index);
|
||||
// if (indexType == NArchive::NEventIndexType::kBlockIndex) {}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,6 +57,8 @@ struct CExtractNtOptions
|
||||
bool ReplaceColonForAltStream;
|
||||
bool WriteToAltStreamIfColon;
|
||||
|
||||
bool PreAllocateOutFile;
|
||||
|
||||
CExtractNtOptions():
|
||||
ReplaceColonForAltStream(false),
|
||||
WriteToAltStreamIfColon(false)
|
||||
@@ -64,6 +66,13 @@ struct CExtractNtOptions
|
||||
SymLinks.Val = true;
|
||||
HardLinks.Val = true;
|
||||
AltStreams.Val = true;
|
||||
|
||||
PreAllocateOutFile =
|
||||
#ifdef _WIN32
|
||||
true;
|
||||
#else
|
||||
false;
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
@@ -201,6 +210,7 @@ class CArchiveExtractCallback:
|
||||
UInt32 _index;
|
||||
UInt64 _curSize;
|
||||
bool _curSizeDefined;
|
||||
bool _fileLengthWasSet;
|
||||
COutFileStream *_outFileStreamSpec;
|
||||
CMyComPtr<ISequentialOutStream> _outFileStream;
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ UString CreateArchiveName(const NFind::CFileInfo &fi, bool keepName)
|
||||
|
||||
static FString CreateArchiveName2(const FString &path, bool fromPrev, bool keepName)
|
||||
{
|
||||
FString resultName = FTEXT("Archive");
|
||||
FString resultName ("Archive");
|
||||
if (fromPrev)
|
||||
{
|
||||
FString dirPrefix;
|
||||
|
||||
@@ -32,8 +32,6 @@
|
||||
#include "../../../../C/Alloc.h"
|
||||
#include "../../../../C/CpuArch.h"
|
||||
|
||||
#include "../../../Windows/System.h"
|
||||
|
||||
#ifndef _7ZIP_ST
|
||||
#include "../../../Windows/Synchronization.h"
|
||||
#include "../../../Windows/Thread.h"
|
||||
@@ -1200,10 +1198,9 @@ static HRESULT MethodBench(
|
||||
|
||||
if (oldLzmaBenchMode && methodId == k_LZMA)
|
||||
{
|
||||
bool fixedNumber;
|
||||
UInt32 numLzmaThreads = method.Get_Lzma_NumThreads(fixedNumber);
|
||||
if (!fixedNumber && numThreads == 1)
|
||||
if (numThreads == 1 && method.Get_NumThreads() < 0)
|
||||
method.AddProp_NumThreads(1);
|
||||
const UInt32 numLzmaThreads = method.Get_Lzma_NumThreads();
|
||||
if (numThreads > 1 && numLzmaThreads > 1)
|
||||
{
|
||||
numEncoderThreads = numThreads / 2;
|
||||
@@ -1858,6 +1855,37 @@ static void PrintTotals(IBenchPrintCallback &f, bool showFreq, UInt64 cpuFreq, c
|
||||
PrintResults(f, res.Usage / numIterations2, res.RPU / numIterations2, res.Rating / numIterations2, showFreq, cpuFreq);
|
||||
}
|
||||
|
||||
|
||||
static void PrintHex(AString &s, UInt64 v)
|
||||
{
|
||||
char temp[32];
|
||||
ConvertUInt64ToHex(v, temp);
|
||||
s += temp;
|
||||
}
|
||||
|
||||
AString GetProcessThreadsInfo(const NSystem::CProcessAffinity &ti)
|
||||
{
|
||||
AString s;
|
||||
// s.Add_UInt32(ti.numProcessThreads);
|
||||
if (ti.processAffinityMask != ti.systemAffinityMask)
|
||||
{
|
||||
// if (ti.numProcessThreads != ti.numSysThreads)
|
||||
{
|
||||
s += " / ";
|
||||
s.Add_UInt32(ti.GetNumSystemThreads());
|
||||
}
|
||||
s += " : ";
|
||||
PrintHex(s, ti.processAffinityMask);
|
||||
s += " / ";
|
||||
PrintHex(s, ti.systemAffinityMask);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
extern bool g_LargePagesMode;
|
||||
|
||||
|
||||
static void PrintRequirements(IBenchPrintCallback &f, const char *sizeString,
|
||||
bool size_Defined, UInt64 size, const char *threadsString, UInt32 numThreads)
|
||||
{
|
||||
@@ -1867,12 +1895,16 @@ static void PrintRequirements(IBenchPrintCallback &f, const char *sizeString,
|
||||
PrintNumber(f, (size >> 20), 6);
|
||||
else
|
||||
f.Print(" ?");
|
||||
f.Print(" MB, # ");
|
||||
f.Print(" MB");
|
||||
if (g_LargePagesMode)
|
||||
f.Print(" LP");
|
||||
f.Print(", # ");
|
||||
f.Print(threadsString);
|
||||
PrintNumber(f, numThreads, 3);
|
||||
f.NewLine();
|
||||
}
|
||||
|
||||
|
||||
|
||||
struct CBenchCallbackToPrint: public IBenchCallback
|
||||
{
|
||||
CBenchProps BenchProps;
|
||||
@@ -1930,7 +1962,7 @@ HRESULT CBenchCallbackToPrint::SetEncodeResult(const CBenchInfo &info, bool fina
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static const char *kSep = " | ";
|
||||
static const char * const kSep = " | ";
|
||||
|
||||
HRESULT CBenchCallbackToPrint::SetDecodeResult(const CBenchInfo &info, bool final)
|
||||
{
|
||||
@@ -2147,7 +2179,7 @@ static HRESULT CrcBench(
|
||||
numThreads = 1;
|
||||
#endif
|
||||
|
||||
AString methodName = method.MethodName;
|
||||
const AString &methodName = method.MethodName;
|
||||
// methodName.RemoveChar(L'-');
|
||||
CMethodId hashID;
|
||||
if (!FindHashMethod(
|
||||
@@ -2410,6 +2442,240 @@ static void x86cpuid_to_String(const Cx86cpuid &c, AString &s)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
static const char * const k_PROCESSOR_ARCHITECTURE[] =
|
||||
{
|
||||
"x86" // "INTEL"
|
||||
, "MIPS"
|
||||
, "ALPHA"
|
||||
, "PPC"
|
||||
, "SHX"
|
||||
, "ARM"
|
||||
, "IA64"
|
||||
, "ALPHA64"
|
||||
, "MSIL"
|
||||
, "x64" // "AMD64"
|
||||
, "IA32_ON_WIN64"
|
||||
, "NEUTRAL"
|
||||
, "ARM64"
|
||||
, "ARM32_ON_WIN64"
|
||||
};
|
||||
|
||||
#define MY__PROCESSOR_ARCHITECTURE_INTEL 0
|
||||
#define MY__PROCESSOR_ARCHITECTURE_AMD64 9
|
||||
|
||||
|
||||
#define MY__PROCESSOR_INTEL_PENTIUM 586
|
||||
#define MY__PROCESSOR_AMD_X8664 8664
|
||||
|
||||
/*
|
||||
static const CUInt32PCharPair k_PROCESSOR[] =
|
||||
{
|
||||
{ 2200, "IA64" },
|
||||
{ 8664, "x64" }
|
||||
};
|
||||
|
||||
#define PROCESSOR_INTEL_386 386
|
||||
#define PROCESSOR_INTEL_486 486
|
||||
#define PROCESSOR_INTEL_PENTIUM 586
|
||||
#define PROCESSOR_INTEL_860 860
|
||||
#define PROCESSOR_INTEL_IA64 2200
|
||||
#define PROCESSOR_AMD_X8664 8664
|
||||
#define PROCESSOR_MIPS_R2000 2000
|
||||
#define PROCESSOR_MIPS_R3000 3000
|
||||
#define PROCESSOR_MIPS_R4000 4000
|
||||
#define PROCESSOR_ALPHA_21064 21064
|
||||
#define PROCESSOR_PPC_601 601
|
||||
#define PROCESSOR_PPC_603 603
|
||||
#define PROCESSOR_PPC_604 604
|
||||
#define PROCESSOR_PPC_620 620
|
||||
#define PROCESSOR_HITACHI_SH3 10003
|
||||
#define PROCESSOR_HITACHI_SH3E 10004
|
||||
#define PROCESSOR_HITACHI_SH4 10005
|
||||
#define PROCESSOR_MOTOROLA_821 821
|
||||
#define PROCESSOR_SHx_SH3 103
|
||||
#define PROCESSOR_SHx_SH4 104
|
||||
#define PROCESSOR_STRONGARM 2577 // 0xA11
|
||||
#define PROCESSOR_ARM720 1824 // 0x720
|
||||
#define PROCESSOR_ARM820 2080 // 0x820
|
||||
#define PROCESSOR_ARM920 2336 // 0x920
|
||||
#define PROCESSOR_ARM_7TDMI 70001
|
||||
#define PROCESSOR_OPTIL 18767 // 0x494f
|
||||
*/
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
static const char * const k_PF[] =
|
||||
{
|
||||
"FP_ERRATA"
|
||||
, "FP_EMU"
|
||||
, "CMPXCHG"
|
||||
, "MMX"
|
||||
, "PPC_MOVEMEM_64BIT"
|
||||
, "ALPHA_BYTE"
|
||||
, "SSE"
|
||||
, "3DNOW"
|
||||
, "RDTSC"
|
||||
, "PAE"
|
||||
, "SSE2"
|
||||
, "SSE_DAZ"
|
||||
, "NX"
|
||||
, "SSE3"
|
||||
, "CMPXCHG16B"
|
||||
, "CMP8XCHG16"
|
||||
, "CHANNELS"
|
||||
, "XSAVE"
|
||||
, "ARM_VFP_32"
|
||||
, "ARM_NEON"
|
||||
, "L2AT"
|
||||
, "VIRT_FIRMWARE"
|
||||
, "RDWRFSGSBASE"
|
||||
, "FASTFAIL"
|
||||
, "ARM_DIVIDE"
|
||||
, "ARM_64BIT_LOADSTORE_ATOMIC"
|
||||
, "ARM_EXTERNAL_CACHE"
|
||||
, "ARM_FMAC"
|
||||
, "RDRAND"
|
||||
, "ARM_V8"
|
||||
, "ARM_V8_CRYPTO"
|
||||
, "ARM_V8_CRC32"
|
||||
, "RDTSCP"
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
static void PrintSize(AString &s, UInt64 ptr)
|
||||
{
|
||||
UInt64 v = ptr;
|
||||
UInt64 t = v >> 40;
|
||||
UInt64 g = v >> 30;
|
||||
UInt64 m = v >> 20;
|
||||
UInt64 k = v >> 10;
|
||||
UInt32 d = (UInt32)v;
|
||||
char c = 0;
|
||||
if (t >= 1000) { d = (UInt32)t; c = 'T'; }
|
||||
else if (g >= 1000) { d = (UInt32)g; c = 'G'; }
|
||||
else if (m >= 1000) { d = (UInt32)m; c = 'M'; }
|
||||
else if (k >= 10) { d = (UInt32)k; c = 'K'; }
|
||||
|
||||
s.Add_UInt32(d);
|
||||
// s += ' ';
|
||||
if (c)
|
||||
s += c;
|
||||
|
||||
|
||||
// PrintHex(s, (DWORD_PTR)v);
|
||||
}
|
||||
|
||||
|
||||
static void PrintPage(AString &s, UInt32 v)
|
||||
{
|
||||
if ((v & 0x3FF) == 0)
|
||||
{
|
||||
s.Add_UInt32(v >> 10);
|
||||
s += "K";
|
||||
}
|
||||
else
|
||||
s.Add_UInt32(v >> 10);
|
||||
}
|
||||
|
||||
static AString TypeToString2(const char * const table[], unsigned num, UInt32 value)
|
||||
{
|
||||
char sz[16];
|
||||
const char *p = NULL;
|
||||
if (value < num)
|
||||
p = table[value];
|
||||
if (!p)
|
||||
{
|
||||
ConvertUInt32ToString(value, sz);
|
||||
p = sz;
|
||||
}
|
||||
return (AString)p;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
static void SysInfo_To_String(AString &s, const SYSTEM_INFO &si)
|
||||
{
|
||||
s += TypeToString2(k_PROCESSOR_ARCHITECTURE, ARRAY_SIZE(k_PROCESSOR_ARCHITECTURE), si.wProcessorArchitecture);
|
||||
|
||||
if (!( si.wProcessorArchitecture == MY__PROCESSOR_ARCHITECTURE_INTEL && si.dwProcessorType == MY__PROCESSOR_INTEL_PENTIUM
|
||||
|| si.wProcessorArchitecture == MY__PROCESSOR_ARCHITECTURE_AMD64 && si.dwProcessorType == MY__PROCESSOR_AMD_X8664))
|
||||
{
|
||||
s += " ";
|
||||
// s += TypePairToString(k_PROCESSOR, ARRAY_SIZE(k_PROCESSOR), si.dwProcessorType);
|
||||
s.Add_UInt32(si.dwProcessorType);
|
||||
}
|
||||
s += " ";
|
||||
PrintHex(s, si.wProcessorLevel);
|
||||
s += ".";
|
||||
PrintHex(s, si.wProcessorRevision);
|
||||
if (si.dwActiveProcessorMask + 1 != ((UInt64)1 << si.dwNumberOfProcessors))
|
||||
{
|
||||
s += " act:";
|
||||
PrintHex(s, si.dwActiveProcessorMask);
|
||||
}
|
||||
s += " cpus:";
|
||||
s.Add_UInt32(si.dwNumberOfProcessors);
|
||||
if (si.dwPageSize != 1 << 12)
|
||||
{
|
||||
s += " page:";
|
||||
PrintPage(s, si.dwPageSize);
|
||||
}
|
||||
if (si.dwAllocationGranularity != 1 << 16)
|
||||
{
|
||||
s += " gran:";
|
||||
PrintPage(s, si.dwAllocationGranularity);
|
||||
}
|
||||
s += " ";
|
||||
|
||||
DWORD_PTR minAdd = (DWORD_PTR)si.lpMinimumApplicationAddress;
|
||||
if (minAdd != (1 << 16))
|
||||
{
|
||||
PrintSize(s, minAdd);
|
||||
s += "-";
|
||||
}
|
||||
PrintSize(s, (UInt64)(DWORD_PTR)si.lpMaximumApplicationAddress + 1);
|
||||
}
|
||||
|
||||
#ifndef _WIN64
|
||||
typedef VOID (WINAPI *Func_GetNativeSystemInfo)(LPSYSTEM_INFO lpSystemInfo);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
void GetSysInfo(AString &s1, AString &s2)
|
||||
{
|
||||
s1.Empty();
|
||||
s2.Empty();
|
||||
|
||||
#ifdef _WIN32
|
||||
SYSTEM_INFO si;
|
||||
GetSystemInfo(&si);
|
||||
{
|
||||
SysInfo_To_String(s1, si);
|
||||
// s += " : ";
|
||||
}
|
||||
|
||||
#if !defined(_WIN64) && !defined(UNDER_CE)
|
||||
Func_GetNativeSystemInfo fn_GetNativeSystemInfo = (Func_GetNativeSystemInfo)GetProcAddress(
|
||||
GetModuleHandleA("kernel32.dll"), "GetNativeSystemInfo");
|
||||
if (fn_GetNativeSystemInfo)
|
||||
{
|
||||
SYSTEM_INFO si2;
|
||||
fn_GetNativeSystemInfo(&si2);
|
||||
// if (memcmp(&si, &si2, sizeof(si)) != 0)
|
||||
{
|
||||
// s += " - ";
|
||||
SysInfo_To_String(s2, si2);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void GetCpuName(AString &s)
|
||||
{
|
||||
s.Empty();
|
||||
@@ -2419,31 +2685,53 @@ void GetCpuName(AString &s)
|
||||
Cx86cpuid cpuid;
|
||||
if (x86cpuid_CheckAndRead(&cpuid))
|
||||
{
|
||||
x86cpuid_to_String(cpuid, s);
|
||||
AString s2;
|
||||
x86cpuid_to_String(cpuid, s2);
|
||||
s += s2;
|
||||
return;
|
||||
}
|
||||
#ifdef MY_CPU_AMD64
|
||||
s = "x64";
|
||||
s += "x64";
|
||||
#else
|
||||
s = "x86";
|
||||
s += "x86";
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
|
||||
#ifdef MY_CPU_LE
|
||||
s = "LE";
|
||||
s += "LE";
|
||||
#elif defined(MY_CPU_BE)
|
||||
s = "BE";
|
||||
s += "BE";
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void GetCpuFeatures(AString &s)
|
||||
{
|
||||
s.Empty();
|
||||
|
||||
#ifdef _WIN32
|
||||
const unsigned kNumFeatures_Extra = 32; // we check also for unknown features
|
||||
const unsigned kNumFeatures = ARRAY_SIZE(k_PF) + kNumFeatures_Extra;
|
||||
for (unsigned i = 0; i < kNumFeatures; i++)
|
||||
{
|
||||
if (IsProcessorFeaturePresent(i))
|
||||
{
|
||||
s.Add_Space_if_NotEmpty();
|
||||
s += TypeToString2(k_PF, ARRAY_SIZE(k_PF), i);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
HRESULT Bench(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
IBenchPrintCallback *printCallback,
|
||||
IBenchCallback *benchCallback,
|
||||
// IBenchFreqCallback *freqCallback,
|
||||
const CObjectVector<CProperty> &props,
|
||||
UInt32 numIterations,
|
||||
bool multiDict)
|
||||
@@ -2454,8 +2742,16 @@ HRESULT Bench(
|
||||
UInt32 numCPUs = 1;
|
||||
UInt64 ramSize = (UInt64)(sizeof(size_t)) << 29;
|
||||
|
||||
NSystem::CProcessAffinity threadsInfo;
|
||||
threadsInfo.InitST();
|
||||
|
||||
#ifndef _7ZIP_ST
|
||||
numCPUs = NSystem::GetNumberOfProcessors();
|
||||
|
||||
if (threadsInfo.Get() && threadsInfo.processAffinityMask != 0)
|
||||
numCPUs = threadsInfo.GetNumProcessThreads();
|
||||
else
|
||||
numCPUs = NSystem::GetNumberOfProcessors();
|
||||
|
||||
#endif
|
||||
|
||||
bool ramSize_Defined = NSystem::GetRamSize(ramSize);
|
||||
@@ -2477,7 +2773,7 @@ HRESULT Bench(
|
||||
for (i = 0; i < props.Size(); i++)
|
||||
{
|
||||
const CProperty &property = props[i];
|
||||
UString name = property.Name;
|
||||
UString name (property.Name);
|
||||
name.MakeLower_Ascii();
|
||||
|
||||
if (name.IsEqualTo("file"))
|
||||
@@ -2504,7 +2800,6 @@ HRESULT Bench(
|
||||
if (printCallback)
|
||||
{
|
||||
printCallback->Print("file size =");
|
||||
// printCallback->Print(GetOemString(property.Value));
|
||||
PrintNumber(*printCallback, len, 0);
|
||||
printCallback->NewLine();
|
||||
}
|
||||
@@ -2523,14 +2818,14 @@ HRESULT Bench(
|
||||
|
||||
if (name.IsEqualTo("time"))
|
||||
{
|
||||
RINOK(ParsePropToUInt32(L"", propVariant, testTime));
|
||||
RINOK(ParsePropToUInt32(UString(), propVariant, testTime));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (name.IsEqualTo("freq"))
|
||||
{
|
||||
UInt32 freq32 = 0;
|
||||
RINOK(ParsePropToUInt32(L"", propVariant, freq32));
|
||||
RINOK(ParsePropToUInt32(UString(), propVariant, freq32));
|
||||
if (freq32 == 0)
|
||||
return E_INVALIDARG;
|
||||
specifiedFreq = (UInt64)freq32 * 1000000;
|
||||
@@ -2548,19 +2843,12 @@ HRESULT Bench(
|
||||
if (name.IsPrefixedBy_Ascii_NoCase("mt"))
|
||||
{
|
||||
UString s = name.Ptr(2);
|
||||
if (s == L"*")
|
||||
if (s.IsEqualTo("*")
|
||||
|| s.IsEmpty() && propVariant.vt == VT_BSTR && StringsAreEqual_Ascii(propVariant.bstrVal, "*"))
|
||||
{
|
||||
multiThreadTests = true;
|
||||
continue;
|
||||
}
|
||||
if (s.IsEmpty() && propVariant.vt == VT_BSTR)
|
||||
{
|
||||
if (wcscmp(propVariant.bstrVal, L"*") == 0)
|
||||
{
|
||||
multiThreadTests = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#ifndef _7ZIP_ST
|
||||
RINOK(ParseMtProp(s, propVariant, numCPUs, numThreadsSpecified));
|
||||
#endif
|
||||
@@ -2573,10 +2861,38 @@ HRESULT Bench(
|
||||
|
||||
if (printCallback)
|
||||
{
|
||||
AString s;
|
||||
GetCpuName(s);
|
||||
printCallback->Print(s);
|
||||
printCallback->NewLine();
|
||||
{
|
||||
AString s1, s2;
|
||||
GetSysInfo(s1, s2);
|
||||
if (!s1.IsEmpty() || !s2.IsEmpty())
|
||||
{
|
||||
printCallback->Print(s1);
|
||||
if (s1 != s2 && !s2.IsEmpty())
|
||||
{
|
||||
printCallback->Print(" - ");
|
||||
printCallback->Print(s2);
|
||||
}
|
||||
printCallback->NewLine();
|
||||
}
|
||||
}
|
||||
{
|
||||
AString s;
|
||||
GetCpuFeatures(s);
|
||||
if (!s.IsEmpty())
|
||||
{
|
||||
printCallback->Print(s);
|
||||
printCallback->NewLine();
|
||||
}
|
||||
}
|
||||
{
|
||||
AString s;
|
||||
GetCpuName(s);
|
||||
if (!s.IsEmpty())
|
||||
{
|
||||
printCallback->Print(s);
|
||||
printCallback->NewLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (printCallback)
|
||||
@@ -2586,7 +2902,7 @@ HRESULT Bench(
|
||||
|
||||
UInt64 complexInCommands = kComplexInCommands;
|
||||
|
||||
if (printCallback /* || benchCallback */)
|
||||
if (printCallback /* || freqCallback */)
|
||||
{
|
||||
UInt64 numMilCommands = 1 << 6;
|
||||
if (specifiedFreq != 0)
|
||||
@@ -2623,8 +2939,8 @@ HRESULT Bench(
|
||||
}
|
||||
}
|
||||
/*
|
||||
if (benchCallback)
|
||||
benchCallback->AddCpuFreq(mipsVal);
|
||||
if (freqCallback)
|
||||
freqCallback->AddCpuFreq(mipsVal);
|
||||
*/
|
||||
|
||||
if (jj >= 3)
|
||||
@@ -2643,6 +2959,8 @@ HRESULT Bench(
|
||||
printCallback->NewLine();
|
||||
printCallback->NewLine();
|
||||
PrintRequirements(*printCallback, "size: ", ramSize_Defined, ramSize, "CPU hardware threads:", numCPUs);
|
||||
printCallback->Print(GetProcessThreadsInfo(threadsInfo));
|
||||
printCallback->NewLine();
|
||||
}
|
||||
|
||||
if (numThreadsSpecified < 1 || numThreadsSpecified > kNumThreadsMax)
|
||||
@@ -2669,7 +2987,7 @@ HRESULT Bench(
|
||||
kOldLzmaDictBits, printCallback, benchCallback, &benchProps);
|
||||
}
|
||||
|
||||
AString methodName = method.MethodName;
|
||||
AString methodName (method.MethodName);
|
||||
if (methodName.IsEqualTo_Ascii_NoCase("CRC"))
|
||||
methodName = "crc32";
|
||||
method.MethodName = methodName;
|
||||
@@ -2691,7 +3009,7 @@ HRESULT Bench(
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(g_Hash); i++)
|
||||
{
|
||||
const CBenchHash &h = g_Hash[i];
|
||||
AString s = h.Name;
|
||||
AString s (h.Name);
|
||||
AString hProp;
|
||||
int propPos = s.Find(':');
|
||||
if (propPos >= 0)
|
||||
@@ -2852,6 +3170,7 @@ HRESULT Bench(
|
||||
}
|
||||
|
||||
PrintRequirements(f, "usage:", true, GetBenchMemoryUsage(numThreads, dict, totalBenchMode), "Benchmark threads: ", numThreads);
|
||||
f.NewLine();
|
||||
|
||||
f.NewLine();
|
||||
|
||||
@@ -3000,7 +3319,6 @@ HRESULT Bench(
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(g_Bench); i++)
|
||||
{
|
||||
const CBenchMethod &h = g_Bench[i];
|
||||
AString s = h.Name;
|
||||
if (AreSameMethodNames(h.Name, methodName))
|
||||
{
|
||||
callback.BenchProps.EncComplex = h.EncComplex;
|
||||
@@ -3040,7 +3358,7 @@ HRESULT Bench(
|
||||
// method2 can have two different dictionary size properties.
|
||||
// And last property is main.
|
||||
NCOM::CPropVariant propVariant = (UInt32)pow;
|
||||
RINOK(method2.ParseMethodFromPROPVARIANT(L"d", propVariant));
|
||||
RINOK(method2.ParseMethodFromPROPVARIANT((UString)"d", propVariant));
|
||||
}
|
||||
|
||||
size_t uncompressedDataSize;
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#ifndef __7ZIP_BENCH_H
|
||||
#define __7ZIP_BENCH_H
|
||||
|
||||
#include "../../../Windows/System.h"
|
||||
|
||||
#include "../../Common/CreateCoder.h"
|
||||
#include "../../UI/Common/Property.h"
|
||||
|
||||
@@ -43,13 +45,28 @@ struct IBenchPrintCallback
|
||||
virtual HRESULT CheckBreak() = 0;
|
||||
};
|
||||
|
||||
/*
|
||||
struct IBenchFreqCallback
|
||||
{
|
||||
virtual void AddCpuFreq(UInt64 freq) = 0;
|
||||
};
|
||||
*/
|
||||
|
||||
HRESULT Bench(
|
||||
DECL_EXTERNAL_CODECS_LOC_VARS
|
||||
IBenchPrintCallback *printCallback,
|
||||
IBenchCallback *benchCallback,
|
||||
// IBenchFreqCallback *freqCallback,
|
||||
const CObjectVector<CProperty> &props,
|
||||
UInt32 numIterations,
|
||||
bool multiDict
|
||||
);
|
||||
|
||||
AString GetProcessThreadsInfo(const NWindows::NSystem::CProcessAffinity &ti);
|
||||
|
||||
void GetSysInfo(AString &s1, AString &s2);
|
||||
void GetCpuName(AString &s);
|
||||
void GetCpuFeatures(AString &s);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -30,24 +30,24 @@ using namespace NWindows;
|
||||
#define MY_TRY_FINISH_VOID } \
|
||||
catch(...) { ErrorMessageHRESULT(E_FAIL); }
|
||||
|
||||
static const char *k7zGui = "7zG.exe";
|
||||
#define k7zGui "7zG.exe"
|
||||
|
||||
static const char *kShowDialogSwitch = " -ad";
|
||||
static const char *kEmailSwitch = " -seml.";
|
||||
static const char *kIncludeSwitch = " -i";
|
||||
static const char *kArchiveTypeSwitch = " -t";
|
||||
static const char *kArcIncludeSwitches = " -an -ai";
|
||||
static const char *kHashIncludeSwitches = " -i";
|
||||
static const char *kStopSwitchParsing = " --";
|
||||
static const char *kLargePagesDisable = " -slp-";
|
||||
#define kShowDialogSwitch " -ad"
|
||||
#define kEmailSwitch " -seml."
|
||||
#define kIncludeSwitch " -i"
|
||||
#define kArchiveTypeSwitch " -t"
|
||||
#define kArcIncludeSwitches " -an -ai"
|
||||
#define kHashIncludeSwitches " -i"
|
||||
#define kStopSwitchParsing " --"
|
||||
#define kLargePagesDisable " -slp-"
|
||||
|
||||
extern HWND g_HWND;
|
||||
|
||||
UString GetQuotedString(const UString &s)
|
||||
{
|
||||
UString s2 = L'\"';
|
||||
UString s2 ('\"');
|
||||
s2 += s;
|
||||
s2 += L'\"';
|
||||
s2 += '\"';
|
||||
return s2;
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ static HRESULT Call7zGui(const UString ¶ms,
|
||||
NSynchronization::CBaseEvent *event)
|
||||
{
|
||||
UString imageName = fs2us(NWindows::NDLL::GetModuleDirPrefix());
|
||||
imageName.AddAscii(k7zGui);
|
||||
imageName += k7zGui;
|
||||
|
||||
CProcess process;
|
||||
WRes res = process.Create(imageName, params, NULL); // curDir);
|
||||
@@ -95,7 +95,7 @@ static HRESULT Call7zGui(const UString ¶ms,
|
||||
static void AddLagePagesSwitch(UString ¶ms)
|
||||
{
|
||||
if (!ReadLockMemoryEnable())
|
||||
params.AddAscii(kLargePagesDisable);
|
||||
params += kLargePagesDisable;
|
||||
}
|
||||
|
||||
class CRandNameGenerator
|
||||
@@ -105,10 +105,8 @@ public:
|
||||
CRandNameGenerator() { _random.Init(); }
|
||||
void GenerateName(UString &s, const char *prefix)
|
||||
{
|
||||
s.AddAscii(prefix);
|
||||
char temp[16];
|
||||
ConvertUInt32ToString((UInt32)(unsigned)_random.Generate(), temp);
|
||||
s.AddAscii(temp);
|
||||
s += prefix;
|
||||
s.Add_UInt32((UInt32)(unsigned)_random.Generate());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -150,14 +148,14 @@ static HRESULT CreateMap(const UStringVector &names,
|
||||
event.Close();
|
||||
}
|
||||
|
||||
params += L'#';
|
||||
params += '#';
|
||||
params += mappingName;
|
||||
params += L':';
|
||||
params += ':';
|
||||
char temp[32];
|
||||
ConvertUInt64ToString(totalSize, temp);
|
||||
params.AddAscii(temp);
|
||||
params += temp;
|
||||
|
||||
params += L':';
|
||||
params += ':';
|
||||
params += eventName;
|
||||
|
||||
LPVOID data = fileMapping.Map(FILE_MAP_WRITE, 0, totalSize);
|
||||
@@ -187,36 +185,36 @@ HRESULT CompressFiles(
|
||||
bool email, bool showDialog, bool waitFinish)
|
||||
{
|
||||
MY_TRY_BEGIN
|
||||
UString params = L'a';
|
||||
UString params ('a');
|
||||
|
||||
CFileMapping fileMapping;
|
||||
NSynchronization::CManualResetEvent event;
|
||||
params.AddAscii(kIncludeSwitch);
|
||||
params += kIncludeSwitch;
|
||||
RINOK(CreateMap(names, fileMapping, event, params));
|
||||
|
||||
if (!arcType.IsEmpty())
|
||||
{
|
||||
params.AddAscii(kArchiveTypeSwitch);
|
||||
params += kArchiveTypeSwitch;
|
||||
params += arcType;
|
||||
}
|
||||
|
||||
if (email)
|
||||
params.AddAscii(kEmailSwitch);
|
||||
params += kEmailSwitch;
|
||||
|
||||
if (showDialog)
|
||||
params.AddAscii(kShowDialogSwitch);
|
||||
params += kShowDialogSwitch;
|
||||
|
||||
AddLagePagesSwitch(params);
|
||||
|
||||
if (arcName.IsEmpty())
|
||||
params.AddAscii(" -an");
|
||||
params += " -an";
|
||||
|
||||
if (addExtension)
|
||||
params.AddAscii(" -saa");
|
||||
params += " -saa";
|
||||
else
|
||||
params.AddAscii(" -sae");
|
||||
params += " -sae";
|
||||
|
||||
params.AddAscii(kStopSwitchParsing);
|
||||
params += kStopSwitchParsing;
|
||||
params.Add_Space();
|
||||
|
||||
if (!arcName.IsEmpty())
|
||||
@@ -237,7 +235,7 @@ HRESULT CompressFiles(
|
||||
static void ExtractGroupCommand(const UStringVector &arcPaths, UString ¶ms, bool isHash)
|
||||
{
|
||||
AddLagePagesSwitch(params);
|
||||
params.AddAscii(isHash ? kHashIncludeSwitches : kArcIncludeSwitches);
|
||||
params += (isHash ? kHashIncludeSwitches : kArcIncludeSwitches);
|
||||
CFileMapping fileMapping;
|
||||
NSynchronization::CManualResetEvent event;
|
||||
HRESULT result = CreateMap(arcPaths, fileMapping, event, params);
|
||||
@@ -250,16 +248,16 @@ static void ExtractGroupCommand(const UStringVector &arcPaths, UString ¶ms,
|
||||
void ExtractArchives(const UStringVector &arcPaths, const UString &outFolder, bool showDialog, bool elimDup)
|
||||
{
|
||||
MY_TRY_BEGIN
|
||||
UString params = L'x';
|
||||
UString params ('x');
|
||||
if (!outFolder.IsEmpty())
|
||||
{
|
||||
params.AddAscii(" -o");
|
||||
params += " -o";
|
||||
params += GetQuotedString(outFolder);
|
||||
}
|
||||
if (elimDup)
|
||||
params.AddAscii(" -spe");
|
||||
params += " -spe";
|
||||
if (showDialog)
|
||||
params.AddAscii(kShowDialogSwitch);
|
||||
params += kShowDialogSwitch;
|
||||
ExtractGroupCommand(arcPaths, params, false);
|
||||
MY_TRY_FINISH_VOID
|
||||
}
|
||||
@@ -267,7 +265,7 @@ void ExtractArchives(const UStringVector &arcPaths, const UString &outFolder, bo
|
||||
void TestArchives(const UStringVector &arcPaths)
|
||||
{
|
||||
MY_TRY_BEGIN
|
||||
UString params = L't';
|
||||
UString params ('t');
|
||||
ExtractGroupCommand(arcPaths, params, false);
|
||||
MY_TRY_FINISH_VOID
|
||||
}
|
||||
@@ -275,10 +273,10 @@ void TestArchives(const UStringVector &arcPaths)
|
||||
void CalcChecksum(const UStringVector &paths, const UString &methodName)
|
||||
{
|
||||
MY_TRY_BEGIN
|
||||
UString params = L'h';
|
||||
UString params ('h');
|
||||
if (!methodName.IsEmpty())
|
||||
{
|
||||
params.AddAscii(" -scrc");
|
||||
params += " -scrc";
|
||||
params += methodName;
|
||||
}
|
||||
ExtractGroupCommand(paths, params, true);
|
||||
@@ -288,7 +286,10 @@ void CalcChecksum(const UStringVector &paths, const UString &methodName)
|
||||
void Benchmark(bool totalMode)
|
||||
{
|
||||
MY_TRY_BEGIN
|
||||
HRESULT result = Call7zGui(totalMode ? L"b -mm=*" : L"b", false, NULL);
|
||||
UString params ('b');
|
||||
if (totalMode)
|
||||
params += " -mm=*";
|
||||
HRESULT result = Call7zGui(params, false, NULL);
|
||||
if (result != S_OK)
|
||||
ErrorMessageHRESULT(result);
|
||||
MY_TRY_FINISH_VOID
|
||||
|
||||
@@ -59,9 +59,9 @@ static void ThrowException_if_Error(HRESULT res)
|
||||
|
||||
UString GetQuotedString(const UString &s)
|
||||
{
|
||||
UString s2 = L'\"';
|
||||
UString s2 ('\"');
|
||||
s2 += s;
|
||||
s2 += L'\"';
|
||||
s2 += '\"';
|
||||
return s2;
|
||||
}
|
||||
|
||||
@@ -145,6 +145,7 @@ HRESULT CompressFiles(
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
static HRESULT ExtractGroupCommand(const UStringVector &arcPaths,
|
||||
bool showDialog, const UString &outFolder, bool testMode, bool elimDup = false)
|
||||
{
|
||||
@@ -192,10 +193,14 @@ static HRESULT ExtractGroupCommand(const UStringVector &arcPaths,
|
||||
censor.AddPathsToCensor(NWildcard::k_RelatPath);
|
||||
|
||||
bool messageWasDisplayed = false;
|
||||
|
||||
ecs->MultiArcMode = (arcPathsSorted.Size() > 1);
|
||||
|
||||
result = ExtractGUI(codecs,
|
||||
formatIndices, CIntVector(),
|
||||
arcPathsSorted, arcFullPathsSorted,
|
||||
censor.Pairs.Front().Head, eo, NULL, showDialog, messageWasDisplayed, ecs, g_HWND);
|
||||
|
||||
if (result != S_OK)
|
||||
{
|
||||
if (result != E_ABORT && messageWasDisplayed)
|
||||
@@ -260,8 +265,8 @@ void Benchmark(bool totalMode)
|
||||
if (totalMode)
|
||||
{
|
||||
CProperty prop;
|
||||
prop.Name = L"m";
|
||||
prop.Value = L"*";
|
||||
prop.Name = "m";
|
||||
prop.Value = "*";
|
||||
props.Add(prop);
|
||||
}
|
||||
result = Benchmark(EXTERNAL_CODECS_VARS_L props, g_HWND);
|
||||
|
||||
@@ -20,9 +20,18 @@ struct CDirItemsStat
|
||||
UInt64 AltStreamsSize;
|
||||
|
||||
UInt64 NumErrors;
|
||||
// UInt64 GetTotalItems() const { return NumDirs + NumFiles + NumAltStreams; }
|
||||
|
||||
UInt64 Get_NumItems() const { return NumDirs + NumFiles + NumAltStreams; }
|
||||
UInt64 Get_NumDataItems() const { return NumFiles + NumAltStreams; }
|
||||
UInt64 GetTotalBytes() const { return FilesSize + AltStreamsSize; }
|
||||
|
||||
bool IsEmpty() const { return
|
||||
0 == NumDirs
|
||||
&& 0 == NumFiles
|
||||
&& 0 == NumAltStreams
|
||||
&& 0 == FilesSize
|
||||
&& 0 == AltStreamsSize
|
||||
&& 0 == NumErrors; }
|
||||
|
||||
CDirItemsStat():
|
||||
NumDirs(0),
|
||||
|
||||
@@ -213,7 +213,8 @@ HRESULT CDirItems::EnumerateDir(int phyParent, int logParent, const FString &phy
|
||||
{
|
||||
RINOK(ScanProgress(phyPrefix));
|
||||
|
||||
NFind::CEnumerator enumerator(phyPrefix + FCHAR_ANY_MASK);
|
||||
NFind::CEnumerator enumerator;
|
||||
enumerator.SetDirPrefix(phyPrefix);
|
||||
for (unsigned ttt = 0; ; ttt++)
|
||||
{
|
||||
NFind::CFileInfo fi;
|
||||
@@ -570,7 +571,7 @@ static HRESULT EnumerateDirItems(
|
||||
#endif
|
||||
*/
|
||||
|
||||
fullPath = FCHAR_PATH_SEPARATOR;
|
||||
fullPath = CHAR_PATH_SEPARATOR;
|
||||
}
|
||||
#if defined(_WIN32) && !defined(UNDER_CE)
|
||||
else if (item.IsDriveItem())
|
||||
@@ -682,7 +683,7 @@ static HRESULT EnumerateDirItems(
|
||||
{
|
||||
{
|
||||
if (nextNode.Name.IsEmpty())
|
||||
fullPath = FCHAR_PATH_SEPARATOR;
|
||||
fullPath = CHAR_PATH_SEPARATOR;
|
||||
#ifdef _WIN32
|
||||
else if (NWildcard::IsDriveColonName(nextNode.Name))
|
||||
fullPath.Add_PathSepar();
|
||||
@@ -773,7 +774,9 @@ static HRESULT EnumerateDirItems(
|
||||
#endif
|
||||
#endif
|
||||
|
||||
NFind::CEnumerator enumerator(phyPrefix + FCHAR_ANY_MASK);
|
||||
NFind::CEnumerator enumerator;
|
||||
enumerator.SetDirPrefix(phyPrefix);
|
||||
|
||||
for (unsigned ttt = 0; ; ttt++)
|
||||
{
|
||||
NFind::CFileInfo fi;
|
||||
|
||||
@@ -51,7 +51,7 @@ static HRESULT DecompressArchive(
|
||||
replaceName = arc0.DefaultName;
|
||||
}
|
||||
|
||||
outDir.Replace(FSTRING_ANY_MASK, us2fs(Get_Correct_FsFile_Name(replaceName)));
|
||||
outDir.Replace(FString("*"), us2fs(Get_Correct_FsFile_Name(replaceName)));
|
||||
|
||||
bool elimIsPossible = false;
|
||||
UString elimPrefix; // only pure name without dir delimiter
|
||||
@@ -156,7 +156,7 @@ static HRESULT DecompressArchive(
|
||||
#endif
|
||||
|
||||
if (outDir.IsEmpty())
|
||||
outDir = FTEXT(".") FSTRING_PATH_SEPARATOR;
|
||||
outDir = "." STRING_PATH_SEPARATOR;
|
||||
/*
|
||||
#ifdef _WIN32
|
||||
else if (NName::IsAltPathPrefix(outDir)) {}
|
||||
@@ -167,7 +167,7 @@ static HRESULT DecompressArchive(
|
||||
HRESULT res = ::GetLastError();
|
||||
if (res == S_OK)
|
||||
res = E_FAIL;
|
||||
errorMessage.SetFromAscii("Can not create output directory: ");
|
||||
errorMessage = "Can not create output directory: ";
|
||||
errorMessage += fs2us(outDir);
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,15 @@
|
||||
|
||||
#include "ExtractingFilePath.h"
|
||||
|
||||
bool g_PathTrailReplaceMode =
|
||||
#ifdef _WIN32
|
||||
true
|
||||
#else
|
||||
false
|
||||
#endif
|
||||
;
|
||||
|
||||
|
||||
static void ReplaceIncorrectChars(UString &s)
|
||||
{
|
||||
{
|
||||
@@ -26,17 +35,42 @@ static void ReplaceIncorrectChars(UString &s)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
if (g_PathTrailReplaceMode)
|
||||
{
|
||||
for (unsigned i = s.Len(); i != 0;)
|
||||
/*
|
||||
// if (g_PathTrailReplaceMode == 1)
|
||||
{
|
||||
wchar_t c = s[--i];
|
||||
if (c != '.' && c != ' ')
|
||||
break;
|
||||
s.ReplaceOneCharAtPos(i, '_');
|
||||
if (!s.IsEmpty())
|
||||
{
|
||||
wchar_t c = s.Back();
|
||||
if (c == '.' || c == ' ')
|
||||
{
|
||||
// s += (wchar_t)(0x9c); // STRING TERMINATOR
|
||||
s += (wchar_t)'_';
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
*/
|
||||
{
|
||||
unsigned i;
|
||||
for (i = s.Len(); i != 0;)
|
||||
{
|
||||
wchar_t c = s[i - 1];
|
||||
if (c != '.' && c != ' ')
|
||||
break;
|
||||
i--;
|
||||
s.ReplaceOneCharAtPos(i, '_');
|
||||
// s.ReplaceOneCharAtPos(i, (c == ' ' ? (wchar_t)(0x2423) : (wchar_t)0x00B7));
|
||||
}
|
||||
/*
|
||||
if (g_PathTrailReplaceMode > 1 && i != s.Len())
|
||||
{
|
||||
s.DeleteFrom(i);
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
@@ -61,7 +95,7 @@ void Correct_AltStream_Name(UString &s)
|
||||
s.ReplaceOneCharAtPos(i, '_');
|
||||
}
|
||||
if (s.IsEmpty())
|
||||
s = L'_';
|
||||
s = '_';
|
||||
}
|
||||
|
||||
static const unsigned g_ReservedWithNum_Index = 4;
|
||||
@@ -120,8 +154,8 @@ static void Correct_PathPart(UString &s)
|
||||
#endif
|
||||
}
|
||||
|
||||
// static const wchar_t *k_EmptyReplaceName = L"[]";
|
||||
static const wchar_t k_EmptyReplaceName = L'_';
|
||||
// static const char * const k_EmptyReplaceName = "[]";
|
||||
static const char k_EmptyReplaceName = '_';
|
||||
|
||||
UString Get_Correct_FsFile_Name(const UString &name)
|
||||
{
|
||||
@@ -176,11 +210,11 @@ void Correct_FsPath(bool absIsAllowed, UStringVector &parts, bool isDir)
|
||||
if (isDrive)
|
||||
{
|
||||
// we convert "c:name" to "c:\name", if absIsAllowed path.
|
||||
const UString &ds = parts[i - 1];
|
||||
if (ds.Len() != 2)
|
||||
UString &ds = parts[i - 1];
|
||||
if (ds.Len() > 2)
|
||||
{
|
||||
UString s = ds.Ptr(2);
|
||||
parts.Insert(i, s);
|
||||
parts.Insert(i, ds.Ptr(2));
|
||||
ds.DeleteFrom(2);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -214,7 +248,7 @@ void Correct_FsPath(bool absIsAllowed, UStringVector &parts, bool isDir)
|
||||
if (!isDir)
|
||||
{
|
||||
if (parts.IsEmpty())
|
||||
parts.Add(k_EmptyReplaceName);
|
||||
parts.Add((UString)k_EmptyReplaceName);
|
||||
else
|
||||
{
|
||||
UString &s = parts.Back();
|
||||
|
||||
@@ -30,17 +30,13 @@ public:
|
||||
~CHashMidBuf() { ::MidFree(_data); }
|
||||
};
|
||||
|
||||
static const char *k_DefaultHashMethod = "CRC32";
|
||||
static const char * const k_DefaultHashMethod = "CRC32";
|
||||
|
||||
HRESULT CHashBundle::SetMethods(DECL_EXTERNAL_CODECS_LOC_VARS const UStringVector &hashMethods)
|
||||
{
|
||||
UStringVector names = hashMethods;
|
||||
if (names.IsEmpty())
|
||||
{
|
||||
UString s;
|
||||
s.SetFromAscii(k_DefaultHashMethod);
|
||||
names.Add(s);
|
||||
}
|
||||
names.Add(UString(k_DefaultHashMethod));
|
||||
|
||||
CRecordVector<CMethodId> ids;
|
||||
CObjectVector<COneMethodInfo> methods;
|
||||
|
||||
@@ -81,7 +81,7 @@ using namespace NFile;
|
||||
#define kFormatsFolderName FTEXT("Formats")
|
||||
|
||||
|
||||
static CFSTR kMainDll =
|
||||
static CFSTR const kMainDll =
|
||||
// #ifdef _WIN32
|
||||
FTEXT("7z.dll");
|
||||
// #else
|
||||
@@ -91,9 +91,9 @@ static CFSTR kMainDll =
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
static LPCTSTR kRegistryPath = TEXT("Software") TEXT(STRING_PATH_SEPARATOR) TEXT("7-zip");
|
||||
static LPCWSTR kProgramPathValue = L"Path";
|
||||
static LPCWSTR kProgramPath2Value = L"Path"
|
||||
static LPCTSTR const kRegistryPath = TEXT("Software") TEXT(STRING_PATH_SEPARATOR) TEXT("7-zip");
|
||||
static LPCWSTR const kProgramPathValue = L"Path";
|
||||
static LPCWSTR const kProgramPath2Value = L"Path"
|
||||
#ifdef _WIN64
|
||||
L"64";
|
||||
#else
|
||||
@@ -516,12 +516,11 @@ HRESULT CCodecs::LoadDll(const FString &dllPath, bool needCheckDll, bool *loaded
|
||||
}
|
||||
|
||||
lib.CreateObject = (Func_CreateObject)lib.Lib.GetProc("CreateObject");
|
||||
if (lib.CreateObject)
|
||||
{
|
||||
unsigned startSize = Codecs.Size() + Hashers.Size();
|
||||
res = LoadCodecs();
|
||||
used = (startSize != Codecs.Size() + Hashers.Size());
|
||||
if (res == S_OK)
|
||||
if (res == S_OK && lib.CreateObject)
|
||||
{
|
||||
startSize = Formats.Size();
|
||||
res = LoadFormats();
|
||||
@@ -539,7 +538,8 @@ HRESULT CCodecs::LoadDll(const FString &dllPath, bool needCheckDll, bool *loaded
|
||||
|
||||
HRESULT CCodecs::LoadDllsFromFolder(const FString &folderPrefix)
|
||||
{
|
||||
NFile::NFind::CEnumerator enumerator(folderPrefix + FCHAR_ANY_MASK);
|
||||
NFile::NFind::CEnumerator enumerator;
|
||||
enumerator.SetDirPrefix(folderPrefix);
|
||||
NFile::NFind::CFileInfo fi;
|
||||
while (enumerator.Next(fi))
|
||||
{
|
||||
@@ -595,7 +595,7 @@ HRESULT CCodecs::Load()
|
||||
const CArcInfo &arc = *g_Arcs[i];
|
||||
CArcInfoEx item;
|
||||
|
||||
item.Name.SetFromAscii(arc.Name);
|
||||
item.Name = arc.Name;
|
||||
item.CreateInArchive = arc.CreateInArchive;
|
||||
item.IsArcFunc = arc.IsArc;
|
||||
item.Flags = arc.Flags;
|
||||
@@ -603,9 +603,9 @@ HRESULT CCodecs::Load()
|
||||
{
|
||||
UString e, ae;
|
||||
if (arc.Ext)
|
||||
e.SetFromAscii(arc.Ext);
|
||||
e = arc.Ext;
|
||||
if (arc.AddExt)
|
||||
ae.SetFromAscii(arc.AddExt);
|
||||
ae = arc.AddExt;
|
||||
item.AddExts(e, ae);
|
||||
}
|
||||
|
||||
@@ -866,7 +866,8 @@ STDMETHODIMP CCodecs::CreateDecoder(UInt32 index, const GUID *iid, void **coder)
|
||||
const CCodecLib &lib = Libs[ci.LibIndex];
|
||||
if (lib.CreateDecoder)
|
||||
return lib.CreateDecoder(ci.CodecIndex, iid, (void **)coder);
|
||||
return lib.CreateObject(&ci.Decoder, iid, (void **)coder);
|
||||
if (lib.CreateObject)
|
||||
return lib.CreateObject(&ci.Decoder, iid, (void **)coder);
|
||||
}
|
||||
return S_OK;
|
||||
#else
|
||||
@@ -888,7 +889,8 @@ STDMETHODIMP CCodecs::CreateEncoder(UInt32 index, const GUID *iid, void **coder)
|
||||
const CCodecLib &lib = Libs[ci.LibIndex];
|
||||
if (lib.CreateEncoder)
|
||||
return lib.CreateEncoder(ci.CodecIndex, iid, (void **)coder);
|
||||
return lib.CreateObject(&ci.Encoder, iid, (void **)coder);
|
||||
if (lib.CreateObject)
|
||||
return lib.CreateObject(&ci.Encoder, iid, (void **)coder);
|
||||
}
|
||||
return S_OK;
|
||||
#else
|
||||
|
||||
@@ -330,17 +330,17 @@ STDMETHODIMP CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val
|
||||
{
|
||||
case kpidPath:
|
||||
{
|
||||
wchar_t sz[32];
|
||||
char sz[32];
|
||||
ConvertUInt32ToString(index + 1, sz);
|
||||
UString s = sz;
|
||||
UString s(sz);
|
||||
if (!item.Name.IsEmpty())
|
||||
{
|
||||
s += L'.';
|
||||
s += '.';
|
||||
s += item.Name;
|
||||
}
|
||||
if (!item.Extension.IsEmpty())
|
||||
{
|
||||
s += L'.';
|
||||
s += '.';
|
||||
s += item.Extension;
|
||||
}
|
||||
prop = s; break;
|
||||
@@ -583,7 +583,7 @@ HRESULT CArc::GetItemPathToParent(UInt32 index, UInt32 parent, UStringVector &pa
|
||||
{
|
||||
{
|
||||
UString &s2 = parts[parts.Size() - 2];
|
||||
s2 += L':';
|
||||
s2 += ':';
|
||||
s2 += parts.Back();
|
||||
}
|
||||
parts.DeleteBack();
|
||||
@@ -733,7 +733,7 @@ HRESULT CArc::GetDefaultItemPath(UInt32 index, UString &result) const
|
||||
RINOK(Archive->GetProperty(index, kpidExtension, &prop));
|
||||
if (prop.vt == VT_BSTR)
|
||||
{
|
||||
result += L'.';
|
||||
result += '.';
|
||||
result += prop.bstrVal;
|
||||
}
|
||||
else if (prop.vt != VT_EMPTY)
|
||||
@@ -1020,10 +1020,11 @@ static void MakeCheckOrder(CCodecs *codecs,
|
||||
|
||||
#ifdef UNDER_CE
|
||||
static const unsigned kNumHashBytes = 1;
|
||||
#define HASH_VAL(buf, pos) ((buf)[pos])
|
||||
#define HASH_VAL(buf) ((buf)[0])
|
||||
#else
|
||||
static const unsigned kNumHashBytes = 2;
|
||||
#define HASH_VAL(buf, pos) ((buf)[pos] | ((UInt32)(buf)[pos + 1] << 8))
|
||||
// #define HASH_VAL(buf) ((buf)[0] | ((UInt32)(buf)[1] << 8))
|
||||
#define HASH_VAL(buf) GetUi16(buf)
|
||||
#endif
|
||||
|
||||
|
||||
@@ -2318,7 +2319,7 @@ HRESULT CArc::OpenStream2(const COpenOptions &op)
|
||||
continue;
|
||||
}
|
||||
thereAreHandlersForSearch = true;
|
||||
UInt32 v = HASH_VAL(sig, 0);
|
||||
UInt32 v = HASH_VAL(sig);
|
||||
unsigned sigIndex = arc2sig[(unsigned)index] + k;
|
||||
prevs[sigIndex] = hash[v];
|
||||
hash[v] = (Byte)sigIndex;
|
||||
@@ -2441,6 +2442,9 @@ HRESULT CArc::OpenStream2(const COpenOptions &op)
|
||||
}
|
||||
}
|
||||
|
||||
if (bytesInBuf <= (size_t)posInBuf)
|
||||
break;
|
||||
|
||||
bool useOffsetCallback = false;
|
||||
if (openCallback_Offset)
|
||||
{
|
||||
@@ -2490,17 +2494,19 @@ HRESULT CArc::OpenStream2(const COpenOptions &op)
|
||||
scanSize++;
|
||||
|
||||
const Byte *buf = byteBuffer + (size_t)posInBuf;
|
||||
const Byte *bufLimit = buf + scanSize;
|
||||
size_t ppp = 0;
|
||||
|
||||
if (!needCheckStartOpen)
|
||||
{
|
||||
for (; ppp < scanSize && hash[HASH_VAL(buf, ppp)] == 0xFF; ppp++);
|
||||
for (; buf < bufLimit && hash[HASH_VAL(buf)] == 0xFF; buf++);
|
||||
ppp = buf - (byteBuffer + (size_t)posInBuf);
|
||||
pos += ppp;
|
||||
if (ppp == scanSize)
|
||||
if (buf == bufLimit)
|
||||
continue;
|
||||
}
|
||||
|
||||
UInt32 v = HASH_VAL(buf, ppp);
|
||||
UInt32 v = HASH_VAL(buf);
|
||||
bool nextNeedCheckStartOpen = true;
|
||||
unsigned i = hash[v];
|
||||
unsigned indexOfDifficult = 0;
|
||||
@@ -2540,7 +2546,7 @@ HRESULT CArc::OpenStream2(const COpenOptions &op)
|
||||
const CByteBuffer &sig = ai.Signatures[sigIndex];
|
||||
|
||||
if (ppp + sig.Size() > availSize
|
||||
|| !TestSignature(buf + ppp, sig, sig.Size()))
|
||||
|| !TestSignature(buf, sig, sig.Size()))
|
||||
continue;
|
||||
// printf("\nSignature OK: %10S %8x %5d", (const wchar_t *)ai.Name, (int)pos, (int)(pos - prevPos));
|
||||
// prevPos = pos;
|
||||
@@ -2947,10 +2953,10 @@ HRESULT CArc::OpenStream(const COpenOptions &op)
|
||||
#ifdef _SFX
|
||||
|
||||
#ifdef _WIN32
|
||||
static const char *k_ExeExt = ".exe";
|
||||
#define k_ExeExt ".exe"
|
||||
static const unsigned k_ExeExt_Len = 4;
|
||||
#else
|
||||
static const char *k_ExeExt = "";
|
||||
#define k_ExeExt ""
|
||||
static const unsigned k_ExeExt_Len = 0;
|
||||
#endif
|
||||
|
||||
@@ -3013,10 +3019,10 @@ HRESULT CArc::OpenStreamOrFile(COpenOptions &op)
|
||||
if (ai.IsSplit())
|
||||
continue;
|
||||
UString path3 = path2;
|
||||
path3 += L'.';
|
||||
path3 += '.';
|
||||
path3 += ai.GetMainExt(); // "7z" for SFX.
|
||||
Path = path3;
|
||||
Path.AddAscii(".001");
|
||||
Path += ".001";
|
||||
bool isOk = op.callbackSpec->SetSecondFileInfo(us2fs(Path));
|
||||
if (!isOk)
|
||||
{
|
||||
|
||||
@@ -83,18 +83,17 @@ void ConvertWinAttribToString(char *s, UInt32 wa) throw()
|
||||
}
|
||||
}
|
||||
|
||||
void ConvertPropertyToShortString(char *dest, const PROPVARIANT &prop, PROPID propID, bool full) throw()
|
||||
void ConvertPropertyToShortString2(char *dest, const PROPVARIANT &prop, PROPID propID, int level) throw()
|
||||
{
|
||||
*dest = 0;
|
||||
|
||||
if (prop.vt == VT_FILETIME)
|
||||
{
|
||||
FILETIME localFileTime;
|
||||
if ((prop.filetime.dwHighDateTime == 0 &&
|
||||
prop.filetime.dwLowDateTime == 0) ||
|
||||
!::FileTimeToLocalFileTime(&prop.filetime, &localFileTime))
|
||||
const FILETIME &ft = prop.filetime;
|
||||
if ((ft.dwHighDateTime == 0 &&
|
||||
ft.dwLowDateTime == 0))
|
||||
return;
|
||||
ConvertFileTimeToString(localFileTime, dest, true, full);
|
||||
ConvertUtcFileTimeToString(prop.filetime, dest, level);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -158,7 +157,7 @@ void ConvertPropertyToShortString(char *dest, const PROPVARIANT &prop, PROPID pr
|
||||
ConvertPropVariantToShortString(prop, dest);
|
||||
}
|
||||
|
||||
void ConvertPropertyToString(UString &dest, const PROPVARIANT &prop, PROPID propID, bool full)
|
||||
void ConvertPropertyToString2(UString &dest, const PROPVARIANT &prop, PROPID propID, int level)
|
||||
{
|
||||
if (prop.vt == VT_BSTR)
|
||||
{
|
||||
@@ -166,8 +165,8 @@ void ConvertPropertyToString(UString &dest, const PROPVARIANT &prop, PROPID prop
|
||||
return;
|
||||
}
|
||||
char temp[64];
|
||||
ConvertPropertyToShortString(temp, prop, propID, full);
|
||||
dest.SetFromAscii(temp);
|
||||
ConvertPropertyToShortString2(temp, prop, propID, level);
|
||||
dest = temp;
|
||||
}
|
||||
|
||||
static inline unsigned GetHex(unsigned v)
|
||||
@@ -349,13 +348,9 @@ static void ParseSid(AString &s, const Byte *p, UInt32 lim, UInt32 &sidSize)
|
||||
}
|
||||
}
|
||||
|
||||
char sz[16];
|
||||
s += "S-1-";
|
||||
if (p[2] == 0 && p[3] == 0)
|
||||
{
|
||||
ConvertUInt32ToString(authority, sz);
|
||||
s += sz;
|
||||
}
|
||||
s.Add_UInt32(authority);
|
||||
else
|
||||
{
|
||||
s += "0x";
|
||||
@@ -365,8 +360,7 @@ static void ParseSid(AString &s, const Byte *p, UInt32 lim, UInt32 &sidSize)
|
||||
for (UInt32 i = 0; i < num; i++)
|
||||
{
|
||||
s += '-';
|
||||
ConvertUInt32ToString(Get32(p + 8 + i * 4), sz);
|
||||
s += sz;
|
||||
s.Add_UInt32(Get32(p + 8 + i * 4));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -536,11 +530,11 @@ bool ConvertNtReparseToString(const Byte *data, UInt32 size, UString &s)
|
||||
if (attr.Parse(data, size))
|
||||
{
|
||||
if (!attr.IsSymLink())
|
||||
s.AddAscii("Junction: ");
|
||||
s += "Junction: ";
|
||||
s += attr.GetPath();
|
||||
if (!attr.IsOkNamePair())
|
||||
{
|
||||
s.AddAscii(" : ");
|
||||
s += " : ";
|
||||
s += attr.PrintName;
|
||||
}
|
||||
return true;
|
||||
@@ -557,7 +551,7 @@ bool ConvertNtReparseToString(const Byte *data, UInt32 size, UString &s)
|
||||
|
||||
char hex[16];
|
||||
ConvertUInt32ToHex8Digits(tag, hex);
|
||||
s.AddAscii(hex);
|
||||
s += hex;
|
||||
s.Add_Space();
|
||||
|
||||
data += 8;
|
||||
@@ -565,8 +559,8 @@ bool ConvertNtReparseToString(const Byte *data, UInt32 size, UString &s)
|
||||
for (UInt32 i = 0; i < len; i++)
|
||||
{
|
||||
unsigned b = ((const Byte *)data)[i];
|
||||
s += (wchar_t)GetHex((b >> 4) & 0xF);
|
||||
s += (wchar_t)GetHex(b & 0xF);
|
||||
s += (char)GetHex((b >> 4) & 0xF);
|
||||
s += (char)GetHex(b & 0xF);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
#include "../../../Common/MyString.h"
|
||||
|
||||
// provide at least 64 bytes for buffer including zero-end
|
||||
void ConvertPropertyToShortString(char *dest, const PROPVARIANT &propVariant, PROPID propID, bool full = true) throw();
|
||||
void ConvertPropertyToString(UString &dest, const PROPVARIANT &propVariant, PROPID propID, bool full = true);
|
||||
void ConvertPropertyToShortString2(char *dest, const PROPVARIANT &propVariant, PROPID propID, int level = 0) throw();
|
||||
void ConvertPropertyToString2(UString &dest, const PROPVARIANT &propVariant, PROPID propID, int level = 0);
|
||||
|
||||
bool ConvertNtReparseToString(const Byte *data, UInt32 size, UString &s);
|
||||
void ConvertNtSecureToString(const Byte *data, UInt32 size, AString &s);
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
#include "Update.h"
|
||||
|
||||
#include "../../../Common/IntToString.h"
|
||||
#include "../../../Common/StringConvert.h"
|
||||
|
||||
#include "../../../Windows/DLL.h"
|
||||
@@ -30,16 +29,19 @@
|
||||
#include "TempFiles.h"
|
||||
#include "UpdateCallback.h"
|
||||
|
||||
static const char *kUpdateIsNotSupoorted =
|
||||
static const char * const kUpdateIsNotSupoorted =
|
||||
"update operations are not supported for this archive";
|
||||
|
||||
static const char * const kUpdateIsNotSupoorted_MultiVol =
|
||||
"Updating for multivolume archives is not implemented";
|
||||
|
||||
using namespace NWindows;
|
||||
using namespace NCOM;
|
||||
using namespace NFile;
|
||||
using namespace NDir;
|
||||
using namespace NName;
|
||||
|
||||
static CFSTR kTempFolderPrefix = FTEXT("7zE");
|
||||
static CFSTR const kTempFolderPrefix = FTEXT("7zE");
|
||||
|
||||
|
||||
void CUpdateErrorInfo::SetFromLastError(const char *message)
|
||||
@@ -60,7 +62,8 @@ static bool DeleteEmptyFolderAndEmptySubFolders(const FString &path)
|
||||
NFind::CFileInfo fileInfo;
|
||||
FString pathPrefix = path + FCHAR_PATH_SEPARATOR;
|
||||
{
|
||||
NFind::CEnumerator enumerator(pathPrefix + FCHAR_ANY_MASK);
|
||||
NFind::CEnumerator enumerator;
|
||||
enumerator.SetDirPrefix(pathPrefix);
|
||||
while (enumerator.Next(fileInfo))
|
||||
{
|
||||
if (fileInfo.IsDir())
|
||||
@@ -156,7 +159,7 @@ bool COutMultiVolStream::SetMTime(const FILETIME *mTime)
|
||||
|
||||
STDMETHODIMP COutMultiVolStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
|
||||
{
|
||||
if (processedSize != NULL)
|
||||
if (processedSize)
|
||||
*processedSize = 0;
|
||||
while (size > 0)
|
||||
{
|
||||
@@ -164,9 +167,8 @@ STDMETHODIMP COutMultiVolStream::Write(const void *data, UInt32 size, UInt32 *pr
|
||||
{
|
||||
CAltStreamInfo altStream;
|
||||
|
||||
FChar temp[16];
|
||||
ConvertUInt32ToString(_streamIndex + 1, temp);
|
||||
FString name = temp;
|
||||
FString name;
|
||||
name.Add_UInt32(_streamIndex + 1);
|
||||
while (name.Len() < 3)
|
||||
name.InsertAtFront(FTEXT('0'));
|
||||
name.Insert(0, Prefix);
|
||||
@@ -218,7 +220,7 @@ STDMETHODIMP COutMultiVolStream::Write(const void *data, UInt32 size, UInt32 *pr
|
||||
_length = _absPos;
|
||||
if (_offsetPos > altStream.RealSize)
|
||||
altStream.RealSize = _offsetPos;
|
||||
if (processedSize != NULL)
|
||||
if (processedSize)
|
||||
*processedSize += realProcessed;
|
||||
if (altStream.Pos == volSize)
|
||||
{
|
||||
@@ -243,7 +245,7 @@ STDMETHODIMP COutMultiVolStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *n
|
||||
case STREAM_SEEK_END: _absPos = _length + offset; break;
|
||||
}
|
||||
_offsetPos = _absPos;
|
||||
if (newPosition != NULL)
|
||||
if (newPosition)
|
||||
*newPosition = _absPos;
|
||||
_streamIndex = 0;
|
||||
return S_OK;
|
||||
@@ -316,7 +318,7 @@ UString CArchivePath::GetFinalPath() const
|
||||
UString path = GetPathWithoutExt();
|
||||
if (!BaseExtension.IsEmpty())
|
||||
{
|
||||
path += L'.';
|
||||
path += '.';
|
||||
path += BaseExtension;
|
||||
}
|
||||
return path;
|
||||
@@ -327,7 +329,7 @@ UString CArchivePath::GetFinalVolPath() const
|
||||
UString path = GetPathWithoutExt();
|
||||
if (!BaseExtension.IsEmpty())
|
||||
{
|
||||
path += L'.';
|
||||
path += '.';
|
||||
path += VolExtension;
|
||||
}
|
||||
return path;
|
||||
@@ -339,17 +341,17 @@ FString CArchivePath::GetTempPath() const
|
||||
path += us2fs(Name);
|
||||
if (!BaseExtension.IsEmpty())
|
||||
{
|
||||
path += FTEXT('.');
|
||||
path += '.';
|
||||
path += us2fs(BaseExtension);
|
||||
}
|
||||
path.AddAscii(".tmp");
|
||||
path += ".tmp";
|
||||
path += TempPostfix;
|
||||
return path;
|
||||
}
|
||||
|
||||
static const wchar_t *kDefaultArcType = L"7z";
|
||||
static const wchar_t *kDefaultArcExt = L"7z";
|
||||
static const char *kSFXExtension =
|
||||
static const char * const kDefaultArcType = "7z";
|
||||
static const char * const kDefaultArcExt = "7z";
|
||||
static const char * const kSFXExtension =
|
||||
#ifdef _WIN32
|
||||
"exe";
|
||||
#else
|
||||
@@ -398,7 +400,7 @@ bool CUpdateOptions::SetArcPath(const CCodecs *codecs, const UString &arcPath)
|
||||
}
|
||||
UString ext = typeExt;
|
||||
if (SfxMode)
|
||||
ext.SetFromAscii(kSFXExtension);
|
||||
ext = kSFXExtension;
|
||||
ArchivePath.BaseExtension = ext;
|
||||
ArchivePath.VolExtension = typeExt;
|
||||
ArchivePath.ParseFromPath(arcPath, ArcNameMode);
|
||||
@@ -412,19 +414,43 @@ bool CUpdateOptions::SetArcPath(const CCodecs *codecs, const UString &arcPath)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
struct CUpdateProduceCallbackImp: public IUpdateProduceCallback
|
||||
{
|
||||
const CObjectVector<CArcItem> *_arcItems;
|
||||
IUpdateCallbackUI *_callback;
|
||||
CDirItemsStat *_stat;
|
||||
|
||||
CUpdateProduceCallbackImp(
|
||||
const CObjectVector<CArcItem> *a,
|
||||
CDirItemsStat *stat,
|
||||
IUpdateCallbackUI *callback):
|
||||
_arcItems(a),
|
||||
_stat(stat),
|
||||
_callback(callback) {}
|
||||
|
||||
CUpdateProduceCallbackImp(const CObjectVector<CArcItem> *a,
|
||||
IUpdateCallbackUI *callback): _arcItems(a), _callback(callback) {}
|
||||
virtual HRESULT ShowDeleteFile(unsigned arcIndex);
|
||||
};
|
||||
|
||||
|
||||
HRESULT CUpdateProduceCallbackImp::ShowDeleteFile(unsigned arcIndex)
|
||||
{
|
||||
const CArcItem &ai = (*_arcItems)[arcIndex];
|
||||
{
|
||||
CDirItemsStat &stat = *_stat;
|
||||
if (ai.IsDir)
|
||||
stat.NumDirs++;
|
||||
else if (ai.IsAltStream)
|
||||
{
|
||||
stat.NumAltStreams++;
|
||||
stat.AltStreamsSize += ai.Size;
|
||||
}
|
||||
else
|
||||
{
|
||||
stat.NumFiles++;
|
||||
stat.FilesSize += ai.Size;
|
||||
}
|
||||
}
|
||||
return _callback->ShowDeleteFile(ai.Name, ai.IsDir);
|
||||
}
|
||||
|
||||
@@ -562,6 +588,8 @@ static HRESULT Compress(
|
||||
|
||||
UStringVector newNames;
|
||||
|
||||
CArcToDoStat stat2;
|
||||
|
||||
if (options.RenamePairs.Size() != 0)
|
||||
{
|
||||
FOR_VECTOR (i, arcItems)
|
||||
@@ -595,7 +623,7 @@ static HRESULT Compress(
|
||||
if (rp.GetNewPath(false, mainName, dest))
|
||||
{
|
||||
needRename = true;
|
||||
dest += L':';
|
||||
dest += ':';
|
||||
dest += ai.Name.Ptr(colonPos + 1);
|
||||
break;
|
||||
}
|
||||
@@ -620,17 +648,51 @@ static HRESULT Compress(
|
||||
{
|
||||
CRecordVector<CUpdatePair> updatePairs;
|
||||
GetUpdatePairInfoList(dirItems, arcItems, fileTimeType, updatePairs); // must be done only once!!!
|
||||
CUpdateProduceCallbackImp upCallback(&arcItems, callback);
|
||||
CUpdateProduceCallbackImp upCallback(&arcItems, &stat2.DeleteData, callback);
|
||||
|
||||
UpdateProduce(updatePairs, actionSet, updatePairs2, isUpdatingItself ? &upCallback : NULL);
|
||||
}
|
||||
|
||||
{
|
||||
UInt32 numItems = 0;
|
||||
FOR_VECTOR (i, updatePairs2)
|
||||
if (updatePairs2[i].NewData)
|
||||
numItems++;
|
||||
RINOK(callback->SetNumItems(numItems));
|
||||
{
|
||||
const CUpdatePair2 &up = updatePairs2[i];
|
||||
if (up.NewData)
|
||||
{
|
||||
CDirItemsStat &stat = stat2.NewData;
|
||||
const CDirItem &di = dirItems.Items[up.DirIndex];
|
||||
if (di.IsDir())
|
||||
stat.NumDirs++;
|
||||
else if (di.IsAltStream)
|
||||
{
|
||||
stat.NumAltStreams++;
|
||||
stat.AltStreamsSize += di.Size;
|
||||
}
|
||||
else
|
||||
{
|
||||
stat.NumFiles++;
|
||||
stat.FilesSize += di.Size;
|
||||
}
|
||||
}
|
||||
else if (up.ArcIndex >= 0)
|
||||
{
|
||||
CDirItemsStat &stat = stat2.OldData;
|
||||
const CArcItem &ai = arcItems[up.ArcIndex];
|
||||
if (ai.IsDir)
|
||||
stat.NumDirs++;
|
||||
else if (ai.IsAltStream)
|
||||
{
|
||||
stat.NumAltStreams++;
|
||||
stat.AltStreamsSize += ai.Size;
|
||||
}
|
||||
else
|
||||
{
|
||||
stat.NumFiles++;
|
||||
stat.FilesSize += ai.Size;
|
||||
}
|
||||
}
|
||||
}
|
||||
RINOK(callback->SetNumItems(stat2));
|
||||
}
|
||||
|
||||
CArchiveUpdateCallback *updateCallbackSpec = new CArchiveUpdateCallback;
|
||||
@@ -698,9 +760,8 @@ static HRESULT Compress(
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
FChar s[16];
|
||||
ConvertUInt32ToString(i, s);
|
||||
archivePath.TempPostfix = s;
|
||||
archivePath.TempPostfix.Empty();
|
||||
archivePath.TempPostfix.Add_UInt32(i);
|
||||
}
|
||||
realPath = archivePath.GetTempPath();
|
||||
}
|
||||
@@ -734,7 +795,7 @@ static HRESULT Compress(
|
||||
outStream = outSeekStream;
|
||||
volStreamSpec->Sizes = options.VolumesSizes;
|
||||
volStreamSpec->Prefix = us2fs(archivePath.GetFinalVolPath());
|
||||
volStreamSpec->Prefix += FTEXT('.');
|
||||
volStreamSpec->Prefix += '.';
|
||||
volStreamSpec->TempFiles = &tempFiles;
|
||||
volStreamSpec->Init();
|
||||
|
||||
@@ -742,7 +803,7 @@ static HRESULT Compress(
|
||||
updateCallbackSpec->VolumesSizes = volumesSizes;
|
||||
updateCallbackSpec->VolName = archivePath.Prefix + archivePath.Name;
|
||||
if (!archivePath.VolExtension.IsEmpty())
|
||||
updateCallbackSpec->VolExt = UString(L'.') + archivePath.VolExtension;
|
||||
updateCallbackSpec->VolExt = UString('.') + archivePath.VolExtension;
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -1025,7 +1086,7 @@ HRESULT UpdateArchive(
|
||||
if (options.SfxMode)
|
||||
{
|
||||
CProperty property;
|
||||
property.Name.SetFromAscii("rsfx");
|
||||
property.Name = "rsfx";
|
||||
options.MethodMode.Properties.Add(property);
|
||||
if (options.SfxModule.IsEmpty())
|
||||
{
|
||||
@@ -1058,7 +1119,15 @@ HRESULT UpdateArchive(
|
||||
!options.SetArcPath(codecs, cmdArcPath2))
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
const UString arcPath = options.ArchivePath.GetFinalPath();
|
||||
|
||||
UString arcPath = options.ArchivePath.GetFinalPath();
|
||||
|
||||
if (!options.VolumesSizes.IsEmpty())
|
||||
{
|
||||
arcPath = options.ArchivePath.GetFinalVolPath();
|
||||
arcPath += '.';
|
||||
arcPath += "001";
|
||||
}
|
||||
|
||||
if (cmdArcPath2.IsEmpty())
|
||||
{
|
||||
@@ -1085,7 +1154,12 @@ HRESULT UpdateArchive(
|
||||
if (fi.IsDevice)
|
||||
return E_NOTIMPL;
|
||||
if (options.VolumesSizes.Size() > 0)
|
||||
{
|
||||
errorInfo.FileNames.Add(us2fs(arcPath));
|
||||
errorInfo.SystemError = (DWORD)E_NOTIMPL;
|
||||
errorInfo.Message = kUpdateIsNotSupoorted_MultiVol;
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
CObjectVector<COpenType> types2;
|
||||
// change it.
|
||||
if (options.MethodMode.Type_Defined)
|
||||
@@ -1122,7 +1196,7 @@ HRESULT UpdateArchive(
|
||||
if (arcLink.VolumePaths.Size() > 1)
|
||||
{
|
||||
errorInfo.SystemError = (DWORD)E_NOTIMPL;
|
||||
errorInfo.Message = "Updating for multivolume archives is not implemented";
|
||||
errorInfo.Message = kUpdateIsNotSupoorted_MultiVol;
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
@@ -1147,7 +1221,7 @@ HRESULT UpdateArchive(
|
||||
|
||||
if (options.MethodMode.Type.FormatIndex < 0)
|
||||
{
|
||||
options.MethodMode.Type.FormatIndex = codecs->FindFormatForArchiveType(kDefaultArcType);
|
||||
options.MethodMode.Type.FormatIndex = codecs->FindFormatForArchiveType((UString)kDefaultArcType);
|
||||
if (options.MethodMode.Type.FormatIndex < 0)
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
@@ -1218,7 +1292,7 @@ HRESULT UpdateArchive(
|
||||
{
|
||||
NFind::CFileInfo fi;
|
||||
FString prefix = us2fs(censor.Pairs[0].Prefix);
|
||||
prefix += FTEXT('.');
|
||||
prefix += '.';
|
||||
// UString prefix = censor.Pairs[0].Prefix;
|
||||
/*
|
||||
if (prefix.Back() == WCHAR_PATH_SEPARATOR)
|
||||
@@ -1353,7 +1427,7 @@ HRESULT UpdateArchive(
|
||||
|
||||
if (options.StdOutMode)
|
||||
{
|
||||
name.SetFromAscii("stdout");
|
||||
name = "stdout";
|
||||
isUpdating = thereIsInArchive;
|
||||
}
|
||||
else
|
||||
@@ -1461,10 +1535,10 @@ HRESULT UpdateArchive(
|
||||
|
||||
for (i = 0; i < fullPaths.Size(); i++)
|
||||
{
|
||||
UString arcPath2 = fs2us(fullPaths[i]);
|
||||
UString fileName = ExtractFileNameFromPath(arcPath2);
|
||||
AString path = GetAnsiString(arcPath2);
|
||||
AString name = GetAnsiString(fileName);
|
||||
const UString arcPath2 = fs2us(fullPaths[i]);
|
||||
const UString fileName = ExtractFileNameFromPath(arcPath2);
|
||||
const AString path (GetAnsiString(arcPath2));
|
||||
const AString name (GetAnsiString(fileName));
|
||||
// Warning!!! MAPISendDocuments function changes Current directory
|
||||
// fnSend(0, ";", (LPSTR)(LPCSTR)path, (LPSTR)(LPCSTR)name, 0);
|
||||
|
||||
@@ -1479,7 +1553,7 @@ HRESULT UpdateArchive(
|
||||
m.nFileCount = 1;
|
||||
m.lpFiles = &f;
|
||||
|
||||
const AString addr = GetAnsiString(options.EMailAddress);
|
||||
const AString addr (GetAnsiString(options.EMailAddress));
|
||||
MapiRecipDesc rec;
|
||||
if (!addr.IsEmpty())
|
||||
{
|
||||
|
||||
@@ -51,6 +51,8 @@ CArchiveUpdateCallback::CArchiveUpdateCallback():
|
||||
ArcItems(NULL),
|
||||
UpdatePairs(NULL),
|
||||
NewNames(NULL),
|
||||
CommentIndex(-1),
|
||||
Comment(NULL),
|
||||
|
||||
ShareForWrite(false),
|
||||
StdInMode(false),
|
||||
@@ -300,7 +302,7 @@ static UString GetRelativePath(const UString &to, const UString &from)
|
||||
unsigned k;
|
||||
|
||||
for (k = i + 1; k < partsFrom.Size(); k++)
|
||||
s += L".." WSTRING_PATH_SEPARATOR;
|
||||
s += ".." STRING_PATH_SEPARATOR;
|
||||
|
||||
for (k = i; k < partsTo.Size(); k++)
|
||||
{
|
||||
@@ -396,6 +398,11 @@ STDMETHODIMP CArchiveUpdateCallback::GetProperty(UInt32 index, PROPID propID, PR
|
||||
}
|
||||
else if (propID == kpidPath && up.NewNameIndex >= 0)
|
||||
prop = (*NewNames)[up.NewNameIndex];
|
||||
else if (propID == kpidComment
|
||||
&& CommentIndex >= 0
|
||||
&& (unsigned)CommentIndex == index
|
||||
&& Comment)
|
||||
prop = *Comment;
|
||||
else if (propID == kpidShortName && up.NewNameIndex >= 0 && up.IsMainRenameItem)
|
||||
{
|
||||
// we can generate new ShortName here;
|
||||
@@ -690,13 +697,13 @@ STDMETHODIMP CArchiveUpdateCallback::GetVolumeSize(UInt32 index, UInt64 *size)
|
||||
STDMETHODIMP CArchiveUpdateCallback::GetVolumeStream(UInt32 index, ISequentialOutStream **volumeStream)
|
||||
{
|
||||
COM_TRY_BEGIN
|
||||
FChar temp[16];
|
||||
char temp[16];
|
||||
ConvertUInt32ToString(index + 1, temp);
|
||||
FString res = temp;
|
||||
FString res (temp);
|
||||
while (res.Len() < 2)
|
||||
res.InsertAtFront(FTEXT('0'));
|
||||
FString fileName = VolName;
|
||||
fileName += FTEXT('.');
|
||||
fileName += '.';
|
||||
fileName += res;
|
||||
fileName += VolExt;
|
||||
COutFileStream *streamSpec = new COutFileStream;
|
||||
|
||||
@@ -15,6 +15,18 @@
|
||||
|
||||
#include "OpenArchive.h"
|
||||
|
||||
struct CArcToDoStat
|
||||
{
|
||||
CDirItemsStat NewData;
|
||||
CDirItemsStat OldData;
|
||||
CDirItemsStat DeleteData;
|
||||
|
||||
UInt64 Get_NumDataItems_Total() const
|
||||
{
|
||||
return NewData.Get_NumDataItems() + OldData.Get_NumDataItems();
|
||||
}
|
||||
};
|
||||
|
||||
#define INTERFACE_IUpdateCallbackUI(x) \
|
||||
virtual HRESULT WriteSfx(const wchar_t *name, UInt64 size) x; \
|
||||
virtual HRESULT SetTotal(UInt64 size) x; \
|
||||
@@ -22,7 +34,7 @@
|
||||
virtual HRESULT SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize) x; \
|
||||
virtual HRESULT CheckBreak() x; \
|
||||
/* virtual HRESULT Finalize() x; */ \
|
||||
virtual HRESULT SetNumItems(UInt64 numItems) x; \
|
||||
virtual HRESULT SetNumItems(const CArcToDoStat &stat) x; \
|
||||
virtual HRESULT GetStream(const wchar_t *name, bool isDir, bool isAnti, UInt32 mode) x; \
|
||||
virtual HRESULT OpenFileError(const FString &path, DWORD systemError) x; \
|
||||
virtual HRESULT ReadingFileError(const FString &path, DWORD systemError) x; \
|
||||
@@ -120,6 +132,8 @@ public:
|
||||
const CObjectVector<CArcItem> *ArcItems;
|
||||
const CRecordVector<CUpdatePair2> *UpdatePairs;
|
||||
const UStringVector *NewNames;
|
||||
int CommentIndex;
|
||||
const UString *Comment;
|
||||
|
||||
bool ShareForWrite;
|
||||
bool StdInMode;
|
||||
|
||||
@@ -38,14 +38,13 @@ static int MyCompareTime(NFileTimeType::EEnum fileTimeType, const FILETIME &time
|
||||
throw 4191618;
|
||||
}
|
||||
|
||||
static const char *k_Duplicate_inArc_Message = "Duplicate filename in archive:";
|
||||
static const char *k_Duplicate_inDir_Message = "Duplicate filename on disk:";
|
||||
static const char *k_NotCensoredCollision_Message = "Internal file name collision (file on disk, file in archive):";
|
||||
static const char * const k_Duplicate_inArc_Message = "Duplicate filename in archive:";
|
||||
static const char * const k_Duplicate_inDir_Message = "Duplicate filename on disk:";
|
||||
static const char * const k_NotCensoredCollision_Message = "Internal file name collision (file on disk, file in archive):";
|
||||
|
||||
static void ThrowError(const char *message, const UString &s1, const UString &s2)
|
||||
{
|
||||
UString m;
|
||||
m.SetFromAscii(message);
|
||||
UString m (message);
|
||||
m.Add_LF(); m += s1;
|
||||
m.Add_LF(); m += s2;
|
||||
throw m;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
using namespace NUpdateArchive;
|
||||
|
||||
static const char *kUpdateActionSetCollision = "Internal collision in update action set";
|
||||
static const char * const kUpdateActionSetCollision = "Internal collision in update action set";
|
||||
|
||||
void UpdateProduce(
|
||||
const CRecordVector<CUpdatePair> &updatePairs,
|
||||
|
||||
@@ -16,9 +16,9 @@ using namespace NRegistry;
|
||||
static NSynchronization::CCriticalSection g_CS;
|
||||
#define CS_LOCK NSynchronization::CCriticalSectionLock lock(g_CS);
|
||||
|
||||
static const TCHAR *kCuPrefix = TEXT("Software") TEXT(STRING_PATH_SEPARATOR) TEXT("7-Zip") TEXT(STRING_PATH_SEPARATOR);
|
||||
static LPCTSTR const kCuPrefix = TEXT("Software") TEXT(STRING_PATH_SEPARATOR) TEXT("7-Zip") TEXT(STRING_PATH_SEPARATOR);
|
||||
|
||||
static CSysString GetKeyPath(const CSysString &path) { return kCuPrefix + path; }
|
||||
static CSysString GetKeyPath(LPCTSTR path) { return kCuPrefix + (CSysString)path; }
|
||||
|
||||
static LONG OpenMainKey(CKey &key, LPCTSTR keyName)
|
||||
{
|
||||
@@ -51,16 +51,16 @@ static void Key_Get_BoolPair_true(CKey &key, LPCTSTR name, CBoolPair &b)
|
||||
namespace NExtract
|
||||
{
|
||||
|
||||
static const TCHAR *kKeyName = TEXT("Extraction");
|
||||
static LPCTSTR const kKeyName = TEXT("Extraction");
|
||||
|
||||
static const TCHAR *kExtractMode = TEXT("ExtractMode");
|
||||
static const TCHAR *kOverwriteMode = TEXT("OverwriteMode");
|
||||
static const TCHAR *kShowPassword = TEXT("ShowPassword");
|
||||
static const TCHAR *kPathHistory = TEXT("PathHistory");
|
||||
static const TCHAR *kSplitDest = TEXT("SplitDest");
|
||||
static const TCHAR *kElimDup = TEXT("ElimDup");
|
||||
// static const TCHAR *kAltStreams = TEXT("AltStreams");
|
||||
static const TCHAR *kNtSecur = TEXT("Security");
|
||||
static LPCTSTR const kExtractMode = TEXT("ExtractMode");
|
||||
static LPCTSTR const kOverwriteMode = TEXT("OverwriteMode");
|
||||
static LPCTSTR const kShowPassword = TEXT("ShowPassword");
|
||||
static LPCTSTR const kPathHistory = TEXT("PathHistory");
|
||||
static LPCTSTR const kSplitDest = TEXT("SplitDest");
|
||||
static LPCTSTR const kElimDup = TEXT("ElimDup");
|
||||
// static LPCTSTR const kAltStreams = TEXT("AltStreams");
|
||||
static LPCTSTR const kNtSecur = TEXT("Security");
|
||||
|
||||
void CInfo::Save() const
|
||||
{
|
||||
@@ -144,30 +144,30 @@ bool Read_ShowPassword()
|
||||
namespace NCompression
|
||||
{
|
||||
|
||||
static const TCHAR *kKeyName = TEXT("Compression");
|
||||
static LPCTSTR const kKeyName = TEXT("Compression");
|
||||
|
||||
static const TCHAR *kArcHistory = TEXT("ArcHistory");
|
||||
static const WCHAR *kArchiver = L"Archiver";
|
||||
static const TCHAR *kShowPassword = TEXT("ShowPassword");
|
||||
static const TCHAR *kEncryptHeaders = TEXT("EncryptHeaders");
|
||||
static LPCTSTR const kArcHistory = TEXT("ArcHistory");
|
||||
static LPCWSTR const kArchiver = L"Archiver";
|
||||
static LPCTSTR const kShowPassword = TEXT("ShowPassword");
|
||||
static LPCTSTR const kEncryptHeaders = TEXT("EncryptHeaders");
|
||||
|
||||
static const TCHAR *kOptionsKeyName = TEXT("Options");
|
||||
static LPCTSTR const kOptionsKeyName = TEXT("Options");
|
||||
|
||||
static const TCHAR *kLevel = TEXT("Level");
|
||||
static const TCHAR *kDictionary = TEXT("Dictionary");
|
||||
static const TCHAR *kOrder = TEXT("Order");
|
||||
static const TCHAR *kBlockSize = TEXT("BlockSize");
|
||||
static const TCHAR *kNumThreads = TEXT("NumThreads");
|
||||
static const WCHAR *kMethod = L"Method";
|
||||
static const WCHAR *kOptions = L"Options";
|
||||
static const WCHAR *kEncryptionMethod = L"EncryptionMethod";
|
||||
static LPCTSTR const kLevel = TEXT("Level");
|
||||
static LPCTSTR const kDictionary = TEXT("Dictionary");
|
||||
static LPCTSTR const kOrder = TEXT("Order");
|
||||
static LPCTSTR const kBlockSize = TEXT("BlockSize");
|
||||
static LPCTSTR const kNumThreads = TEXT("NumThreads");
|
||||
static LPCWSTR const kMethod = L"Method";
|
||||
static LPCWSTR const kOptions = L"Options";
|
||||
static LPCWSTR const kEncryptionMethod = L"EncryptionMethod";
|
||||
|
||||
static const TCHAR *kNtSecur = TEXT("Security");
|
||||
static const TCHAR *kAltStreams = TEXT("AltStreams");
|
||||
static const TCHAR *kHardLinks = TEXT("HardLinks");
|
||||
static const TCHAR *kSymLinks = TEXT("SymLinks");
|
||||
static LPCTSTR const kNtSecur = TEXT("Security");
|
||||
static LPCTSTR const kAltStreams = TEXT("AltStreams");
|
||||
static LPCTSTR const kHardLinks = TEXT("HardLinks");
|
||||
static LPCTSTR const kSymLinks = TEXT("SymLinks");
|
||||
|
||||
static void SetRegString(CKey &key, const WCHAR *name, const UString &value)
|
||||
static void SetRegString(CKey &key, LPCWSTR name, const UString &value)
|
||||
{
|
||||
if (value.IsEmpty())
|
||||
key.DeleteValue(name);
|
||||
@@ -175,7 +175,7 @@ static void SetRegString(CKey &key, const WCHAR *name, const UString &value)
|
||||
key.SetValue(name, value);
|
||||
}
|
||||
|
||||
static void SetRegUInt32(CKey &key, const TCHAR *name, UInt32 value)
|
||||
static void SetRegUInt32(CKey &key, LPCTSTR name, UInt32 value)
|
||||
{
|
||||
if (value == (UInt32)(Int32)-1)
|
||||
key.DeleteValue(name);
|
||||
@@ -183,13 +183,13 @@ static void SetRegUInt32(CKey &key, const TCHAR *name, UInt32 value)
|
||||
key.SetValue(name, value);
|
||||
}
|
||||
|
||||
static void GetRegString(CKey &key, const WCHAR *name, UString &value)
|
||||
static void GetRegString(CKey &key, LPCWSTR name, UString &value)
|
||||
{
|
||||
if (key.QueryValue(name, value) != ERROR_SUCCESS)
|
||||
value.Empty();
|
||||
}
|
||||
|
||||
static void GetRegUInt32(CKey &key, const TCHAR *name, UInt32 &value)
|
||||
static void GetRegUInt32(CKey &key, LPCTSTR name, UInt32 &value)
|
||||
{
|
||||
if (key.QueryValue(name, value) != ERROR_SUCCESS)
|
||||
value = (UInt32)(Int32)-1;
|
||||
@@ -300,13 +300,13 @@ void CInfo::Load()
|
||||
|
||||
}
|
||||
|
||||
static const TCHAR *kOptionsInfoKeyName = TEXT("Options");
|
||||
static LPCTSTR const kOptionsInfoKeyName = TEXT("Options");
|
||||
|
||||
namespace NWorkDir
|
||||
{
|
||||
static const TCHAR *kWorkDirType = TEXT("WorkDirType");
|
||||
static const WCHAR *kWorkDirPath = L"WorkDirPath";
|
||||
static const TCHAR *kTempRemovableOnly = TEXT("TempRemovableOnly");
|
||||
static LPCTSTR const kWorkDirType = TEXT("WorkDirType");
|
||||
static LPCWSTR const kWorkDirPath = L"WorkDirPath";
|
||||
static LPCTSTR const kTempRemovableOnly = TEXT("TempRemovableOnly");
|
||||
|
||||
|
||||
void CInfo::Save()const
|
||||
@@ -352,10 +352,10 @@ void CInfo::Load()
|
||||
|
||||
}
|
||||
|
||||
static const TCHAR *kCascadedMenu = TEXT("CascadedMenu");
|
||||
static const TCHAR *kContextMenu = TEXT("ContextMenu");
|
||||
static const TCHAR *kMenuIcons = TEXT("MenuIcons");
|
||||
static const TCHAR *kElimDup = TEXT("ElimDupExtract");
|
||||
static LPCTSTR const kCascadedMenu = TEXT("CascadedMenu");
|
||||
static LPCTSTR const kContextMenu = TEXT("ContextMenu");
|
||||
static LPCTSTR const kMenuIcons = TEXT("MenuIcons");
|
||||
static LPCTSTR const kElimDup = TEXT("ElimDupExtract");
|
||||
|
||||
void CContextMenuInfo::Save() const
|
||||
{
|
||||
|
||||
@@ -44,7 +44,7 @@ RSC=rc.exe
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /Gr /MD /W4 /WX /GX /O1 /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /D "WIN_LONG_PATH" /D "EXTERNAL_CODECS" /D "_7ZIP_LARGE_PAGES" /D "SUPPORT_DEVICE_FILE" /FAs /Yu"StdAfx.h" /FD /GF /c
|
||||
# ADD CPP /nologo /Gr /MD /W4 /WX /GX /O1 /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /D "WIN_LONG_PATH" /D "EXTERNAL_CODECS" /D "_7ZIP_LARGE_PAGES" /D "SUPPORT_DEVICE_FILE" /FAcs /Yu"StdAfx.h" /FD /GF /c
|
||||
# ADD BASE RSC /l 0x419 /d "NDEBUG"
|
||||
# ADD RSC /l 0x419 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
|
||||
@@ -32,7 +32,7 @@ static HRESULT CheckBreak2()
|
||||
return NConsoleClose::TestBreakSignal() ? E_ABORT : S_OK;
|
||||
}
|
||||
|
||||
static const char *kError = "ERROR: ";
|
||||
static const char * const kError = "ERROR: ";
|
||||
|
||||
|
||||
void CExtractScanConsole::StartScanning()
|
||||
@@ -138,33 +138,33 @@ static NSynchronization::CCriticalSection g_CriticalSection;
|
||||
#endif
|
||||
|
||||
|
||||
static const char *kTestString = "T";
|
||||
static const char *kExtractString = "-";
|
||||
static const char *kSkipString = ".";
|
||||
static const char * const kTestString = "T";
|
||||
static const char * const kExtractString = "-";
|
||||
static const char * const kSkipString = ".";
|
||||
|
||||
// static const char *kCantAutoRename = "can not create file with auto name\n";
|
||||
// static const char *kCantRenameFile = "can not rename existing file\n";
|
||||
// static const char *kCantDeleteOutputFile = "can not delete output file ";
|
||||
// static const char * const kCantAutoRename = "can not create file with auto name\n";
|
||||
// static const char * const kCantRenameFile = "can not rename existing file\n";
|
||||
// static const char * const kCantDeleteOutputFile = "can not delete output file ";
|
||||
|
||||
static const char *kMemoryExceptionMessage = "Can't allocate required memory!";
|
||||
static const char * const kMemoryExceptionMessage = "Can't allocate required memory!";
|
||||
|
||||
static const char *kExtracting = "Extracting archive: ";
|
||||
static const char *kTesting = "Testing archive: ";
|
||||
static const char * const kExtracting = "Extracting archive: ";
|
||||
static const char * const kTesting = "Testing archive: ";
|
||||
|
||||
static const char *kEverythingIsOk = "Everything is Ok";
|
||||
static const char *kNoFiles = "No files to process";
|
||||
static const char * const kEverythingIsOk = "Everything is Ok";
|
||||
static const char * const kNoFiles = "No files to process";
|
||||
|
||||
static const char *kUnsupportedMethod = "Unsupported Method";
|
||||
static const char *kCrcFailed = "CRC Failed";
|
||||
static const char *kCrcFailedEncrypted = "CRC Failed in encrypted file. Wrong password?";
|
||||
static const char *kDataError = "Data Error";
|
||||
static const char *kDataErrorEncrypted = "Data Error in encrypted file. Wrong password?";
|
||||
static const char *kUnavailableData = "Unavailable data";
|
||||
static const char *kUnexpectedEnd = "Unexpected end of data";
|
||||
static const char *kDataAfterEnd = "There are some data after the end of the payload data";
|
||||
static const char *kIsNotArc = "Is not archive";
|
||||
static const char *kHeadersError = "Headers Error";
|
||||
static const char *kWrongPassword = "Wrong password";
|
||||
static const char * const kUnsupportedMethod = "Unsupported Method";
|
||||
static const char * const kCrcFailed = "CRC Failed";
|
||||
static const char * const kCrcFailedEncrypted = "CRC Failed in encrypted file. Wrong password?";
|
||||
static const char * const kDataError = "Data Error";
|
||||
static const char * const kDataErrorEncrypted = "Data Error in encrypted file. Wrong password?";
|
||||
static const char * const kUnavailableData = "Unavailable data";
|
||||
static const char * const kUnexpectedEnd = "Unexpected end of data";
|
||||
static const char * const kDataAfterEnd = "There are some data after the end of the payload data";
|
||||
static const char * const kIsNotArc = "Is not archive";
|
||||
static const char * const kHeadersError = "Headers Error";
|
||||
static const char * const kWrongPassword = "Wrong password";
|
||||
|
||||
static const char * const k_ErrorFlagsMessages[] =
|
||||
{
|
||||
@@ -206,7 +206,7 @@ STDMETHODIMP CExtractCallbackConsole::SetCompleted(const UInt64 *completeValue)
|
||||
return CheckBreak2();
|
||||
}
|
||||
|
||||
static const char *kTab = " ";
|
||||
static const char * const kTab = " ";
|
||||
|
||||
static void PrintFileInfo(CStdOutStream *_so, const wchar_t *path, const FILETIME *ft, const UInt64 *size)
|
||||
{
|
||||
@@ -220,10 +220,8 @@ static void PrintFileInfo(CStdOutStream *_so, const wchar_t *path, const FILETIM
|
||||
if (ft)
|
||||
{
|
||||
char temp[64];
|
||||
FILETIME locTime;
|
||||
if (FileTimeToLocalFileTime(ft, &locTime))
|
||||
if (ConvertFileTimeToString(locTime, temp, true, true))
|
||||
*_so << kTab << "Modified: " << temp << endl;
|
||||
if (ConvertUtcFileTimeToString(*ft, temp, kTimestampPrintLevel_SEC))
|
||||
*_so << kTab << "Modified: " << temp << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,6 +254,8 @@ STDMETHODIMP CExtractCallbackConsole::AskOverwrite(
|
||||
case NUserAnswerMode::kYesAll: *answer = NOverwriteAnswer::kYesToAll; break;
|
||||
case NUserAnswerMode::kYes: *answer = NOverwriteAnswer::kYes; break;
|
||||
case NUserAnswerMode::kAutoRenameAll: *answer = NOverwriteAnswer::kAutoRename; break;
|
||||
case NUserAnswerMode::kEof: return E_ABORT;
|
||||
case NUserAnswerMode::kError: return E_FAIL;
|
||||
default: return E_FAIL;
|
||||
}
|
||||
|
||||
@@ -388,10 +388,8 @@ void SetExtractErrorMessage(Int32 opRes, Int32 encrypted, AString &dest)
|
||||
dest += s;
|
||||
else
|
||||
{
|
||||
char temp[16];
|
||||
ConvertUInt32ToString(opRes, temp);
|
||||
dest += "Error #";
|
||||
dest += temp;
|
||||
dest.Add_UInt32(opRes);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -524,22 +522,22 @@ void PrintErrorFlags(CStdOutStream &so, const char *s, UInt32 errorFlags)
|
||||
void Add_Messsage_Pre_ArcType(UString &s, const char *pre, const wchar_t *arcType)
|
||||
{
|
||||
s.Add_LF();
|
||||
s.AddAscii(pre);
|
||||
s.AddAscii(" as [");
|
||||
s += pre;
|
||||
s += " as [";
|
||||
s += arcType;
|
||||
s.AddAscii("] archive");
|
||||
s += "] archive";
|
||||
}
|
||||
|
||||
void Print_ErrorFormatIndex_Warning(CStdOutStream *_so, const CCodecs *codecs, const CArc &arc)
|
||||
{
|
||||
const CArcErrorInfo &er = arc.ErrorInfo;
|
||||
|
||||
UString s = L"WARNING:\n";
|
||||
UString s ("WARNING:\n");
|
||||
s += arc.Path;
|
||||
if (arc.FormatIndex == er.ErrorFormatIndex)
|
||||
{
|
||||
s.Add_LF();
|
||||
s.AddAscii("The archive is open with offset");
|
||||
s += "The archive is open with offset";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
#include "ConsoleClose.h"
|
||||
#include "HashCon.h"
|
||||
|
||||
static const wchar_t *kEmptyFileAlias = L"[Content]";
|
||||
static const char * const kEmptyFileAlias = "[Content]";
|
||||
|
||||
static const char *kScanningMessage = "Scanning";
|
||||
static const char * const kScanningMessage = "Scanning";
|
||||
|
||||
static HRESULT CheckBreak2()
|
||||
{
|
||||
@@ -168,7 +168,7 @@ HRESULT CHashCallbackConsole::BeforeFirstFile(const CHashBundle &hb)
|
||||
if (PrintSize)
|
||||
{
|
||||
_s.Add_Space();
|
||||
const AString s2 = "Size";
|
||||
const AString s2 ("Size");
|
||||
AddSpaces_if_Positive(_s, (int)kSizeField_Len - (int)s2.Len());
|
||||
_s += s2;
|
||||
}
|
||||
|
||||
@@ -128,14 +128,14 @@ static const char * const kPropIdToName[] =
|
||||
|
||||
static const char kEmptyAttribChar = '.';
|
||||
|
||||
static const char *kListing = "Listing archive: ";
|
||||
static const char * const kListing = "Listing archive: ";
|
||||
|
||||
static const char *kString_Files = "files";
|
||||
static const char *kString_Dirs = "folders";
|
||||
static const char *kString_AltStreams = "alternate streams";
|
||||
static const char *kString_Streams = "streams";
|
||||
static const char * const kString_Files = "files";
|
||||
static const char * const kString_Dirs = "folders";
|
||||
static const char * const kString_AltStreams = "alternate streams";
|
||||
static const char * const kString_Streams = "streams";
|
||||
|
||||
static const char *kError = "ERROR: ";
|
||||
static const char * const kError = "ERROR: ";
|
||||
|
||||
static void GetAttribString(UInt32 wa, bool isDir, bool allAttribs, char *s)
|
||||
{
|
||||
@@ -417,9 +417,8 @@ static void GetPropName(PROPID propID, const wchar_t *name, AString &nameA, UStr
|
||||
nameU = name;
|
||||
else
|
||||
{
|
||||
char s[16];
|
||||
ConvertUInt32ToString(propID, s);
|
||||
nameA = s;
|
||||
nameA.Empty();
|
||||
nameA.Add_UInt32(propID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -429,7 +428,7 @@ void CFieldPrinter::AddProp(const wchar_t *name, PROPID propID, bool isRawProp)
|
||||
f.PropID = propID;
|
||||
f.IsRawProp = isRawProp;
|
||||
GetPropName(propID, name, f.NameA, f.NameU);
|
||||
f.NameU.AddAscii(" = ");
|
||||
f.NameU += " = ";
|
||||
if (!f.NameA.IsEmpty())
|
||||
f.NameA += " = ";
|
||||
else
|
||||
@@ -499,10 +498,7 @@ static void PrintTime(char *dest, const FILETIME *ft)
|
||||
*dest = 0;
|
||||
if (ft->dwLowDateTime == 0 && ft->dwHighDateTime == 0)
|
||||
return;
|
||||
FILETIME locTime;
|
||||
if (!FileTimeToLocalFileTime(ft, &locTime))
|
||||
throw 20121211;
|
||||
ConvertFileTimeToString(locTime, dest, true, true);
|
||||
ConvertUtcFileTimeToString(*ft, dest, kTimestampPrintLevel_SEC);
|
||||
}
|
||||
|
||||
#ifndef _SFX
|
||||
@@ -686,7 +682,7 @@ HRESULT CFieldPrinter::PrintItemInfo(UInt32 index, const CListStat &st)
|
||||
else
|
||||
{
|
||||
char s[64];
|
||||
ConvertPropertyToShortString(s, prop, f.PropID);
|
||||
ConvertPropertyToShortString2(s, prop, f.PropID);
|
||||
if (techMode)
|
||||
g_StdOut << s;
|
||||
else
|
||||
@@ -828,7 +824,7 @@ static void PrintPropPair(CStdOutStream &so, const char *name, const wchar_t *va
|
||||
static void PrintPropertyPair2(CStdOutStream &so, PROPID propID, const wchar_t *name, const CPropVariant &prop)
|
||||
{
|
||||
UString s;
|
||||
ConvertPropertyToString(s, prop, propID);
|
||||
ConvertPropertyToString2(s, prop, propID);
|
||||
if (!s.IsEmpty())
|
||||
{
|
||||
AString nameA;
|
||||
|
||||
@@ -64,6 +64,8 @@ using namespace NCommandLineParser;
|
||||
HINSTANCE g_hInstance = 0;
|
||||
#endif
|
||||
|
||||
bool g_LargePagesMode = false;
|
||||
|
||||
extern CStdOutStream *g_StdStream;
|
||||
extern CStdOutStream *g_ErrStream;
|
||||
|
||||
@@ -73,24 +75,19 @@ extern const CCodecInfo *g_Codecs[];
|
||||
extern unsigned g_NumHashers;
|
||||
extern const CHasherInfo *g_Hashers[];
|
||||
|
||||
static const char *kCopyrightString = "\n7-Zip"
|
||||
#ifndef EXTERNAL_CODECS
|
||||
#ifdef PROG_VARIANT_R
|
||||
" (r)"
|
||||
#else
|
||||
" (a)"
|
||||
#endif
|
||||
#endif
|
||||
static const char * const kCopyrightString = "\n7-Zip"
|
||||
#ifndef EXTERNAL_CODECS
|
||||
#ifdef PROG_VARIANT_R
|
||||
" (r)"
|
||||
#else
|
||||
" (a)"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef MY_CPU_64BIT
|
||||
" [64]"
|
||||
#elif defined MY_CPU_32BIT
|
||||
" [32]"
|
||||
#endif
|
||||
" " MY_VERSION_CPU
|
||||
" : " MY_COPYRIGHT_DATE "\n\n";
|
||||
|
||||
" " MY_VERSION_COPYRIGHT_DATE "\n\n";
|
||||
|
||||
static const char *kHelpString =
|
||||
static const char * const kHelpString =
|
||||
"Usage: 7z"
|
||||
#ifndef EXTERNAL_CODECS
|
||||
#ifdef PROG_VARIANT_R
|
||||
@@ -128,6 +125,7 @@ static const char *kHelpString =
|
||||
" -i[r[-|0]]{@listfile|!wildcard} : Include filenames\n"
|
||||
" -m{Parameters} : set compression Method\n"
|
||||
" -mmt[N] : set number of CPU threads\n"
|
||||
" -mx[N] : set compression level: -mx1 (fastest) ... -mx9 (ultra)\n"
|
||||
" -o{Directory} : set Output directory\n"
|
||||
#ifndef _NO_CRYPTO
|
||||
" -p{Password} : set Password\n"
|
||||
@@ -166,13 +164,13 @@ static const char *kHelpString =
|
||||
// ---------------------------
|
||||
// exception messages
|
||||
|
||||
static const char *kEverythingIsOk = "Everything is Ok";
|
||||
static const char *kUserErrorMessage = "Incorrect command line";
|
||||
static const char *kNoFormats = "7-Zip cannot find the code that works with archives.";
|
||||
static const char *kUnsupportedArcTypeMessage = "Unsupported archive type";
|
||||
// static const char *kUnsupportedUpdateArcType = "Can't create archive for that type";
|
||||
static const char * const kEverythingIsOk = "Everything is Ok";
|
||||
static const char * const kUserErrorMessage = "Incorrect command line";
|
||||
static const char * const kNoFormats = "7-Zip cannot find the code that works with archives.";
|
||||
static const char * const kUnsupportedArcTypeMessage = "Unsupported archive type";
|
||||
// static const char * const kUnsupportedUpdateArcType = "Can't create archive for that type";
|
||||
|
||||
static CFSTR kDefaultSfxModule = FTEXT("7zCon.sfx");
|
||||
#define kDefaultSfxModule "7zCon.sfx"
|
||||
|
||||
static void ShowMessageAndThrowException(LPCSTR message, NExitCode::EEnum code)
|
||||
{
|
||||
@@ -204,9 +202,9 @@ static void ShowCopyrightAndHelp(CStdOutStream *so, bool needHelp)
|
||||
}
|
||||
|
||||
|
||||
static void PrintStringRight(CStdOutStream &so, const AString &s, unsigned size)
|
||||
static void PrintStringRight(CStdOutStream &so, const char *s, unsigned size)
|
||||
{
|
||||
unsigned len = s.Len();
|
||||
unsigned len = MyStringLen(s);
|
||||
for (unsigned i = len; i < size; i++)
|
||||
so << ' ';
|
||||
so << s;
|
||||
@@ -279,7 +277,7 @@ static int WarningsCheck(HRESULT result, const CCallbackConsoleBase &callback,
|
||||
UString message;
|
||||
if (!errorInfo.Message.IsEmpty())
|
||||
{
|
||||
message.AddAscii(errorInfo.Message);
|
||||
message += errorInfo.Message.Ptr();
|
||||
message.Add_LF();
|
||||
}
|
||||
{
|
||||
@@ -389,6 +387,7 @@ static void PrintMemUsage(const char *s, UInt64 val)
|
||||
EXTERN_C_BEGIN
|
||||
typedef BOOL (WINAPI *Func_GetProcessMemoryInfo)(HANDLE Process,
|
||||
PPROCESS_MEMORY_COUNTERS ppsmemCounters, DWORD cb);
|
||||
typedef BOOL (WINAPI *Func_QueryProcessCycleTime)(HANDLE Process, PULONG64 CycleTime);
|
||||
EXTERN_C_END
|
||||
|
||||
#endif
|
||||
@@ -415,6 +414,8 @@ static void PrintStat()
|
||||
PROCESS_MEMORY_COUNTERS m;
|
||||
memset(&m, 0, sizeof(m));
|
||||
BOOL memDefined = FALSE;
|
||||
BOOL cycleDefined = FALSE;
|
||||
ULONG64 cycleTime = 0;
|
||||
{
|
||||
/* NT 4.0: GetProcessMemoryInfo() in Psapi.dll
|
||||
Win7: new function K32GetProcessMemoryInfo() in kernel32.dll
|
||||
@@ -425,8 +426,9 @@ static void PrintStat()
|
||||
// memDefined = GetProcessMemoryInfo(GetCurrentProcess(), &m, sizeof(m));
|
||||
*/
|
||||
|
||||
HMODULE kern = ::GetModuleHandleW(L"kernel32.dll");
|
||||
Func_GetProcessMemoryInfo my_GetProcessMemoryInfo = (Func_GetProcessMemoryInfo)
|
||||
::GetProcAddress(::GetModuleHandleW(L"kernel32.dll"), "K32GetProcessMemoryInfo");
|
||||
::GetProcAddress(kern, "K32GetProcessMemoryInfo");
|
||||
if (!my_GetProcessMemoryInfo)
|
||||
{
|
||||
HMODULE lib = LoadLibraryW(L"Psapi.dll");
|
||||
@@ -436,6 +438,11 @@ static void PrintStat()
|
||||
if (my_GetProcessMemoryInfo)
|
||||
memDefined = my_GetProcessMemoryInfo(GetCurrentProcess(), &m, sizeof(m));
|
||||
// FreeLibrary(lib);
|
||||
|
||||
Func_QueryProcessCycleTime my_QueryProcessCycleTime = (Func_QueryProcessCycleTime)
|
||||
::GetProcAddress(kern, "QueryProcessCycleTime");
|
||||
if (my_QueryProcessCycleTime)
|
||||
cycleDefined = my_QueryProcessCycleTime(GetCurrentProcess(), &cycleTime);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -448,6 +455,16 @@ static void PrintStat()
|
||||
UInt64 totalTime = curTime - creationTime;
|
||||
|
||||
PrintTime("Kernel ", kernelTime, totalTime);
|
||||
|
||||
#ifndef UNDER_CE
|
||||
if (cycleDefined)
|
||||
{
|
||||
*g_StdStream << " ";
|
||||
PrintNum(cycleTime / 1000000, 22);
|
||||
*g_StdStream << " MCycles";
|
||||
}
|
||||
#endif
|
||||
|
||||
PrintTime("User ", userTime, totalTime);
|
||||
|
||||
PrintTime("Process", kernelTime + userTime, totalTime);
|
||||
@@ -470,6 +487,7 @@ static void PrintHexId(CStdOutStream &so, UInt64 id)
|
||||
PrintStringRight(so, s, 8);
|
||||
}
|
||||
|
||||
|
||||
int Main2(
|
||||
#ifndef _WIN32
|
||||
int numArgs, char *args[]
|
||||
@@ -488,14 +506,17 @@ int Main2(
|
||||
GetArguments(numArgs, args, commandStrings);
|
||||
#endif
|
||||
|
||||
if (commandStrings.Size() == 1)
|
||||
#ifndef UNDER_CE
|
||||
if (commandStrings.Size() > 0)
|
||||
commandStrings.Delete(0);
|
||||
#endif
|
||||
|
||||
if (commandStrings.Size() == 0)
|
||||
{
|
||||
ShowCopyrightAndHelp(g_StdStream, true);
|
||||
return 0;
|
||||
}
|
||||
|
||||
commandStrings.Delete(0);
|
||||
|
||||
CArcCmdLineOptions options;
|
||||
|
||||
CArcCmdLineParser parser;
|
||||
@@ -527,8 +548,11 @@ int Main2(
|
||||
if (options.LargePages)
|
||||
{
|
||||
SetLargePageSize();
|
||||
g_LargePagesMode =
|
||||
#if defined(_WIN32) && !defined(UNDER_CE)
|
||||
NSecurity::EnablePrivilege_LockMemory();
|
||||
NSecurity::EnablePrivilege_LockMemory();
|
||||
#else
|
||||
true;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
@@ -579,7 +603,7 @@ int Main2(
|
||||
#ifdef EXTERNAL_CODECS
|
||||
if (!codecs->MainDll_ErrorPath.IsEmpty())
|
||||
{
|
||||
UString s = L"Can't load module ";
|
||||
UString s ("Can't load module: ");
|
||||
s += fs2us(codecs->MainDll_ErrorPath);
|
||||
throw s;
|
||||
}
|
||||
@@ -639,7 +663,7 @@ int Main2(
|
||||
|
||||
so << endl << "Formats:" << endl;
|
||||
|
||||
const char *kArcFlags = "KSNFMGOPBELH";
|
||||
const char * const kArcFlags = "KSNFMGOPBELH";
|
||||
const unsigned kNumArcFlags = (unsigned)strlen(kArcFlags);
|
||||
|
||||
for (i = 0; i < codecs->Formats.Size(); i++)
|
||||
@@ -673,9 +697,9 @@ int Main2(
|
||||
s += ext.Ext;
|
||||
if (!ext.AddExt.IsEmpty())
|
||||
{
|
||||
s += L" (";
|
||||
s += " (";
|
||||
s += ext.AddExt;
|
||||
s += L')';
|
||||
s += ')';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,12 +24,12 @@ extern int Main2(
|
||||
#endif
|
||||
);
|
||||
|
||||
static const char *kException_CmdLine_Error_Message = "Command Line Error:";
|
||||
static const char *kExceptionErrorMessage = "ERROR:";
|
||||
static const char *kUserBreakMessage = "Break signaled";
|
||||
static const char *kMemoryExceptionMessage = "ERROR: Can't allocate required memory!";
|
||||
static const char *kUnknownExceptionMessage = "Unknown Error";
|
||||
static const char *kInternalExceptionMessage = "\n\nInternal Error #";
|
||||
static const char * const kException_CmdLine_Error_Message = "Command Line Error:";
|
||||
static const char * const kExceptionErrorMessage = "ERROR:";
|
||||
static const char * const kUserBreakMessage = "Break signaled";
|
||||
static const char * const kMemoryExceptionMessage = "ERROR: Can't allocate required memory!";
|
||||
static const char * const kUnknownExceptionMessage = "Unknown Error";
|
||||
static const char * const kInternalExceptionMessage = "\n\nInternal Error #";
|
||||
|
||||
static void FlushStreams()
|
||||
{
|
||||
|
||||
@@ -32,13 +32,17 @@ HRESULT COpenCallbackConsole::Open_SetTotal(const UInt64 *files, const UInt64 *b
|
||||
|
||||
if (bytes)
|
||||
{
|
||||
_totalBytesDefined = true;
|
||||
// _totalBytes = *bytes;
|
||||
// _totalBytesDefined = true;
|
||||
_totalBytes = *bytes;
|
||||
if (!files)
|
||||
_percent.Total = *bytes;
|
||||
}
|
||||
else
|
||||
_totalBytesDefined = false;
|
||||
{
|
||||
// _totalBytesDefined = false;
|
||||
if (!files)
|
||||
_percent.Total = _totalBytes;
|
||||
}
|
||||
}
|
||||
|
||||
return CheckBreak2();
|
||||
@@ -83,7 +87,7 @@ HRESULT COpenCallbackConsole::Open_CryptoGetTextPassword(BSTR *password)
|
||||
if (!PasswordIsDefined)
|
||||
{
|
||||
ClosePercents();
|
||||
Password = GetPassword(_so);
|
||||
RINOK(GetPassword_HRESULT(_so, Password));
|
||||
PasswordIsDefined = true;
|
||||
}
|
||||
return StringToBstr(Password, password);
|
||||
|
||||
@@ -18,9 +18,9 @@ protected:
|
||||
CStdOutStream *_se;
|
||||
|
||||
bool _totalFilesDefined;
|
||||
bool _totalBytesDefined;
|
||||
// bool _totalBytesDefined;
|
||||
// UInt64 _totalFiles;
|
||||
// UInt64 _totalBytes;
|
||||
UInt64 _totalBytes;
|
||||
|
||||
bool NeedPercents() const { return _percent._so != NULL; }
|
||||
|
||||
@@ -36,7 +36,8 @@ public:
|
||||
|
||||
COpenCallbackConsole():
|
||||
_totalFilesDefined(false),
|
||||
_totalBytesDefined(false),
|
||||
// _totalBytesDefined(false),
|
||||
_totalBytes(0),
|
||||
MultiArcMode(false)
|
||||
|
||||
#ifndef _NO_CRYPTO
|
||||
|
||||
@@ -23,15 +23,15 @@ static NSynchronization::CCriticalSection g_CriticalSection;
|
||||
#define MT_LOCK
|
||||
#endif
|
||||
|
||||
static const wchar_t *kEmptyFileAlias = L"[Content]";
|
||||
static const wchar_t * const kEmptyFileAlias = L"[Content]";
|
||||
|
||||
static const char *kOpenArchiveMessage = "Open archive: ";
|
||||
static const char *kCreatingArchiveMessage = "Creating archive: ";
|
||||
static const char *kUpdatingArchiveMessage = "Updating archive: ";
|
||||
static const char *kScanningMessage = "Scanning the drive:";
|
||||
static const char * const kOpenArchiveMessage = "Open archive: ";
|
||||
static const char * const kCreatingArchiveMessage = "Creating archive: ";
|
||||
static const char * const kUpdatingArchiveMessage = "Updating archive: ";
|
||||
static const char * const kScanningMessage = "Scanning the drive:";
|
||||
|
||||
static const char *kError = "ERROR: ";
|
||||
static const char *kWarning = "WARNING: ";
|
||||
static const char * const kError = "ERROR: ";
|
||||
static const char * const kWarning = "WARNING: ";
|
||||
|
||||
static HRESULT CheckBreak2()
|
||||
{
|
||||
@@ -259,7 +259,7 @@ HRESULT CUpdateCallbackConsole::FinishScanning(const CDirItemsStat &st)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static const char *k_StdOut_ArcName = "StdOut";
|
||||
static const char * const k_StdOut_ArcName = "StdOut";
|
||||
|
||||
HRESULT CUpdateCallbackConsole::StartOpenArchive(const wchar_t *name)
|
||||
{
|
||||
@@ -316,7 +316,7 @@ HRESULT CUpdateCallbackConsole::WriteSfx(const wchar_t *name, UInt64 size)
|
||||
{
|
||||
*_so << "Write SFX: ";
|
||||
*_so << name;
|
||||
AString s = " : ";
|
||||
AString s (" : ");
|
||||
PrintSize_bytes_Smart(s, size);
|
||||
*_so << s << endl;
|
||||
}
|
||||
@@ -398,14 +398,31 @@ HRESULT CUpdateCallbackConsole::Finalize()
|
||||
}
|
||||
*/
|
||||
|
||||
HRESULT CUpdateCallbackConsole::SetNumItems(UInt64 numItems)
|
||||
|
||||
void static PrintToDoStat(CStdOutStream *_so, const CDirItemsStat &stat, const char *name)
|
||||
{
|
||||
AString s;
|
||||
Print_DirItemsStat(s, stat);
|
||||
*_so << name << ": " << s << endl;
|
||||
}
|
||||
|
||||
HRESULT CUpdateCallbackConsole::SetNumItems(const CArcToDoStat &stat)
|
||||
{
|
||||
if (_so)
|
||||
{
|
||||
ClosePercents_for_so();
|
||||
AString s;
|
||||
PrintPropPair(s, "Items to compress", numItems);
|
||||
*_so << s << endl << endl;
|
||||
if (!stat.DeleteData.IsEmpty())
|
||||
{
|
||||
*_so << endl;
|
||||
PrintToDoStat(_so, stat.DeleteData, "Delete data from archive");
|
||||
}
|
||||
if (!stat.OldData.IsEmpty())
|
||||
PrintToDoStat(_so, stat.OldData, "Keep old data in archive");
|
||||
// if (!stat.NewData.IsEmpty())
|
||||
{
|
||||
PrintToDoStat(_so, stat.NewData, "Add new data to archive");
|
||||
}
|
||||
*_so << endl;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
@@ -622,7 +639,7 @@ HRESULT CUpdateCallbackConsole::CryptoGetTextPassword2(Int32 *passwordIsDefined,
|
||||
{
|
||||
if (AskPassword)
|
||||
{
|
||||
Password = GetPassword(_so);
|
||||
RINOK(GetPassword_HRESULT(_so, Password));
|
||||
PasswordIsDefined = true;
|
||||
}
|
||||
}
|
||||
@@ -649,7 +666,7 @@ HRESULT CUpdateCallbackConsole::CryptoGetTextPassword(BSTR *password)
|
||||
if (!PasswordIsDefined)
|
||||
{
|
||||
{
|
||||
Password = GetPassword(_so);
|
||||
RINOK(GetPassword_HRESULT(_so, Password))
|
||||
PasswordIsDefined = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@ static const char kNoAll = 's';
|
||||
static const char kAutoRenameAll = 'u';
|
||||
static const char kQuit = 'q';
|
||||
|
||||
static const char *kFirstQuestionMessage = "? ";
|
||||
static const char *kHelpQuestionMessage =
|
||||
static const char * const kFirstQuestionMessage = "? ";
|
||||
static const char * const kHelpQuestionMessage =
|
||||
"(Y)es / (N)o / (A)lways / (S)kip all / A(u)to rename all / (Q)uit? ";
|
||||
|
||||
// return true if pressed Quite;
|
||||
@@ -31,9 +31,16 @@ NUserAnswerMode::EEnum ScanUserYesNoAllQuit(CStdOutStream *outStream)
|
||||
*outStream << kHelpQuestionMessage;
|
||||
outStream->Flush();
|
||||
}
|
||||
AString scannedString = g_StdIn.ScanStringUntilNewLine();
|
||||
AString scannedString;
|
||||
if (!g_StdIn.ScanAStringUntilNewLine(scannedString))
|
||||
return NUserAnswerMode::kError;
|
||||
if (g_StdIn.Error())
|
||||
return NUserAnswerMode::kError;
|
||||
scannedString.Trim();
|
||||
if (!scannedString.IsEmpty())
|
||||
if (scannedString.IsEmpty() && g_StdIn.Eof())
|
||||
return NUserAnswerMode::kEof;
|
||||
|
||||
if (scannedString.Len() == 1)
|
||||
switch (::MyCharLower_Ascii(scannedString[0]))
|
||||
{
|
||||
case kYes: return NUserAnswerMode::kYes;
|
||||
@@ -52,7 +59,7 @@ NUserAnswerMode::EEnum ScanUserYesNoAllQuit(CStdOutStream *outStream)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
UString GetPassword(CStdOutStream *outStream)
|
||||
static bool GetPassword(CStdOutStream *outStream, UString &psw)
|
||||
{
|
||||
if (outStream)
|
||||
{
|
||||
@@ -72,19 +79,32 @@ UString GetPassword(CStdOutStream *outStream)
|
||||
if (console != INVALID_HANDLE_VALUE && console != 0)
|
||||
if (GetConsoleMode(console, &mode))
|
||||
wasChanged = (SetConsoleMode(console, mode & ~ENABLE_ECHO_INPUT) != 0);
|
||||
UString res = g_StdIn.ScanUStringUntilNewLine();
|
||||
bool res = g_StdIn.ScanUStringUntilNewLine(psw);
|
||||
if (wasChanged)
|
||||
SetConsoleMode(console, mode);
|
||||
|
||||
#else
|
||||
|
||||
bool res = g_StdIn.ScanUStringUntilNewLine(psw);
|
||||
|
||||
#endif
|
||||
|
||||
if (outStream)
|
||||
{
|
||||
*outStream << endl;
|
||||
outStream->Flush();
|
||||
}
|
||||
|
||||
return res;
|
||||
|
||||
#else
|
||||
|
||||
return g_StdIn.ScanUStringUntilNewLine();
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
HRESULT GetPassword_HRESULT(CStdOutStream *outStream, UString &psw)
|
||||
{
|
||||
if (!GetPassword(outStream, psw))
|
||||
return E_INVALIDARG;
|
||||
if (g_StdIn.Error())
|
||||
return E_FAIL;
|
||||
if (g_StdIn.Eof() && psw.IsEmpty())
|
||||
return E_ABORT;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -14,11 +14,14 @@ enum EEnum
|
||||
kYesAll,
|
||||
kNoAll,
|
||||
kAutoRenameAll,
|
||||
kQuit
|
||||
kQuit,
|
||||
kEof,
|
||||
kError
|
||||
};
|
||||
}
|
||||
|
||||
NUserAnswerMode::EEnum ScanUserYesNoAllQuit(CStdOutStream *outStream);
|
||||
UString GetPassword(CStdOutStream *outStream);
|
||||
// bool GetPassword(CStdOutStream *outStream, UString &psw);
|
||||
HRESULT GetPassword_HRESULT(CStdOutStream *outStream, UString &psw);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
#include "../../MyVersionInfo.rc"
|
||||
|
||||
MY_VERSION_INFO_APP("7-Zip Console", "7z")
|
||||
MY_VERSION_INFO_APP("7-Zip Console" , "7z")
|
||||
|
||||
@@ -129,27 +129,16 @@ HRESULT CZipContextMenu::InitContextMenu(const wchar_t * /* folder */, const wch
|
||||
/////////////////////////////
|
||||
// IContextMenu
|
||||
|
||||
static LPCWSTR kMainVerb = L"SevenZipZS";
|
||||
static LPCWSTR kOpenCascadedVerb = L"SevenZipZS.OpenWithType.";
|
||||
static LPCWSTR kCheckSumCascadedVerb = L"SevenZipZS.Checksum";
|
||||
static LPCSTR const kMainVerb = "SevenZipZS";
|
||||
static LPCSTR const kOpenCascadedVerb = "SevenZipZS.OpenWithType.";
|
||||
static LPCSTR const kCheckSumCascadedVerb = "SevenZipZS.Checksum";
|
||||
|
||||
/*
|
||||
static LPCTSTR kOpenVerb = TEXT("SevenOpen");
|
||||
static LPCTSTR kExtractVerb = TEXT("SevenExtract");
|
||||
static LPCTSTR kExtractHereVerb = TEXT("SevenExtractHere");
|
||||
static LPCTSTR kExtractToVerb = TEXT("SevenExtractTo");
|
||||
static LPCTSTR kTestVerb = TEXT("SevenTest");
|
||||
static LPCTSTR kCompressVerb = TEXT("SevenCompress");
|
||||
static LPCTSTR kCompressToVerb = TEXT("SevenCompressTo");
|
||||
static LPCTSTR kCompressEmailVerb = TEXT("SevenCompressEmail");
|
||||
static LPCTSTR kCompressToEmailVerb = TEXT("SevenCompressToEmail");
|
||||
*/
|
||||
|
||||
struct CContextMenuCommand
|
||||
{
|
||||
UInt32 flag;
|
||||
CZipContextMenu::ECommandInternalID CommandInternalID;
|
||||
LPCWSTR Verb;
|
||||
LPCSTR Verb;
|
||||
UINT ResourceID;
|
||||
};
|
||||
|
||||
@@ -158,67 +147,67 @@ static const CContextMenuCommand g_Commands[] =
|
||||
{
|
||||
NContextMenuFlags::kOpen,
|
||||
CZipContextMenu::kOpen,
|
||||
L"Open",
|
||||
"Open",
|
||||
IDS_CONTEXT_OPEN
|
||||
},
|
||||
{
|
||||
NContextMenuFlags::kExtract,
|
||||
CZipContextMenu::kExtract,
|
||||
L"Extract",
|
||||
"Extract",
|
||||
IDS_CONTEXT_EXTRACT
|
||||
},
|
||||
{
|
||||
NContextMenuFlags::kExtractHere,
|
||||
CZipContextMenu::kExtractHere,
|
||||
L"ExtractHere",
|
||||
"ExtractHere",
|
||||
IDS_CONTEXT_EXTRACT_HERE
|
||||
},
|
||||
{
|
||||
NContextMenuFlags::kExtractTo,
|
||||
CZipContextMenu::kExtractTo,
|
||||
L"ExtractTo",
|
||||
"ExtractTo",
|
||||
IDS_CONTEXT_EXTRACT_TO
|
||||
},
|
||||
{
|
||||
NContextMenuFlags::kTest,
|
||||
CZipContextMenu::kTest,
|
||||
L"Test",
|
||||
"Test",
|
||||
IDS_CONTEXT_TEST
|
||||
},
|
||||
{
|
||||
NContextMenuFlags::kCompress,
|
||||
CZipContextMenu::kCompress,
|
||||
L"Compress",
|
||||
"Compress",
|
||||
IDS_CONTEXT_COMPRESS
|
||||
},
|
||||
{
|
||||
NContextMenuFlags::kCompressEmail,
|
||||
CZipContextMenu::kCompressEmail,
|
||||
L"CompressEmail",
|
||||
"CompressEmail",
|
||||
IDS_CONTEXT_COMPRESS_EMAIL
|
||||
},
|
||||
{
|
||||
NContextMenuFlags::kCompressTo7z,
|
||||
CZipContextMenu::kCompressTo7z,
|
||||
L"CompressTo7z",
|
||||
"CompressTo7z",
|
||||
IDS_CONTEXT_COMPRESS_TO
|
||||
},
|
||||
{
|
||||
NContextMenuFlags::kCompressTo7zEmail,
|
||||
CZipContextMenu::kCompressTo7zEmail,
|
||||
L"CompressTo7zEmail",
|
||||
"CompressTo7zEmail",
|
||||
IDS_CONTEXT_COMPRESS_TO_EMAIL
|
||||
},
|
||||
{
|
||||
NContextMenuFlags::kCompressToZip,
|
||||
CZipContextMenu::kCompressToZip,
|
||||
L"CompressToZip",
|
||||
"CompressToZip",
|
||||
IDS_CONTEXT_COMPRESS_TO
|
||||
},
|
||||
{
|
||||
NContextMenuFlags::kCompressToZipEmail,
|
||||
CZipContextMenu::kCompressToZipEmail,
|
||||
L"CompressToZipEmail",
|
||||
"CompressToZipEmail",
|
||||
IDS_CONTEXT_COMPRESS_TO_EMAIL
|
||||
}
|
||||
};
|
||||
@@ -226,17 +215,17 @@ static const CContextMenuCommand g_Commands[] =
|
||||
struct CHashCommand
|
||||
{
|
||||
CZipContextMenu::ECommandInternalID CommandInternalID;
|
||||
LPCWSTR UserName;
|
||||
LPCWSTR MethodName;
|
||||
LPCSTR UserName;
|
||||
LPCSTR MethodName;
|
||||
};
|
||||
|
||||
static const CHashCommand g_HashCommands[] =
|
||||
{
|
||||
{ CZipContextMenu::kHash_CRC32, L"CRC-32", L"CRC32" },
|
||||
{ CZipContextMenu::kHash_CRC64, L"CRC-64", L"CRC64" },
|
||||
{ CZipContextMenu::kHash_SHA1, L"SHA-1", L"SHA1" },
|
||||
{ CZipContextMenu::kHash_SHA256, L"SHA-256", L"SHA256" },
|
||||
{ CZipContextMenu::kHash_All, L"*", L"*" }
|
||||
{ CZipContextMenu::kHash_CRC32, "CRC-32", "CRC32" },
|
||||
{ CZipContextMenu::kHash_CRC64, "CRC-64", "CRC64" },
|
||||
{ CZipContextMenu::kHash_SHA1, "SHA-1", "SHA1" },
|
||||
{ CZipContextMenu::kHash_SHA256, "SHA-256", "SHA256" },
|
||||
{ CZipContextMenu::kHash_All, "*", "*" }
|
||||
};
|
||||
|
||||
static int FindCommand(CZipContextMenu::ECommandInternalID &id)
|
||||
@@ -255,7 +244,8 @@ bool CZipContextMenu::FillCommand(ECommandInternalID id, UString &mainString, CC
|
||||
return false;
|
||||
const CContextMenuCommand &command = g_Commands[i];
|
||||
commandMapItem.CommandInternalID = command.CommandInternalID;
|
||||
commandMapItem.Verb = (UString)kMainVerb + (UString)command.Verb;
|
||||
commandMapItem.Verb = kMainVerb;
|
||||
commandMapItem.Verb += command.Verb;
|
||||
// LangString(command.ResourceHelpID, command.LangID + 1, commandMapItem.HelpString);
|
||||
LangString(command.ResourceID, mainString);
|
||||
return true;
|
||||
@@ -345,7 +335,7 @@ static void MyFormatNew_ReducedName(UString &s, const UString &name)
|
||||
s = MyFormatNew(s, GetQuotedReducedString(name));
|
||||
}
|
||||
|
||||
static const char *kExtractExludeExtensions =
|
||||
static const char * const kExtractExludeExtensions =
|
||||
" 3gp"
|
||||
" aac ans ape asc asm asp aspx avi awk"
|
||||
" bas bat bmp"
|
||||
@@ -357,7 +347,7 @@ static const char *kExtractExludeExtensions =
|
||||
" h hpp hta htm html hxx"
|
||||
" ico idl inc ini inl"
|
||||
" java jpeg jpg js"
|
||||
" la log"
|
||||
" la lnk log"
|
||||
" mak manifest wmv mov mp3 mp4 mpe mpeg mpg m4a"
|
||||
" ofr ogg"
|
||||
" pac pas pdf php php3 php4 php5 phptml pl pm png ps py pyo"
|
||||
@@ -370,7 +360,7 @@ static const char *kExtractExludeExtensions =
|
||||
" ";
|
||||
|
||||
/*
|
||||
static const char *kNoOpenAsExtensions =
|
||||
static const char * const kNoOpenAsExtensions =
|
||||
" 7z arj bz2 cab chm cpio flv gz lha lzh lzma rar swm tar tbz2 tgz wim xar xz z zip ";
|
||||
*/
|
||||
|
||||
@@ -423,7 +413,7 @@ static bool DoNeedExtract(const FString &name)
|
||||
}
|
||||
|
||||
// we must use diferent Verbs for Popup subMenu.
|
||||
void CZipContextMenu::AddMapItem_ForSubMenu(const wchar_t *verb)
|
||||
void CZipContextMenu::AddMapItem_ForSubMenu(const char *verb)
|
||||
{
|
||||
CCommandMapItem commandMapItem;
|
||||
commandMapItem.CommandInternalID = kCommandNULL;
|
||||
@@ -502,9 +492,9 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
||||
fi0.Name = us2fs(fileName.Ptr(NName::kDevicePathPrefixSize)); // change it 4 - must be constant
|
||||
folderPrefix =
|
||||
#ifdef UNDER_CE
|
||||
FTEXT("\\");
|
||||
"\\";
|
||||
#else
|
||||
FTEXT("C:\\");
|
||||
"C:\\";
|
||||
#endif
|
||||
}
|
||||
else
|
||||
@@ -559,9 +549,11 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
||||
FillCommand(kOpen, mainString, commandMapItem);
|
||||
else
|
||||
{
|
||||
mainString.SetFromAscii(kOpenTypes[i]);
|
||||
mainString = kOpenTypes[i];
|
||||
commandMapItem.CommandInternalID = kOpen;
|
||||
commandMapItem.Verb = (UString)kMainVerb + L".Open." + mainString;
|
||||
commandMapItem.Verb = kMainVerb;
|
||||
commandMapItem.Verb += ".Open.";
|
||||
commandMapItem.Verb += mainString;
|
||||
commandMapItem.HelpString = mainString;
|
||||
commandMapItem.ArcType = mainString;
|
||||
}
|
||||
@@ -603,7 +595,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
||||
if (_dropMode)
|
||||
baseFolder = _dropPath;
|
||||
|
||||
UString specFolder = L'*';
|
||||
UString specFolder ('*');
|
||||
if (_fileNames.Size() == 1)
|
||||
specFolder = GetSubFolderNameForExtract(fs2us(fi0.Name));
|
||||
specFolder.Add_PathSepar();
|
||||
@@ -657,8 +649,10 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
||||
else
|
||||
arcName = CreateArchiveName(fileName, _fileNames.Size() > 1, false);
|
||||
|
||||
UString arcName7z = arcName + L".7z";
|
||||
UString arcNameZip = arcName + L".zip";
|
||||
UString arcName7z = arcName;
|
||||
arcName7z += ".7z";
|
||||
UString arcNameZip = arcName;
|
||||
arcNameZip += ".zip";
|
||||
|
||||
// Compress
|
||||
if ((contextMenuFlags & NContextMenuFlags::kCompress) != 0)
|
||||
@@ -698,7 +692,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
||||
else
|
||||
commandMapItem.Folder = fs2us(folderPrefix);
|
||||
commandMapItem.ArcName = arcName7z;
|
||||
commandMapItem.ArcType.SetFromAscii("7z");
|
||||
commandMapItem.ArcType = "7z";
|
||||
MyFormatNew_ReducedName(s, arcName7z);
|
||||
MyInsertMenu(popupMenu, subIndex++, currentCommandID++, s, bitmap);
|
||||
_commandMap.Add(commandMapItem);
|
||||
@@ -712,7 +706,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
||||
UString s;
|
||||
FillCommand(kCompressTo7zEmail, s, commandMapItem);
|
||||
commandMapItem.ArcName = arcName7z;
|
||||
commandMapItem.ArcType.SetFromAscii("7z");
|
||||
commandMapItem.ArcType = "7z";
|
||||
MyFormatNew_ReducedName(s, arcName7z);
|
||||
MyInsertMenu(popupMenu, subIndex++, currentCommandID++, s, bitmap);
|
||||
_commandMap.Add(commandMapItem);
|
||||
@@ -731,7 +725,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
||||
else
|
||||
commandMapItem.Folder = fs2us(folderPrefix);
|
||||
commandMapItem.ArcName = arcNameZip;
|
||||
commandMapItem.ArcType.SetFromAscii("zip");
|
||||
commandMapItem.ArcType = "zip";
|
||||
MyFormatNew_ReducedName(s, arcNameZip);
|
||||
MyInsertMenu(popupMenu, subIndex++, currentCommandID++, s, bitmap);
|
||||
_commandMap.Add(commandMapItem);
|
||||
@@ -745,7 +739,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
||||
UString s;
|
||||
FillCommand(kCompressToZipEmail, s, commandMapItem);
|
||||
commandMapItem.ArcName = arcNameZip;
|
||||
commandMapItem.ArcType.SetFromAscii("zip");
|
||||
commandMapItem.ArcType = "zip";
|
||||
MyFormatNew_ReducedName(s, arcNameZip);
|
||||
MyInsertMenu(popupMenu, subIndex++, currentCommandID++, s, bitmap);
|
||||
_commandMap.Add(commandMapItem);
|
||||
@@ -767,7 +761,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
||||
mi.fMask |= MIIM_CHECKMARKS;
|
||||
mi.wID = currentCommandID++;
|
||||
mi.hSubMenu = popupMenu.Detach();
|
||||
mi.StringValue.SetFromAscii("7-Zip ZStandard"); // LangString(IDS_CONTEXT_POPUP_CAPTION);
|
||||
mi.StringValue = "7-Zip ZStandard"; // LangString(IDS_CONTEXT_POPUP_CAPTION);
|
||||
mi.hbmpUnchecked = bitmap;
|
||||
|
||||
CMenu menu;
|
||||
@@ -803,7 +797,7 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
||||
mi.fMask |= MIIM_CHECKMARKS;
|
||||
mi.wID = currentCommandID++;
|
||||
mi.hSubMenu = subMenu;
|
||||
mi.StringValue.SetFromAscii("CRC SHA ZStandard");
|
||||
mi.StringValue = "CRC SHA ZStandard";
|
||||
mi.hbmpUnchecked = bitmap;
|
||||
|
||||
CMenu menu;
|
||||
@@ -818,9 +812,10 @@ STDMETHODIMP CZipContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu,
|
||||
const CHashCommand &hc = g_HashCommands[i];
|
||||
CCommandMapItem commandMapItem;
|
||||
commandMapItem.CommandInternalID = hc.CommandInternalID;
|
||||
commandMapItem.Verb = (UString)kCheckSumCascadedVerb + (UString)hc.MethodName;
|
||||
commandMapItem.Verb = kCheckSumCascadedVerb;
|
||||
commandMapItem.Verb += hc.MethodName;
|
||||
// commandMapItem.HelpString = hc.Name;
|
||||
MyInsertMenu(subMenu, subIndex_CRC++, currentCommandID++, hc.UserName, bitmap);
|
||||
MyInsertMenu(subMenu, subIndex_CRC++, currentCommandID++, (UString)hc.UserName, bitmap);
|
||||
_commandMap.Add(commandMapItem);
|
||||
}
|
||||
|
||||
@@ -885,7 +880,7 @@ STDMETHODIMP CZipContextMenu::InvokeCommand(LPCMINVOKECOMMANDINFO commandInfo)
|
||||
params = GetQuotedString(_fileNames[0]);
|
||||
if (!commandMapItem.ArcType.IsEmpty())
|
||||
{
|
||||
params += L" -t";
|
||||
params += " -t";
|
||||
params += commandMapItem.ArcType;
|
||||
}
|
||||
MyCreateProcess(Get7zFmPath(), params);
|
||||
@@ -939,7 +934,7 @@ STDMETHODIMP CZipContextMenu::InvokeCommand(LPCMINVOKECOMMANDINFO commandInfo)
|
||||
const CHashCommand &hc = g_HashCommands[i];
|
||||
if (hc.CommandInternalID == cmdID)
|
||||
{
|
||||
CalcChecksum(_fileNames, hc.MethodName);
|
||||
CalcChecksum(_fileNames, (UString)hc.MethodName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ private:
|
||||
HRESULT GetFileNames(LPDATAOBJECT dataObject, UStringVector &fileNames);
|
||||
int FindVerb(const UString &verb);
|
||||
bool FillCommand(ECommandInternalID id, UString &mainString, CCommandMapItem &commandMapItem);
|
||||
void AddMapItem_ForSubMenu(const wchar_t *ver);
|
||||
void AddMapItem_ForSubMenu(const char *ver);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -25,14 +25,14 @@
|
||||
|
||||
#include "ContextMenu.h"
|
||||
|
||||
static LPCTSTR k_ShellExtName = TEXT("7-Zip-ZStandard Shell Extension");
|
||||
static LPCTSTR k_Approved = TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved");
|
||||
static LPCTSTR const k_ShellExtName = TEXT("7-Zip-ZStandard Shell Extension");
|
||||
static LPCTSTR const k_Approved = TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved");
|
||||
|
||||
// {23170F69-40C1-278A-1000-000100020000}
|
||||
#ifdef NEED_7ZIP_GUID
|
||||
static LPCTSTR k_Clsid = TEXT("{23170F69-40C1-278A-1000-000100020001}");
|
||||
static LPCTSTR const k_Clsid = TEXT("{23170F69-40C1-278A-1000-000100020001}");
|
||||
#else
|
||||
static LPCTSTR k_Clsid = TEXT("{23170F69-0803-278A-1000-000100020001}");
|
||||
static LPCTSTR const k_Clsid = TEXT("{23170F69-0803-278A-1000-000100020001}");
|
||||
#endif
|
||||
|
||||
DEFINE_GUID(CLSID_CZipContextMenu,
|
||||
@@ -159,9 +159,8 @@ static BOOL RegisterServer()
|
||||
return FALSE;
|
||||
const UString modulePathU = fs2us(modulePath);
|
||||
|
||||
CSysString clsidString = k_Clsid;
|
||||
CSysString s = TEXT("CLSID\\");
|
||||
s += clsidString;
|
||||
CSysString s ("CLSID\\");
|
||||
s += k_Clsid;
|
||||
|
||||
{
|
||||
NRegistry::CKey key;
|
||||
@@ -181,7 +180,7 @@ static BOOL RegisterServer()
|
||||
{
|
||||
NRegistry::CKey key;
|
||||
if (key.Create(HKEY_LOCAL_MACHINE, k_Approved, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE) == NOERROR)
|
||||
key.SetValue(clsidString, k_ShellExtName);
|
||||
key.SetValue(k_Clsid, k_ShellExtName);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@@ -194,13 +193,10 @@ STDAPI DllRegisterServer(void)
|
||||
|
||||
static BOOL UnregisterServer()
|
||||
{
|
||||
const CSysString clsidString = k_Clsid;
|
||||
CSysString s = TEXT("CLSID\\");
|
||||
s += clsidString;
|
||||
CSysString s2 = s;
|
||||
s2.AddAscii("\\InprocServer32");
|
||||
CSysString s ("CLSID\\");
|
||||
s += k_Clsid;
|
||||
|
||||
RegDeleteKey(HKEY_CLASSES_ROOT, s2);
|
||||
RegDeleteKey(HKEY_CLASSES_ROOT, s + TEXT("\\InprocServer32"));
|
||||
RegDeleteKey(HKEY_CLASSES_ROOT, s);
|
||||
|
||||
#if !defined(_WIN64) && !defined(UNDER_CE)
|
||||
@@ -210,7 +206,7 @@ static BOOL UnregisterServer()
|
||||
HKEY hKey;
|
||||
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, k_Approved, 0, KEY_SET_VALUE, &hKey) == NOERROR)
|
||||
{
|
||||
RegDeleteValue(hKey, clsidString);
|
||||
RegDeleteValue(hKey, k_Clsid);
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,21 +17,23 @@ using namespace NRegistry;
|
||||
// CLISID (and Approved ?) items are separated for 32-bit and 64-bit code.
|
||||
// shellex items shared by 32-bit and 64-bit code?
|
||||
|
||||
static LPCTSTR k_Clsid = TEXT("{23170F69-0803-278A-1000-000100020001}");
|
||||
static LPCTSTR k_ShellExtName = TEXT("7-Zip Shell Extension");
|
||||
#define k_Clsid_A "{23170F69-0803-278A-1000-000100020001}"
|
||||
|
||||
static LPCTSTR k_Approved = TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved");
|
||||
static LPCTSTR k_Inproc = TEXT("InprocServer32");
|
||||
static LPCTSTR const k_Clsid = TEXT(k_Clsid_A);
|
||||
static LPCTSTR const k_ShellExtName = TEXT("7-Zip Shell Extension");
|
||||
|
||||
static LPCTSTR k_KeyPostfix_ContextMenu = TEXT("\\shellex\\ContextMenuHandlers\\7-Zip-ZStandard");
|
||||
static LPCTSTR k_KeyPostfix_DragDrop = TEXT("\\shellex\\DragDropHandlers\\7-Zip-ZStandard");
|
||||
static LPCTSTR const k_Approved = TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved");
|
||||
static LPCTSTR const k_Inproc = TEXT("InprocServer32");
|
||||
|
||||
static LPCTSTR k_KeyName_File = TEXT("*");
|
||||
static LPCTSTR k_KeyName_Folder = TEXT("Folder");
|
||||
static LPCTSTR k_KeyName_Directory = TEXT("Directory");
|
||||
static LPCTSTR k_KeyName_Drive = TEXT("Drive");
|
||||
static LPCSTR const k_KeyPostfix_ContextMenu = "\\shellex\\ContextMenuHandlers\\7-Zip-ZStandard";
|
||||
static LPCSTR const k_KeyPostfix_DragDrop = "\\shellex\\DragDropHandlers\\7-Zip-ZStandard";
|
||||
|
||||
static LPCTSTR const k_shellex_Prefixes[] =
|
||||
static LPCSTR const k_KeyName_File = "*";
|
||||
static LPCSTR const k_KeyName_Folder = "Folder";
|
||||
static LPCSTR const k_KeyName_Directory = "Directory";
|
||||
static LPCSTR const k_KeyName_Drive = "Drive";
|
||||
|
||||
static LPCSTR const k_shellex_Prefixes[] =
|
||||
{
|
||||
k_KeyName_File,
|
||||
k_KeyName_Folder,
|
||||
@@ -95,32 +97,32 @@ static LONG MyRegistry_DeleteKey_HKCR(LPCTSTR name, UInt32 wow)
|
||||
|
||||
// static NSynchronization::CCriticalSection g_CS;
|
||||
|
||||
static CSysString Get_ContextMenuHandler_KeyName(const CSysString &keyName)
|
||||
{ return (keyName + k_KeyPostfix_ContextMenu); }
|
||||
static AString Get_ContextMenuHandler_KeyName(LPCSTR keyName)
|
||||
{ return (AString)keyName + k_KeyPostfix_ContextMenu; }
|
||||
|
||||
/*
|
||||
static CSysString Get_DragDropHandler_KeyName(const CSysString &keyName)
|
||||
{ return (keyName + k_KeyPostfix_DragDrop); }
|
||||
static CSysString Get_DragDropHandler_KeyName(LPCTSTR keyName)
|
||||
{ return (AString)keyName + k_KeyPostfix_DragDrop); }
|
||||
*/
|
||||
|
||||
static bool CheckHandlerCommon(const CSysString &keyName, UInt32 wow)
|
||||
static bool CheckHandlerCommon(const AString &keyName, UInt32 wow)
|
||||
{
|
||||
CKey key;
|
||||
if (key.Open(HKEY_CLASSES_ROOT, keyName, KEY_READ | wow) != ERROR_SUCCESS)
|
||||
if (key.Open(HKEY_CLASSES_ROOT, (CSysString)keyName, KEY_READ | wow) != ERROR_SUCCESS)
|
||||
return false;
|
||||
CSysString value;
|
||||
if (key.QueryValue(NULL, value) != ERROR_SUCCESS)
|
||||
return false;
|
||||
return StringsAreEqualNoCase_Ascii(value, k_Clsid);
|
||||
return StringsAreEqualNoCase_Ascii(value, k_Clsid_A);
|
||||
}
|
||||
|
||||
bool CheckContextMenuHandler(const UString &path, UInt32 wow)
|
||||
{
|
||||
// NSynchronization::CCriticalSectionLock lock(g_CS);
|
||||
|
||||
CSysString s = TEXT("CLSID\\");
|
||||
s += k_Clsid;
|
||||
s.AddAscii("\\InprocServer32");
|
||||
CSysString s ("CLSID\\");
|
||||
s += k_Clsid_A;
|
||||
s += "\\InprocServer32";
|
||||
|
||||
{
|
||||
NRegistry::CKey key;
|
||||
@@ -160,8 +162,8 @@ LONG SetContextMenuHandler(bool setMode, const UString &path, UInt32 wow)
|
||||
LONG res;
|
||||
|
||||
{
|
||||
CSysString s = TEXT("CLSID\\");
|
||||
s += k_Clsid;
|
||||
CSysString s ("CLSID\\");
|
||||
s += k_Clsid_A;
|
||||
|
||||
if (setMode)
|
||||
{
|
||||
@@ -189,8 +191,8 @@ LONG SetContextMenuHandler(bool setMode, const UString &path, UInt32 wow)
|
||||
}
|
||||
else
|
||||
{
|
||||
CSysString s2 = s;
|
||||
s2.AddAscii("\\InprocServer32");
|
||||
CSysString s2 (s);
|
||||
s2 += "\\InprocServer32";
|
||||
|
||||
MyRegistry_DeleteKey_HKCR(s2, wow);
|
||||
res = MyRegistry_DeleteKey_HKCR(s, wow);
|
||||
@@ -203,7 +205,7 @@ LONG SetContextMenuHandler(bool setMode, const UString &path, UInt32 wow)
|
||||
{
|
||||
for (unsigned k = 0; k < ARRAY_SIZE(k_shellex_Prefixes); k++)
|
||||
{
|
||||
CSysString s = k_shellex_Prefixes[k];
|
||||
CSysString s (k_shellex_Prefixes[k]);
|
||||
s += (i == 0 ? k_KeyPostfix_ContextMenu : k_KeyPostfix_DragDrop);
|
||||
if (k_shellex_Statuses[i][k])
|
||||
{
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include "../../../Windows/Synchronization.h"
|
||||
#endif
|
||||
|
||||
#include "../../../Common/IntToString.h"
|
||||
#include "../../../Common/StringConvert.h"
|
||||
|
||||
#include "ExtractEngine.h"
|
||||
@@ -128,9 +127,9 @@ STDMETHODIMP CExtractCallbackImp::AskOverwrite(
|
||||
return CheckBreak2();
|
||||
}
|
||||
|
||||
static const char *kTestString = "Testing";
|
||||
static const char *kExtractString = "Extracting";
|
||||
static const char *kSkipString = "Skipping";
|
||||
static const char * const kTestString = "Testing";
|
||||
static const char * const kExtractString = "Extracting";
|
||||
static const char * const kSkipString = "Skipping";
|
||||
|
||||
STDMETHODIMP CExtractCallbackImp::PrepareOperation(const wchar_t *name, Int32 /* isFolder */, Int32 askExtractMode, const UInt64 * /* position */)
|
||||
{
|
||||
@@ -161,7 +160,7 @@ STDMETHODIMP CExtractCallbackImp::MessageError(const wchar_t *message)
|
||||
{
|
||||
MT_LOCK
|
||||
|
||||
AString s = UnicodeStringToMultiByte(message, CP_OEMCP);
|
||||
AString s (UnicodeStringToMultiByte(message, CP_OEMCP));
|
||||
if (g_StartupInfo.ShowErrorMessage((const char *)s) == -1)
|
||||
return E_ABORT;
|
||||
|
||||
@@ -198,7 +197,7 @@ void SetExtractErrorMessage(Int32 opRes, Int32 encrypted, AString &s)
|
||||
if (messageID != 0)
|
||||
{
|
||||
s = g_StartupInfo.GetMsgString(messageID);
|
||||
s.Replace(" '%s'", "");
|
||||
s.Replace((AString)" '%s'", AString());
|
||||
}
|
||||
else if (opRes == NArchive::NExtract::NOperationResult::kUnavailable)
|
||||
s = "Unavailable data";
|
||||
@@ -212,10 +211,8 @@ void SetExtractErrorMessage(Int32 opRes, Int32 encrypted, AString &s)
|
||||
s = "kHeaders Error";
|
||||
else
|
||||
{
|
||||
char temp[16];
|
||||
ConvertUInt32ToString(opRes, temp);
|
||||
s = "Error #";
|
||||
s += temp;
|
||||
s.Add_UInt32(opRes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,10 +25,10 @@ using namespace NFar;
|
||||
|
||||
static const DWORD kShowProgressTime_ms = 100;
|
||||
|
||||
static const char *kCommandPrefix = "7-zip";
|
||||
static const TCHAR *kRegisrtryMainKeyName = TEXT("");
|
||||
static const TCHAR *kRegisrtryValueNameEnabled = TEXT("UsedByDefault3");
|
||||
static const char *kHelpTopicConfig = "Config";
|
||||
static const char * const kCommandPrefix = "7-zip";
|
||||
static const char * const kRegisrtryMainKeyName = NULL; // ""
|
||||
static LPCTSTR const kRegisrtryValueNameEnabled = TEXT("UsedByDefault3");
|
||||
static const char * const kHelpTopicConfig = "Config";
|
||||
static bool kPluginEnabledDefault = true;
|
||||
|
||||
HINSTANCE g_hInstance;
|
||||
@@ -67,7 +67,7 @@ static struct COptions
|
||||
bool Enabled;
|
||||
} g_Options;
|
||||
|
||||
static const TCHAR *kPliginNameForRegestry = TEXT("7-ZIP");
|
||||
static const char * const kPliginNameForRegistry = "7-ZIP";
|
||||
|
||||
EXTERN_C void WINAPI ExitFAR()
|
||||
{
|
||||
@@ -84,7 +84,7 @@ EXTERN_C void WINAPI ExitFAR()
|
||||
EXTERN_C void WINAPI SetStartupInfo(const PluginStartupInfo *info)
|
||||
{
|
||||
MY_TRY_BEGIN;
|
||||
g_StartupInfo.Init(*info, kPliginNameForRegestry);
|
||||
g_StartupInfo.Init(*info, kPliginNameForRegistry);
|
||||
g_Options.Enabled = g_StartupInfo.QueryRegKeyValue(
|
||||
HKEY_CURRENT_USER, kRegisrtryMainKeyName,
|
||||
kRegisrtryValueNameEnabled, kPluginEnabledDefault);
|
||||
@@ -299,8 +299,7 @@ HRESULT GetPassword(UString &password)
|
||||
if (g_StartupInfo.ShowDialog(76, 6, NULL, dialogItems, kNumItems) < 0)
|
||||
return E_ABORT;
|
||||
|
||||
AString oemPassword = dialogItems[2].Data;
|
||||
password = MultiByteToUnicodeString(oemPassword, CP_OEMCP);
|
||||
password = MultiByteToUnicodeString(dialogItems[2].Data, CP_OEMCP);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -449,7 +448,7 @@ EXTERN_C HANDLE WINAPI OpenPlugin(int openFrom, INT_PTR item)
|
||||
|
||||
if (openFrom == OPEN_COMMANDLINE)
|
||||
{
|
||||
AString fileName = (const char *)item;
|
||||
AString fileName ((const char *)item);
|
||||
if (fileName.IsEmpty())
|
||||
return INVALID_HANDLE_VALUE;
|
||||
if (fileName.Len() >= 2
|
||||
@@ -522,9 +521,9 @@ EXTERN_C int WINAPI GetFindData(HANDLE plugin, struct PluginPanelItem **panelIte
|
||||
|
||||
EXTERN_C void WINAPI FreeFindData(HANDLE plugin, struct PluginPanelItem *panelItems, int itemsNumber)
|
||||
{
|
||||
MY_TRY_BEGIN;
|
||||
// MY_TRY_BEGIN;
|
||||
((CPlugin *)plugin)->FreeFindData(panelItems, itemsNumber);
|
||||
MY_TRY_END1("FreeFindData");
|
||||
// MY_TRY_END1("FreeFindData");
|
||||
}
|
||||
|
||||
EXTERN_C int WINAPI GetFiles(HANDLE plugin, struct PluginPanelItem *panelItems,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "../../../Common/IntToString.h"
|
||||
// #include "../../../Common/IntToString.h"
|
||||
#include "../../../Common/StringConvert.h"
|
||||
|
||||
#ifndef UNDER_CE
|
||||
@@ -19,13 +19,15 @@ namespace NFar {
|
||||
|
||||
CStartupInfo g_StartupInfo;
|
||||
|
||||
const char kRegistryKeyDelimiter = '\\';
|
||||
|
||||
void CStartupInfo::Init(const PluginStartupInfo &pluginStartupInfo,
|
||||
const CSysString &pluginNameForRegestry)
|
||||
const char *pluginNameForRegistry)
|
||||
{
|
||||
m_Data = pluginStartupInfo;
|
||||
m_RegistryPath = GetSystemString(pluginStartupInfo.RootKey);
|
||||
m_RegistryPath += TEXT('\\');
|
||||
m_RegistryPath += pluginNameForRegestry;
|
||||
m_RegistryPath = pluginStartupInfo.RootKey;
|
||||
m_RegistryPath += kRegistryKeyDelimiter;
|
||||
m_RegistryPath += pluginNameForRegistry;
|
||||
}
|
||||
|
||||
const char *CStartupInfo::GetMsgString(int messageId)
|
||||
@@ -114,7 +116,7 @@ static void SplitString(const AString &src, AStringVector &destStrings)
|
||||
int CStartupInfo::ShowErrorMessage(const char *message)
|
||||
{
|
||||
AStringVector strings;
|
||||
SplitString(message, strings);
|
||||
SplitString((AString)message, strings);
|
||||
const unsigned kNumStringsMax = 20;
|
||||
const char *items[kNumStringsMax + 1];
|
||||
unsigned pos = 0;
|
||||
@@ -209,28 +211,31 @@ void CStartupInfo::RestoreScreen(HANDLE handle)
|
||||
m_Data.RestoreScreen(handle);
|
||||
}
|
||||
|
||||
const TCHAR kRegestryKeyDelimiter = TEXT('\'');
|
||||
|
||||
CSysString CStartupInfo::GetFullKeyName(const CSysString &keyName) const
|
||||
CSysString CStartupInfo::GetFullKeyName(const char *keyName) const
|
||||
{
|
||||
return (keyName.IsEmpty()) ? m_RegistryPath:
|
||||
(m_RegistryPath + kRegestryKeyDelimiter + keyName);
|
||||
AString s = m_RegistryPath;
|
||||
if (keyName && *keyName)
|
||||
{
|
||||
s += kRegistryKeyDelimiter;
|
||||
s += keyName;
|
||||
}
|
||||
return (CSysString)s;
|
||||
}
|
||||
|
||||
|
||||
LONG CStartupInfo::CreateRegKey(HKEY parentKey,
|
||||
const CSysString &keyName, NRegistry::CKey &destKey) const
|
||||
const char *keyName, NRegistry::CKey &destKey) const
|
||||
{
|
||||
return destKey.Create(parentKey, GetFullKeyName(keyName));
|
||||
}
|
||||
|
||||
LONG CStartupInfo::OpenRegKey(HKEY parentKey,
|
||||
const CSysString &keyName, NRegistry::CKey &destKey) const
|
||||
const char *keyName, NRegistry::CKey &destKey) const
|
||||
{
|
||||
return destKey.Open(parentKey, GetFullKeyName(keyName));
|
||||
}
|
||||
|
||||
void CStartupInfo::SetRegKeyValue(HKEY parentKey, const CSysString &keyName,
|
||||
void CStartupInfo::SetRegKeyValue(HKEY parentKey, const char *keyName,
|
||||
LPCTSTR valueName, LPCTSTR value) const
|
||||
{
|
||||
NRegistry::CKey regKey;
|
||||
@@ -238,7 +243,7 @@ void CStartupInfo::SetRegKeyValue(HKEY parentKey, const CSysString &keyName,
|
||||
regKey.SetValue(valueName, value);
|
||||
}
|
||||
|
||||
void CStartupInfo::SetRegKeyValue(HKEY parentKey, const CSysString &keyName,
|
||||
void CStartupInfo::SetRegKeyValue(HKEY parentKey, const char *keyName,
|
||||
LPCTSTR valueName, UInt32 value) const
|
||||
{
|
||||
NRegistry::CKey regKey;
|
||||
@@ -246,7 +251,7 @@ void CStartupInfo::SetRegKeyValue(HKEY parentKey, const CSysString &keyName,
|
||||
regKey.SetValue(valueName, value);
|
||||
}
|
||||
|
||||
void CStartupInfo::SetRegKeyValue(HKEY parentKey, const CSysString &keyName,
|
||||
void CStartupInfo::SetRegKeyValue(HKEY parentKey, const char *keyName,
|
||||
LPCTSTR valueName, bool value) const
|
||||
{
|
||||
NRegistry::CKey regKey;
|
||||
@@ -254,7 +259,7 @@ void CStartupInfo::SetRegKeyValue(HKEY parentKey, const CSysString &keyName,
|
||||
regKey.SetValue(valueName, value);
|
||||
}
|
||||
|
||||
CSysString CStartupInfo::QueryRegKeyValue(HKEY parentKey, const CSysString &keyName,
|
||||
CSysString CStartupInfo::QueryRegKeyValue(HKEY parentKey, const char *keyName,
|
||||
LPCTSTR valueName, const CSysString &valueDefault) const
|
||||
{
|
||||
NRegistry::CKey regKey;
|
||||
@@ -268,7 +273,7 @@ CSysString CStartupInfo::QueryRegKeyValue(HKEY parentKey, const CSysString &keyN
|
||||
return value;
|
||||
}
|
||||
|
||||
UInt32 CStartupInfo::QueryRegKeyValue(HKEY parentKey, const CSysString &keyName,
|
||||
UInt32 CStartupInfo::QueryRegKeyValue(HKEY parentKey, const char *keyName,
|
||||
LPCTSTR valueName, UInt32 valueDefault) const
|
||||
{
|
||||
NRegistry::CKey regKey;
|
||||
@@ -282,7 +287,7 @@ UInt32 CStartupInfo::QueryRegKeyValue(HKEY parentKey, const CSysString &keyName,
|
||||
return value;
|
||||
}
|
||||
|
||||
bool CStartupInfo::QueryRegKeyValue(HKEY parentKey, const CSysString &keyName,
|
||||
bool CStartupInfo::QueryRegKeyValue(HKEY parentKey, const char *keyName,
|
||||
LPCTSTR valueName, bool valueDefault) const
|
||||
{
|
||||
NRegistry::CKey regKey;
|
||||
@@ -390,7 +395,7 @@ int CStartupInfo::Menu(
|
||||
unsigned int flags,
|
||||
const char *title,
|
||||
const char *helpTopic,
|
||||
const CSysStringVector &items,
|
||||
const AStringVector &items,
|
||||
int selectedItem)
|
||||
{
|
||||
CRecordVector<FarMenuItem> farMenuItems;
|
||||
@@ -400,8 +405,8 @@ int CStartupInfo::Menu(
|
||||
item.Checked = 0;
|
||||
item.Separator = 0;
|
||||
item.Selected = ((int)i == selectedItem);
|
||||
CSysString reducedString = items[i].Left(ARRAY_SIZE(item.Text) - 1);
|
||||
MyStringCopy(item.Text, (const char *)GetOemString(reducedString));
|
||||
const AString reducedString (items[i].Left(ARRAY_SIZE(item.Text) - 1));
|
||||
MyStringCopy(item.Text, reducedString);
|
||||
farMenuItems.Add(item);
|
||||
}
|
||||
return Menu(flags, title, helpTopic, &farMenuItems.Front(), farMenuItems.Size());
|
||||
@@ -434,11 +439,9 @@ void CScreenRestorer::Restore()
|
||||
|
||||
int PrintErrorMessage(const char *message, unsigned code)
|
||||
{
|
||||
AString s = message;
|
||||
AString s (message);
|
||||
s += " #";
|
||||
char temp[16];
|
||||
ConvertUInt32ToString((UInt32)code, temp);
|
||||
s += temp;
|
||||
s.Add_UInt32((UInt32)code);
|
||||
return g_StartupInfo.ShowErrorMessage(s);
|
||||
}
|
||||
|
||||
@@ -479,10 +482,10 @@ int ShowLastErrorMessage()
|
||||
|
||||
int ShowSysErrorMessage(DWORD errorCode, const wchar_t *name)
|
||||
{
|
||||
UString s = NError::MyFormatMessage(errorCode);
|
||||
AString s1 = UnicodeStringToMultiByte(s, CP_OEMCP);
|
||||
AString s2 = UnicodeStringToMultiByte(name, CP_OEMCP);
|
||||
return g_StartupInfo.ShowErrorMessage2(s1, s2);
|
||||
const UString s = NError::MyFormatMessage(errorCode);
|
||||
return g_StartupInfo.ShowErrorMessage2(
|
||||
UnicodeStringToMultiByte(s, CP_OEMCP),
|
||||
UnicodeStringToMultiByte(name, CP_OEMCP));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -47,17 +47,17 @@ struct CInitDialogItem
|
||||
class CStartupInfo
|
||||
{
|
||||
PluginStartupInfo m_Data;
|
||||
CSysString m_RegistryPath;
|
||||
AString m_RegistryPath;
|
||||
|
||||
CSysString GetFullKeyName(const CSysString &keyName) const;
|
||||
CSysString GetFullKeyName(const char *keyName) const;
|
||||
LONG CreateRegKey(HKEY parentKey,
|
||||
const CSysString &keyName, NWindows::NRegistry::CKey &destKey) const;
|
||||
const char *keyName, NWindows::NRegistry::CKey &destKey) const;
|
||||
LONG OpenRegKey(HKEY parentKey,
|
||||
const CSysString &keyName, NWindows::NRegistry::CKey &destKey) const;
|
||||
const char *keyName, NWindows::NRegistry::CKey &destKey) const;
|
||||
|
||||
public:
|
||||
void Init(const PluginStartupInfo &pluginStartupInfo,
|
||||
const CSysString &pluginNameForRegestry);
|
||||
const char *pluginNameForRegistry);
|
||||
const char *GetMsgString(int messageId);
|
||||
|
||||
int ShowMessage(unsigned int flags, const char *helpTopic,
|
||||
@@ -82,20 +82,20 @@ public:
|
||||
HANDLE SaveScreen();
|
||||
void RestoreScreen(HANDLE handle);
|
||||
|
||||
void SetRegKeyValue(HKEY parentKey, const CSysString &keyName,
|
||||
void SetRegKeyValue(HKEY parentKey, const char *keyName,
|
||||
const LPCTSTR valueName, LPCTSTR value) const;
|
||||
void SetRegKeyValue(HKEY hRoot, const CSysString &keyName,
|
||||
void SetRegKeyValue(HKEY hRoot, const char *keyName,
|
||||
const LPCTSTR valueName, UInt32 value) const;
|
||||
void SetRegKeyValue(HKEY hRoot, const CSysString &keyName,
|
||||
void SetRegKeyValue(HKEY hRoot, const char *keyName,
|
||||
const LPCTSTR valueName, bool value) const;
|
||||
|
||||
CSysString QueryRegKeyValue(HKEY parentKey, const CSysString &keyName,
|
||||
CSysString QueryRegKeyValue(HKEY parentKey, const char *keyName,
|
||||
LPCTSTR valueName, const CSysString &valueDefault) const;
|
||||
|
||||
UInt32 QueryRegKeyValue(HKEY parentKey, const CSysString &keyName,
|
||||
UInt32 QueryRegKeyValue(HKEY parentKey, const char *keyName,
|
||||
LPCTSTR valueName, UInt32 valueDefault) const;
|
||||
|
||||
bool QueryRegKeyValue(HKEY parentKey, const CSysString &keyName,
|
||||
bool QueryRegKeyValue(HKEY parentKey, const char *keyName,
|
||||
LPCTSTR valueName, bool valueDefault) const;
|
||||
|
||||
bool Control(HANDLE plugin, int command, void *param);
|
||||
@@ -131,7 +131,7 @@ public:
|
||||
unsigned int flags,
|
||||
const char *title,
|
||||
const char *helpTopic,
|
||||
const CSysStringVector &items,
|
||||
const AStringVector &items,
|
||||
int selectedItem);
|
||||
|
||||
int Editor(const char *fileName, const char *title,
|
||||
|
||||
@@ -43,23 +43,31 @@ void SetFileInfoStrings(const CFileInfo &fileInfo,
|
||||
fileInfoStrings.Size = "";
|
||||
}
|
||||
|
||||
FILETIME localFileTime;
|
||||
fileInfoStrings.Time.Empty();
|
||||
if (fileInfo.TimeIsDefined)
|
||||
{
|
||||
if (!FileTimeToLocalFileTime(&fileInfo.Time, &localFileTime))
|
||||
throw 4190402;
|
||||
char timeString[32];
|
||||
ConvertFileTimeToString(localFileTime, timeString);
|
||||
ConvertUtcFileTimeToString(fileInfo.Time, timeString);
|
||||
fileInfoStrings.Time = g_StartupInfo.GetMsgString(NMessageID::kOverwriteModifiedOn);
|
||||
fileInfoStrings.Time += ' ';
|
||||
fileInfoStrings.Time += timeString;
|
||||
}
|
||||
}
|
||||
|
||||
static void ReduceString2(UString &s, unsigned size)
|
||||
{
|
||||
if (!s.IsEmpty() && s.Back() == ' ')
|
||||
{
|
||||
// s += (wchar_t)(0x2423);
|
||||
s.InsertAtFront(L'\"');
|
||||
s += L'\"';
|
||||
}
|
||||
ReduceString(s, size);
|
||||
}
|
||||
|
||||
NResult::EEnum Execute(const CFileInfo &oldFileInfo, const CFileInfo &newFileInfo)
|
||||
{
|
||||
const int kYSize = 20;
|
||||
const int kYSize = 22;
|
||||
const int kXSize = 76;
|
||||
|
||||
CFileInfoStrings oldFileInfoStrings;
|
||||
@@ -68,17 +76,30 @@ NResult::EEnum Execute(const CFileInfo &oldFileInfo, const CFileInfo &newFileInf
|
||||
SetFileInfoStrings(oldFileInfo, oldFileInfoStrings);
|
||||
SetFileInfoStrings(newFileInfo, newFileInfoStrings);
|
||||
|
||||
UString oldName2 = oldFileInfo.Name;
|
||||
UString newName2 = newFileInfo.Name;
|
||||
const UString &oldName2 = oldFileInfo.Name;
|
||||
const UString &newName2 = newFileInfo.Name;
|
||||
|
||||
int slashPos = oldName2.ReverseFind_PathSepar();
|
||||
UString pref1 = oldName2.Left(slashPos + 1);
|
||||
UString name1 = oldName2.Ptr(slashPos + 1);
|
||||
|
||||
slashPos = newName2.ReverseFind_PathSepar();
|
||||
UString pref2 = newName2.Left(slashPos + 1);
|
||||
UString name2 = newName2.Ptr(slashPos + 1);
|
||||
|
||||
const unsigned kNameOffset = 2;
|
||||
{
|
||||
const unsigned maxNameLen = kXSize - 9 - 2;
|
||||
ReduceString(oldName2, maxNameLen);
|
||||
ReduceString(newName2, maxNameLen);
|
||||
ReduceString(pref1, maxNameLen);
|
||||
ReduceString(pref2, maxNameLen);
|
||||
ReduceString2(name1, maxNameLen - kNameOffset);
|
||||
ReduceString2(name2, maxNameLen - kNameOffset);
|
||||
}
|
||||
|
||||
AString oldName = UnicodeStringToMultiByte(oldName2);
|
||||
AString newName = UnicodeStringToMultiByte(newName2);
|
||||
AString pref1A (UnicodeStringToMultiByte(pref1, CP_OEMCP));
|
||||
AString pref2A (UnicodeStringToMultiByte(pref2, CP_OEMCP));
|
||||
AString name1A (UnicodeStringToMultiByte(name1, CP_OEMCP));
|
||||
AString name2A (UnicodeStringToMultiByte(name2, CP_OEMCP));
|
||||
|
||||
struct CInitDialogItem initItems[]={
|
||||
{ DI_DOUBLEBOX, 3, 1, kXSize - 4, kYSize - 2, false, false, 0, false, NMessageID::kOverwriteTitle, NULL, NULL },
|
||||
@@ -88,15 +109,17 @@ NResult::EEnum Execute(const CFileInfo &oldFileInfo, const CFileInfo &newFileInf
|
||||
|
||||
{ DI_TEXT, 5, 4, 0, 0, false, false, 0, false, NMessageID::kOverwriteMessageWouldYouLike, NULL, NULL },
|
||||
|
||||
{ DI_TEXT, 7, 6, 0, 0, false, false, 0, false, -1, oldName, NULL },
|
||||
{ DI_TEXT, 7, 7, 0, 0, false, false, 0, false, -1, oldFileInfoStrings.Size, NULL },
|
||||
{ DI_TEXT, 7, 8, 0, 0, false, false, 0, false, -1, oldFileInfoStrings.Time, NULL },
|
||||
{ DI_TEXT, 7, 6, 0, 0, false, false, 0, false, -1, pref1A, NULL },
|
||||
{ DI_TEXT, 7 + kNameOffset, 7, 0, 0, false, false, 0, false, -1, name1A, NULL },
|
||||
{ DI_TEXT, 7, 8, 0, 0, false, false, 0, false, -1, oldFileInfoStrings.Size, NULL },
|
||||
{ DI_TEXT, 7, 9, 0, 0, false, false, 0, false, -1, oldFileInfoStrings.Time, NULL },
|
||||
|
||||
{ DI_TEXT, 5, 10, 0, 0, false, false, 0, false, NMessageID::kOverwriteMessageWithtTisOne, NULL, NULL },
|
||||
{ DI_TEXT, 5, 11, 0, 0, false, false, 0, false, NMessageID::kOverwriteMessageWithtTisOne, NULL, NULL },
|
||||
|
||||
{ DI_TEXT, 7, 12, 0, 0, false, false, 0, false, -1, newName, NULL },
|
||||
{ DI_TEXT, 7, 13, 0, 0, false, false, 0, false, -1, newFileInfoStrings.Size, NULL },
|
||||
{ DI_TEXT, 7, 14, 0, 0, false, false, 0, false, -1, newFileInfoStrings.Time, NULL },
|
||||
{ DI_TEXT, 7, 13, 0, 0, false, false, 0, false, -1, pref2A, NULL },
|
||||
{ DI_TEXT, 7 + kNameOffset, 14, 0, 0, false, false, 0, false, -1, name2A, NULL },
|
||||
{ DI_TEXT, 7, 15, 0, 0, false, false, 0, false, -1, newFileInfoStrings.Size, NULL },
|
||||
{ DI_TEXT, 7, 16, 0, 0, false, false, 0, false, -1, newFileInfoStrings.Time, NULL },
|
||||
|
||||
{ DI_TEXT, 3, kYSize - 5, 0, 0, false, false, DIF_BOXCOLOR|DIF_SEPARATOR, false, -1, "", NULL },
|
||||
|
||||
|
||||
@@ -30,7 +30,8 @@ int CompareFileNames_ForFolderList(const wchar_t *s1, const wchar_t *s2)
|
||||
CPlugin::CPlugin(const FString &fileName, CAgent *agent, UString archiveTypeName):
|
||||
_agent(agent),
|
||||
m_FileName(fileName),
|
||||
_archiveTypeName(archiveTypeName)
|
||||
_archiveTypeName(archiveTypeName),
|
||||
PasswordIsDefined(false)
|
||||
{
|
||||
m_ArchiveHandler = agent;
|
||||
if (!m_FileInfo.Find(m_FileName))
|
||||
@@ -82,7 +83,7 @@ void CPlugin::ReadPluginPanelItem(PluginPanelItem &panelItem, UInt32 itemIndex)
|
||||
if (prop.vt != VT_BSTR)
|
||||
throw 272340;
|
||||
|
||||
AString oemString = UnicodeStringToMultiByte(prop.bstrVal, CP_OEMCP);
|
||||
AString oemString (UnicodeStringToMultiByte(prop.bstrVal, CP_OEMCP));
|
||||
if (oemString == "..")
|
||||
oemString = kDotsReplaceString;
|
||||
|
||||
@@ -193,7 +194,7 @@ void CPlugin::EnterToDirectory(const UString &dirName)
|
||||
CMyComPtr<IFolderFolder> newFolder;
|
||||
UString s = dirName;
|
||||
if (dirName == kDotsReplaceStringU)
|
||||
s = L"..";
|
||||
s = "..";
|
||||
_folder->BindToFolder(s, &newFolder);
|
||||
if (!newFolder)
|
||||
if (dirName.IsEmpty())
|
||||
@@ -281,7 +282,7 @@ void CPlugin::SetCurrentDirVar()
|
||||
}
|
||||
}
|
||||
|
||||
static const char *kPluginFormatName = "7-ZIP";
|
||||
static const char * const kPluginFormatName = "7-ZIP";
|
||||
|
||||
|
||||
static int FindPropNameID(PROPID propID)
|
||||
@@ -371,17 +372,17 @@ static AString GetNameOfProp(PROPID propID, const wchar_t *name)
|
||||
{
|
||||
int farID = FindPropNameID(propID);
|
||||
if (farID >= 0)
|
||||
return g_StartupInfo.GetMsgString(farID);
|
||||
return (AString)g_StartupInfo.GetMsgString(farID);
|
||||
if (name)
|
||||
return UnicodeStringToMultiByte((const wchar_t *)name, CP_OEMCP);
|
||||
return UnicodeStringToMultiByte(name, CP_OEMCP);
|
||||
char s[16];
|
||||
ConvertUInt32ToString(propID, s);
|
||||
return s;
|
||||
return (AString)s;
|
||||
}
|
||||
|
||||
static AString GetNameOfProp2(PROPID propID, const wchar_t *name)
|
||||
{
|
||||
AString s = GetNameOfProp(propID, name);
|
||||
AString s (GetNameOfProp(propID, name));
|
||||
if (s.Len() > (kInfoPanelLineSize - 1))
|
||||
s.DeleteFrom(kInfoPanelLineSize - 1);
|
||||
return s;
|
||||
@@ -403,14 +404,14 @@ static AString ConvertSizeToString(UInt64 value)
|
||||
}
|
||||
while (i > 0)
|
||||
s[--pos] = s[--i];
|
||||
return s + pos;
|
||||
return (AString)(s + pos);
|
||||
}
|
||||
|
||||
static AString PropToString(const NCOM::CPropVariant &prop, PROPID propID)
|
||||
{
|
||||
if (prop.vt == VT_BSTR)
|
||||
{
|
||||
AString s = UnicodeStringToMultiByte(prop.bstrVal, CP_OEMCP);
|
||||
AString s (UnicodeStringToMultiByte(prop.bstrVal, CP_OEMCP));
|
||||
s.Replace((char)0xA, ' ');
|
||||
s.Replace((char)0xD, ' ');
|
||||
return s;
|
||||
@@ -419,7 +420,7 @@ static AString PropToString(const NCOM::CPropVariant &prop, PROPID propID)
|
||||
{
|
||||
int messageID = VARIANT_BOOLToBool(prop.boolVal) ?
|
||||
NMessageID::kYes : NMessageID::kNo;
|
||||
return g_StartupInfo.GetMsgString(messageID);
|
||||
return (AString)g_StartupInfo.GetMsgString(messageID);
|
||||
}
|
||||
if (prop.vt != VT_EMPTY)
|
||||
{
|
||||
@@ -441,8 +442,8 @@ static AString PropToString(const NCOM::CPropVariant &prop, PROPID propID)
|
||||
}
|
||||
{
|
||||
char sz[64];
|
||||
ConvertPropertyToShortString(sz, prop, propID);
|
||||
return sz;
|
||||
ConvertPropertyToShortString2(sz, prop, propID);
|
||||
return (AString)sz;
|
||||
}
|
||||
}
|
||||
return AString();
|
||||
@@ -450,7 +451,7 @@ static AString PropToString(const NCOM::CPropVariant &prop, PROPID propID)
|
||||
|
||||
static AString PropToString2(const NCOM::CPropVariant &prop, PROPID propID)
|
||||
{
|
||||
AString s = PropToString(prop, propID);
|
||||
AString s (PropToString(prop, propID));
|
||||
if (s.Len() > (kInfoPanelLineSize - 1))
|
||||
s.DeleteFrom(kInfoPanelLineSize - 1);
|
||||
return s;
|
||||
@@ -461,7 +462,7 @@ static void AddPropertyString(InfoPanelLine *lines, int &numItems, PROPID propID
|
||||
{
|
||||
if (prop.vt != VT_EMPTY)
|
||||
{
|
||||
AString val = PropToString2(prop, propID);
|
||||
AString val (PropToString2(prop, propID));
|
||||
if (!val.IsEmpty())
|
||||
{
|
||||
InfoPanelLine &item = lines[numItems++];
|
||||
@@ -504,9 +505,9 @@ void CPlugin::GetOpenPluginInfo(struct OpenPluginInfo *info)
|
||||
name = fs2us(fileName);
|
||||
}
|
||||
|
||||
m_PannelTitle = L' ';
|
||||
m_PannelTitle = ' ';
|
||||
m_PannelTitle += _archiveTypeName;
|
||||
m_PannelTitle += L':';
|
||||
m_PannelTitle += ':';
|
||||
m_PannelTitle += name;
|
||||
m_PannelTitle.Add_Space();
|
||||
if (!m_CurrentDir.IsEmpty())
|
||||
@@ -748,8 +749,7 @@ HRESULT CPlugin::ShowAttributesWindow()
|
||||
|
||||
NCOM::CPropVariant prop;
|
||||
RINOK(_folder->GetProperty(itemIndex, property.ID, &prop));
|
||||
AString s = PropToString(prop, property.ID);
|
||||
values.Add(s);
|
||||
values.Add(PropToString(prop, property.ID));
|
||||
|
||||
{
|
||||
const CInitDialogItem idi =
|
||||
@@ -803,10 +803,8 @@ HRESULT CPlugin::ShowAttributesWindow()
|
||||
const UInt32 kMaxDataSize = 64;
|
||||
if (dataSize > kMaxDataSize)
|
||||
{
|
||||
char temp[64];
|
||||
s += "data:";
|
||||
ConvertUInt32ToString(dataSize, temp);
|
||||
s += temp;
|
||||
s.Add_UInt32(dataSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -84,6 +84,8 @@ int CPlugin::DeleteFiles(PluginPanelItem *panelItems, int numItems, int opMode)
|
||||
CMyComPtr<IFolderArchiveUpdateCallback> updateCallback(updateCallbackSpec);
|
||||
|
||||
updateCallbackSpec->Init(/* m_ArchiveHandler, */ progressBoxPointer);
|
||||
updateCallbackSpec->PasswordIsDefined = PasswordIsDefined;
|
||||
updateCallbackSpec->Password = Password;
|
||||
|
||||
/*
|
||||
outArchive->SetFolder(_folder);
|
||||
|
||||
@@ -21,11 +21,11 @@ using namespace NFile;
|
||||
using namespace NDir;
|
||||
using namespace NFar;
|
||||
|
||||
static const char *kHelpTopicExtrFromSevenZip = "Extract";
|
||||
static const char * const kHelpTopicExtrFromSevenZip = "Extract";
|
||||
|
||||
static const char kDirDelimiter = '\\';
|
||||
static const char kDirDelimiter = CHAR_PATH_SEPARATOR;
|
||||
|
||||
static const char *kExractPathHistoryName = "7-ZipExtractPath";
|
||||
static const char * const kExractPathHistoryName = "7-ZipExtractPath";
|
||||
|
||||
HRESULT CPlugin::ExtractFiles(
|
||||
bool decompressAllItems,
|
||||
@@ -95,7 +95,7 @@ NFileOperationReturnCode::EEnum CPlugin::GetFilesReal(struct PluginPanelItem *pa
|
||||
return NFileOperationReturnCode::kError;
|
||||
}
|
||||
|
||||
AString destPath = destPathLoc;
|
||||
AString destPath (destPathLoc);
|
||||
UString destPathU = GetUnicodeString(destPath, CP_OEMCP);
|
||||
NName::NormalizeDirPathPrefix(destPathU);
|
||||
destPath = UnicodeStringToMultiByte(destPathU, CP_OEMCP);
|
||||
@@ -127,7 +127,7 @@ NFileOperationReturnCode::EEnum CPlugin::GetFilesReal(struct PluginPanelItem *pa
|
||||
|
||||
const int kXMid = kXSize / 2;
|
||||
|
||||
AString oemPassword = UnicodeStringToMultiByte(password, CP_OEMCP);
|
||||
AString oemPassword (UnicodeStringToMultiByte(password, CP_OEMCP));
|
||||
|
||||
struct CInitDialogItem initItems[]={
|
||||
{ DI_DOUBLEBOX, 3, 1, kXSize - 4, kYSize - 2, false, false, 0, false, NMessageID::kExtractTitle, NULL, NULL },
|
||||
@@ -196,7 +196,7 @@ NFileOperationReturnCode::EEnum CPlugin::GetFilesReal(struct PluginPanelItem *pa
|
||||
if (destPathU.IsEmpty())
|
||||
{
|
||||
#ifdef UNDER_CE
|
||||
destPathU = L"\\";
|
||||
destPathU = "\\";
|
||||
#else
|
||||
FString destPathF = us2fs(destPathU);
|
||||
if (!GetCurrentDir(destPathF))
|
||||
|
||||
@@ -27,9 +27,9 @@ using namespace NFar;
|
||||
|
||||
using namespace NUpdateArchive;
|
||||
|
||||
static const char *kHelpTopic = "Update";
|
||||
static const char * const kHelpTopic = "Update";
|
||||
|
||||
static const char *kArchiveHistoryKeyName = "7-ZipArcName";
|
||||
static const char * const kArchiveHistoryKeyName = "7-ZipArcName";
|
||||
|
||||
static const UInt32 g_MethodMap[] = { 0, 1, 3, 5, 7, 9 };
|
||||
|
||||
@@ -38,13 +38,18 @@ static HRESULT SetOutProperties(IOutFolderArchive *outArchive, UInt32 method)
|
||||
CMyComPtr<ISetProperties> setProperties;
|
||||
if (outArchive->QueryInterface(IID_ISetProperties, (void **)&setProperties) == S_OK)
|
||||
{
|
||||
/*
|
||||
UStringVector realNames;
|
||||
realNames.Add(UString(L"x"));
|
||||
realNames.Add(UString("x"));
|
||||
NCOM::CPropVariant value = (UInt32)method;
|
||||
CRecordVector<const wchar_t *> names;
|
||||
FOR_VECTOR (i, realNames)
|
||||
names.Add(realNames[i]);
|
||||
RINOK(setProperties->SetProperties(&names.Front(), &value, names.Size()));
|
||||
*/
|
||||
NCOM::CPropVariant value = (UInt32)method;
|
||||
const wchar_t *name = L"x";
|
||||
RINOK(setProperties->SetProperties(&name, &value, 1));
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
@@ -219,6 +224,8 @@ NFileOperationReturnCode::EEnum CPlugin::PutFiles(
|
||||
CMyComPtr<IFolderArchiveUpdateCallback> updateCallback(updateCallbackSpec );
|
||||
|
||||
updateCallbackSpec->Init(/* m_ArchiveHandler, */ progressBoxPointer);
|
||||
updateCallbackSpec->PasswordIsDefined = PasswordIsDefined;
|
||||
updateCallbackSpec->Password = Password;
|
||||
|
||||
if (SetOutProperties(outArchive, compressionInfo.Level) != S_OK)
|
||||
return NFileOperationReturnCode::kError;
|
||||
@@ -287,7 +294,7 @@ struct CParsedPath
|
||||
UString MergePath() const;
|
||||
};
|
||||
|
||||
static const wchar_t kDirDelimiter = WCHAR_PATH_SEPARATOR;
|
||||
static const char kDirDelimiter = CHAR_PATH_SEPARATOR;
|
||||
static const wchar_t kDiskDelimiter = L':';
|
||||
|
||||
namespace NPathType
|
||||
@@ -322,7 +329,7 @@ void CParsedPath::ParsePath(const UString &path)
|
||||
case NPathType::kUNC:
|
||||
{
|
||||
// the bug was fixed:
|
||||
curPos = path.Find(kDirDelimiter, 2);
|
||||
curPos = path.Find((wchar_t)kDirDelimiter, 2);
|
||||
if (curPos < 0)
|
||||
curPos = path.Len();
|
||||
else
|
||||
@@ -355,7 +362,7 @@ static void SetArcName(UString &arcName, const CArcInfoEx &arcInfo)
|
||||
if (dotPos > slashPos + 1)
|
||||
arcName.DeleteFrom(dotPos);
|
||||
}
|
||||
arcName += L'.';
|
||||
arcName += '.';
|
||||
arcName += arcInfo.GetMainExt();
|
||||
}
|
||||
|
||||
@@ -444,7 +451,7 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
|
||||
|
||||
for (;;)
|
||||
{
|
||||
AString archiveNameA = UnicodeStringToMultiByte(arcName, CP_OEMCP);
|
||||
AString archiveNameA (UnicodeStringToMultiByte(arcName, CP_OEMCP));
|
||||
const int kYSize = 16;
|
||||
const int kXMid = 38;
|
||||
|
||||
@@ -456,7 +463,7 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
|
||||
char updateAddToArchiveString[512];
|
||||
{
|
||||
const CArcInfoEx &arcInfo = codecs->Formats[archiverIndex];
|
||||
const AString s = UnicodeStringToMultiByte(arcInfo.Name, CP_OEMCP);
|
||||
const AString s (UnicodeStringToMultiByte(arcInfo.Name, CP_OEMCP));
|
||||
sprintf(updateAddToArchiveString,
|
||||
g_StartupInfo.GetMsgString(NMessageID::kUpdateAddToArchive), (const char *)s);
|
||||
}
|
||||
@@ -530,14 +537,14 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
|
||||
if (askCode == kSelectarchiverButtonIndex)
|
||||
{
|
||||
CIntVector indices;
|
||||
CSysStringVector archiverNames;
|
||||
AStringVector archiverNames;
|
||||
FOR_VECTOR (k, codecs->Formats)
|
||||
{
|
||||
const CArcInfoEx &arc = codecs->Formats[k];
|
||||
if (arc.UpdateEnabled)
|
||||
{
|
||||
indices.Add(k);
|
||||
archiverNames.Add(GetSystemString(arc.Name, CP_OEMCP));
|
||||
archiverNames.Add(GetOemString(arc.Name));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -704,7 +711,7 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
|
||||
}
|
||||
|
||||
|
||||
static const char *k_CreateFolder_History = "NewFolder"; // we use default FAR folder name
|
||||
static const char * const k_CreateFolder_History = "NewFolder"; // we use default FAR folder name
|
||||
|
||||
HRESULT CPlugin::CreateFolder()
|
||||
{
|
||||
@@ -720,7 +727,7 @@ HRESULT CPlugin::CreateFolder()
|
||||
const int kYSize = 8;
|
||||
const int kPathIndex = 2;
|
||||
|
||||
AString destPath = "New Folder";
|
||||
AString destPath ("New Folder");
|
||||
|
||||
const struct CInitDialogItem initItems[]={
|
||||
{ DI_DOUBLEBOX, 3, 1, kXSize - 4, kYSize - 2, false, false, 0, false,
|
||||
@@ -773,6 +780,8 @@ HRESULT CPlugin::CreateFolder()
|
||||
CMyComPtr<IFolderArchiveUpdateCallback> updateCallback(updateCallbackSpec);
|
||||
|
||||
updateCallbackSpec->Init(/* m_ArchiveHandler, */ progressBoxPointer);
|
||||
updateCallbackSpec->PasswordIsDefined = PasswordIsDefined;
|
||||
updateCallbackSpec->Password = Password;
|
||||
|
||||
HRESULT result;
|
||||
{
|
||||
@@ -797,7 +806,7 @@ HRESULT CPlugin::CreateFolder()
|
||||
|
||||
if (g_StartupInfo.ControlGetActivePanelInfo(panelInfo))
|
||||
{
|
||||
AString destPath = GetOemString(destPathU);
|
||||
const AString destPath (GetOemString(destPathU));
|
||||
|
||||
for (int i = 0; i < panelInfo.ItemsNumber; i++)
|
||||
{
|
||||
|
||||
@@ -18,7 +18,7 @@ void CPercentPrinterState::ClearCurState()
|
||||
FileName.Empty();
|
||||
}
|
||||
|
||||
void CProgressBox::Init(const AString &title)
|
||||
void CProgressBox::Init(const char *title)
|
||||
{
|
||||
_title = title;
|
||||
_wasPrinted = false;
|
||||
@@ -218,14 +218,13 @@ void CProgressBox::Print()
|
||||
unsigned filled = 0;
|
||||
if (total != (UInt64)(Int64)-1 && total != 0)
|
||||
filled = (unsigned)(cur * numChars / total);
|
||||
if (filled > numChars)
|
||||
filled = numChars;
|
||||
unsigned i = 0;
|
||||
if (filled < numChars)
|
||||
{
|
||||
for (i = 0; i < filled; i++)
|
||||
_perc += '=';
|
||||
}
|
||||
for (i = 0; i < filled; i++)
|
||||
_perc += (char)(Byte)0xDB; // '=';
|
||||
for (; i < numChars; i++)
|
||||
_perc += '.';
|
||||
_perc += (char)(Byte)0xB0; // '.';
|
||||
}
|
||||
|
||||
_perc.Add_Space();
|
||||
|
||||
@@ -76,7 +76,7 @@ public:
|
||||
MaxLen(60)
|
||||
{}
|
||||
|
||||
void Init(const AString &title);
|
||||
void Init(const char *title);
|
||||
void Print();
|
||||
};
|
||||
|
||||
|
||||
@@ -62,6 +62,20 @@ STDMETHODIMP CUpdateCallback100Imp::SetNumFiles(UInt64 numFiles)
|
||||
return CheckBreak2();
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CUpdateCallback100Imp::SetTotal(const UInt64 * /* files */, const UInt64 * /* bytes */)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CUpdateCallback100Imp::SetCompleted(const UInt64 * /* files */, const UInt64 * /* bytes */)
|
||||
{
|
||||
MT_LOCK
|
||||
return CheckBreak2();
|
||||
}
|
||||
|
||||
|
||||
|
||||
STDMETHODIMP CUpdateCallback100Imp::SetTotal(UInt64 size)
|
||||
{
|
||||
MT_LOCK
|
||||
@@ -203,10 +217,21 @@ STDMETHODIMP CUpdateCallback100Imp::CryptoGetTextPassword(BSTR *password)
|
||||
MT_LOCK
|
||||
|
||||
*password = NULL;
|
||||
if (!m_PasswordIsDefined)
|
||||
if (!PasswordIsDefined)
|
||||
{
|
||||
RINOK(GetPassword(m_Password));
|
||||
m_PasswordIsDefined = true;
|
||||
RINOK(GetPassword(Password));
|
||||
PasswordIsDefined = true;
|
||||
}
|
||||
return StringToBstr(m_Password, password);
|
||||
return StringToBstr(Password, password);
|
||||
}
|
||||
|
||||
STDMETHODIMP CUpdateCallback100Imp::CryptoGetTextPassword2(Int32 *passwordIsDefined, BSTR *password)
|
||||
{
|
||||
MT_LOCK
|
||||
|
||||
*password = NULL;
|
||||
*passwordIsDefined = BoolToInt(PasswordIsDefined);
|
||||
if (!PasswordIsDefined)
|
||||
return S_OK;
|
||||
return StringToBstr(Password, password);
|
||||
}
|
||||
|
||||
@@ -15,35 +15,45 @@ class CUpdateCallback100Imp:
|
||||
public IFolderArchiveUpdateCallback,
|
||||
public IFolderArchiveUpdateCallback2,
|
||||
public IFolderScanProgress,
|
||||
public ICryptoGetTextPassword2,
|
||||
public ICryptoGetTextPassword,
|
||||
public IArchiveOpenCallback,
|
||||
public CMyUnknownImp
|
||||
{
|
||||
// CMyComPtr<IInFolderArchive> _archiveHandler;
|
||||
CProgressBox *_percent;
|
||||
UInt64 _total;
|
||||
bool m_PasswordIsDefined;
|
||||
UString m_Password;
|
||||
|
||||
public:
|
||||
MY_UNKNOWN_IMP4(
|
||||
|
||||
bool PasswordIsDefined;
|
||||
UString Password;
|
||||
|
||||
MY_UNKNOWN_IMP6(
|
||||
IFolderArchiveUpdateCallback,
|
||||
IFolderArchiveUpdateCallback2,
|
||||
IFolderScanProgress,
|
||||
ICryptoGetTextPassword)
|
||||
ICryptoGetTextPassword2,
|
||||
ICryptoGetTextPassword,
|
||||
IArchiveOpenCallback
|
||||
)
|
||||
|
||||
INTERFACE_IProgress(;)
|
||||
INTERFACE_IFolderArchiveUpdateCallback(;)
|
||||
INTERFACE_IFolderArchiveUpdateCallback2(;)
|
||||
INTERFACE_IFolderScanProgress(;)
|
||||
INTERFACE_IArchiveOpenCallback(;)
|
||||
|
||||
STDMETHOD(CryptoGetTextPassword)(BSTR *password);
|
||||
STDMETHOD(CryptoGetTextPassword2)(Int32 *passwordIsDefined, BSTR *password);
|
||||
|
||||
CUpdateCallback100Imp(): _total(0) {}
|
||||
void Init(/* IInFolderArchive *archiveHandler, */ CProgressBox *progressBox)
|
||||
{
|
||||
// _archiveHandler = archiveHandler;
|
||||
_percent = progressBox;
|
||||
m_PasswordIsDefined = false;
|
||||
PasswordIsDefined = false;
|
||||
Password.Empty();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@ static const UInt32 kLangIDs[] =
|
||||
IDT_ABOUT_INFO
|
||||
};
|
||||
|
||||
static LPCTSTR kHomePageURL = TEXT("http://www.7-zip.org/");
|
||||
static LPCWSTR kHelpTopic = L"start.htm";
|
||||
#define kHomePageURL TEXT("http://www.7-zip.org/")
|
||||
#define kHelpTopic "start.htm"
|
||||
|
||||
#define LLL_(quote) L##quote
|
||||
#define LLL(quote) LLL_(quote)
|
||||
@@ -26,14 +26,7 @@ static LPCWSTR kHelpTopic = L"start.htm";
|
||||
bool CAboutDialog::OnInit()
|
||||
{
|
||||
LangSetDlgItems(*this, kLangIDs, ARRAY_SIZE(kLangIDs));
|
||||
UString s = L"7-Zip " LLL(MY_VERSION);
|
||||
#ifdef MY_CPU_64BIT
|
||||
s += L" [";
|
||||
AddLangString(s, IDS_PROP_BIT64);
|
||||
s += L']';
|
||||
#endif
|
||||
|
||||
SetItemText(IDT_ABOUT_VERSION, s);
|
||||
SetItemText(IDT_ABOUT_VERSION, UString("7-Zip " MY_VERSION_CPU));
|
||||
SetItemText(IDT_ABOUT_DATE, LLL(MY_DATE));
|
||||
|
||||
LangSetWindowText(*this, IDD_ABOUT);
|
||||
@@ -43,7 +36,7 @@ bool CAboutDialog::OnInit()
|
||||
|
||||
void CAboutDialog::OnHelp()
|
||||
{
|
||||
ShowHelpWindow(NULL, kHelpTopic);
|
||||
ShowHelpWindow(kHelpTopic);
|
||||
}
|
||||
|
||||
bool CAboutDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
|
||||
|
||||
@@ -274,7 +274,7 @@ STDMETHODIMP CAltStreamsFolder::BindToFolder(const wchar_t * /* name */, IFolder
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
static const CFSTR kSuperPrefix = FTEXT("\\\\?\\");
|
||||
// static CFSTR const kSuperPrefix = FTEXT("\\\\?\\");
|
||||
|
||||
STDMETHODIMP CAltStreamsFolder::BindToParentFolder(IFolderFolder **resultFolder)
|
||||
{
|
||||
@@ -408,7 +408,7 @@ static HRESULT SendMessageError(IFolderOperationsExtractCallback *callback,
|
||||
const wchar_t *message, const FString &fileName)
|
||||
{
|
||||
UString s = message;
|
||||
s += L" : ";
|
||||
s += " : ";
|
||||
s += fs2us(fileName);
|
||||
return callback->ShowMessage(s);
|
||||
}
|
||||
@@ -417,7 +417,7 @@ static HRESULT SendMessageError(IFolderArchiveUpdateCallback *callback,
|
||||
const wchar_t *message, const FString &fileName)
|
||||
{
|
||||
UString s = message;
|
||||
s += L" : ";
|
||||
s += " : ";
|
||||
s += fs2us(fileName);
|
||||
return callback->UpdateErrorMessage(s);
|
||||
}
|
||||
@@ -629,7 +629,7 @@ static HRESULT CopyStream(
|
||||
if (IntToBool(writeAskResult))
|
||||
{
|
||||
RINOK(callback->SetCurrentFilePath(fs2us(srcPath)));
|
||||
FString destPathNew = us2fs((LPCOLESTR)destPathResult);
|
||||
FString destPathNew (us2fs((LPCOLESTR)destPathResult));
|
||||
RINOK(state.MyCopyFile(srcPath, destPathNew));
|
||||
if (state.ErrorFileIndex >= 0)
|
||||
{
|
||||
@@ -712,7 +712,7 @@ STDMETHODIMP CAltStreamsFolder::CopyTo(Int32 moveMode, const UInt32 *indices, UI
|
||||
}
|
||||
*/
|
||||
|
||||
FString destPath = us2fs(path);
|
||||
FString destPath (us2fs(path));
|
||||
if (destPath.IsEmpty() /* && !ExtractToStreamCallback */)
|
||||
return E_INVALIDARG;
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "FormatUtils.h"
|
||||
#include "IFolder.h"
|
||||
#include "LangUtils.h"
|
||||
#include "MyLoadMenu.h"
|
||||
#include "RegistryUtils.h"
|
||||
#include "ViewSettings.h"
|
||||
|
||||
@@ -37,7 +38,7 @@ using namespace NName;
|
||||
extern DWORD g_ComCtl32Version;
|
||||
extern HINSTANCE g_hInstance;
|
||||
|
||||
static CFSTR kTempDirPrefix = FTEXT("7zE");
|
||||
#define kTempDirPrefix FTEXT("7zE")
|
||||
|
||||
void CPanelCallbackImp::OnTab()
|
||||
{
|
||||
@@ -281,9 +282,6 @@ void CApp::SaveToolbarChanges()
|
||||
}
|
||||
|
||||
|
||||
void MyLoadMenu();
|
||||
|
||||
|
||||
HRESULT CApp::Create(HWND hwnd, const UString &mainPath, const UString &arcFormat, int xSizes[2], bool needOpenArc, bool &archiveIsOpened, bool &encrypted)
|
||||
{
|
||||
_window.Attach(hwnd);
|
||||
@@ -460,7 +458,7 @@ static void AddSizeValue(UString &s, UInt64 size)
|
||||
static void AddValuePair1(UString &s, UINT resourceID, UInt64 size)
|
||||
{
|
||||
AddLangString(s, resourceID);
|
||||
s += L": ";
|
||||
s += ": ";
|
||||
AddSizeValue(s, size);
|
||||
s.Add_LF();
|
||||
}
|
||||
@@ -470,14 +468,14 @@ void AddValuePair2(UString &s, UINT resourceID, UInt64 num, UInt64 size)
|
||||
if (num == 0)
|
||||
return;
|
||||
AddLangString(s, resourceID);
|
||||
s += L": ";
|
||||
s += ": ";
|
||||
s += ConvertSizeToString(num);
|
||||
|
||||
if (size != (UInt64)(Int64)-1)
|
||||
{
|
||||
s += L" ( ";
|
||||
s += " ( ";
|
||||
AddSizeValue(s, size);
|
||||
s += L" )";
|
||||
s += " )";
|
||||
}
|
||||
s.Add_LF();
|
||||
}
|
||||
@@ -529,14 +527,18 @@ UString CPanel::GetItemsInfoString(const CRecordVector<UInt32> &indices)
|
||||
|
||||
for (i = 0; i < indices.Size() && (int)i < (int)kCopyDialog_NumInfoLines - 6; i++)
|
||||
{
|
||||
info += L"\n ";
|
||||
info.Add_LF();
|
||||
info += " ";
|
||||
int index = indices[i];
|
||||
info += GetItemRelPath(index);
|
||||
if (IsItem_Folder(index))
|
||||
info.Add_PathSepar();
|
||||
}
|
||||
if (i != indices.Size())
|
||||
info += L"\n ...";
|
||||
{
|
||||
info.Add_LF();
|
||||
info += " ...";
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
@@ -697,7 +699,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
|
||||
else
|
||||
{
|
||||
if (indices.Size() == 1 &&
|
||||
!destPath.IsEmpty() && destPath.Back() != WCHAR_PATH_SEPARATOR)
|
||||
!destPath.IsEmpty() && !IS_PATH_SEPAR(destPath.Back()))
|
||||
{
|
||||
int pos = destPath.ReverseFind_PathSepar();
|
||||
if (pos < 0)
|
||||
@@ -810,7 +812,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
|
||||
// srcPanel.InvalidateList(NULL, true);
|
||||
|
||||
if (result != E_ABORT)
|
||||
srcPanel.MessageBoxError(result, L"Error");
|
||||
srcPanel.MessageBoxError(result);
|
||||
// return;
|
||||
}
|
||||
|
||||
@@ -862,12 +864,24 @@ void CApp::OnSetSubFolder(int srcPanelIndex)
|
||||
{
|
||||
if (srcPanel._folder->BindToParentFolder(&newFolder) != S_OK)
|
||||
return;
|
||||
if (!newFolder)
|
||||
{
|
||||
const UString parentPrefix = srcPanel.GetParentDirPrefix();
|
||||
bool archiveIsOpened, encrypted;
|
||||
destPanel.BindToPath(parentPrefix, UString(), archiveIsOpened, encrypted);
|
||||
destPanel.RefreshListCtrl();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (srcPanel._folder->BindToFolder(realIndex, &newFolder) != S_OK)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!newFolder)
|
||||
return;
|
||||
|
||||
destPanel.CloseOpenFolders();
|
||||
destPanel.SetNewFolder(newFolder);
|
||||
destPanel.RefreshListCtrl();
|
||||
@@ -927,7 +941,7 @@ void CApp::RefreshTitle(bool always)
|
||||
{
|
||||
UString path = GetFocusedPanel()._currentFolderPrefix;
|
||||
if (path.IsEmpty())
|
||||
path = L"7-Zip"; // LangString(IDS_APP_TITLE);
|
||||
path = "7-Zip"; // LangString(IDS_APP_TITLE);
|
||||
if (!always && path == PrevTitle)
|
||||
return;
|
||||
PrevTitle = path;
|
||||
|
||||
@@ -195,7 +195,7 @@ public:
|
||||
void MoveTo() { OnCopy(true, false, GetFocusedPanelIndex()); }
|
||||
void Delete(bool toRecycleBin) { GetFocusedPanel().DeleteItems(toRecycleBin); }
|
||||
HRESULT CalculateCrc2(const UString &methodName);
|
||||
void CalculateCrc(const UString &methodName);
|
||||
void CalculateCrc(const char *methodName);
|
||||
void DiffFiles();
|
||||
void Split();
|
||||
void Combine();
|
||||
@@ -259,7 +259,23 @@ public:
|
||||
void SetListSettings();
|
||||
HRESULT SwitchOnOffOnePanel();
|
||||
|
||||
CIntVector _timestampLevels;
|
||||
|
||||
bool GetFlatMode() { return Panels[LastFocusedPanel].GetFlatMode(); }
|
||||
|
||||
int GetTimestampLevel() const { return Panels[LastFocusedPanel]._timestampLevel; }
|
||||
void SetTimestampLevel(int level)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < kNumPanelsMax; i++)
|
||||
{
|
||||
CPanel &panel = Panels[i];
|
||||
panel._timestampLevel = level;
|
||||
if (panel.PanelCreated)
|
||||
panel.RedrawListItems();
|
||||
}
|
||||
}
|
||||
|
||||
// bool Get_ShowNtfsStrems_Mode() { return Panels[LastFocusedPanel].Get_ShowNtfsStrems_Mode(); }
|
||||
|
||||
void ChangeFlatMode() { Panels[LastFocusedPanel].ChangeFlatMode(); }
|
||||
|
||||
@@ -209,7 +209,7 @@ bool CBrowseDialog::OnInit()
|
||||
if (!FilterDescription.IsEmpty())
|
||||
s = FilterDescription;
|
||||
else if (ShowAllFiles)
|
||||
s = L"*.*";
|
||||
s = "*.*";
|
||||
else
|
||||
{
|
||||
FOR_VECTOR (i, Filters)
|
||||
@@ -468,11 +468,11 @@ bool CBrowseDialog::GetParentPath(const UString &path, UString &parentPrefix, US
|
||||
if (_topDirPrefix == path)
|
||||
return false;
|
||||
UString s = path;
|
||||
if (s.Back() == WCHAR_PATH_SEPARATOR)
|
||||
if (IS_PATH_SEPAR(s.Back()))
|
||||
s.DeleteBack();
|
||||
if (s.IsEmpty())
|
||||
return false;
|
||||
if (s.Back() == WCHAR_PATH_SEPARATOR)
|
||||
if (IS_PATH_SEPAR(s.Back()))
|
||||
return false;
|
||||
int pos = s.ReverseFind_PathSepar();
|
||||
parentPrefix.SetFrom(s, pos + 1);
|
||||
@@ -531,7 +531,7 @@ HRESULT CBrowseDialog::Reload(const UString &pathPrefix, const UString &selected
|
||||
|
||||
#ifndef UNDER_CE
|
||||
bool isDrive = false;
|
||||
if (pathPrefix.IsEmpty() || pathPrefix == kSuperPathPrefix)
|
||||
if (pathPrefix.IsEmpty() || pathPrefix.IsEqualTo(kSuperPathPrefix))
|
||||
{
|
||||
isDrive = true;
|
||||
FStringVector drives;
|
||||
@@ -551,7 +551,8 @@ HRESULT CBrowseDialog::Reload(const UString &pathPrefix, const UString &selected
|
||||
else
|
||||
#endif
|
||||
{
|
||||
CEnumerator enumerator(us2fs(pathPrefix + L'*'));
|
||||
CEnumerator enumerator;
|
||||
enumerator.SetDirPrefix(us2fs(pathPrefix));
|
||||
for (;;)
|
||||
{
|
||||
bool found;
|
||||
@@ -596,7 +597,7 @@ HRESULT CBrowseDialog::Reload(const UString &pathPrefix, const UString &selected
|
||||
if (_showDots && _topDirPrefix != DirPrefix)
|
||||
{
|
||||
item.iItem = index;
|
||||
const UString itemName = L"..";
|
||||
const UString itemName ("..");
|
||||
if (selectedName.IsEmpty())
|
||||
cursorIndex = index;
|
||||
item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
|
||||
@@ -642,16 +643,14 @@ HRESULT CBrowseDialog::Reload(const UString &pathPrefix, const UString &selected
|
||||
_list.InsertItem(&item);
|
||||
wchar_t s[32];
|
||||
{
|
||||
FILETIME ft;
|
||||
s[0] = 0;
|
||||
if (FileTimeToLocalFileTime(&fi.MTime, &ft))
|
||||
ConvertFileTimeToString(ft, s,
|
||||
ConvertUtcFileTimeToString(fi.MTime, s,
|
||||
#ifndef UNDER_CE
|
||||
true
|
||||
kTimestampPrintLevel_MIN
|
||||
#else
|
||||
false
|
||||
kTimestampPrintLevel_DAY
|
||||
#endif
|
||||
, false);
|
||||
);
|
||||
_list.SetSubItem(index, subItem++, s);
|
||||
}
|
||||
{
|
||||
@@ -780,8 +779,10 @@ void CBrowseDialog::OnItemEnter()
|
||||
*/
|
||||
return;
|
||||
}
|
||||
UString s = DirPrefix + fs2us(file.Name) + WCHAR_PATH_SEPARATOR;
|
||||
HRESULT res = Reload(s, L"");
|
||||
UString s = DirPrefix;
|
||||
s += fs2us(file.Name);
|
||||
s.Add_PathSepar();
|
||||
HRESULT res = Reload(s, UString());
|
||||
if (res != S_OK)
|
||||
MessageBox_HResError(*this, res, s);
|
||||
SetPathEditText();
|
||||
@@ -853,17 +854,17 @@ bool MyBrowseForFile(HWND owner, LPCWSTR title, LPCWSTR path,
|
||||
#else
|
||||
// maybe we must use GetLastError in WinCE.
|
||||
DWORD errorCode = CommDlgExtendedError();
|
||||
const wchar_t *errorMessage = NULL;
|
||||
const char *errorMessage = NULL;
|
||||
switch (errorCode)
|
||||
{
|
||||
case 0: return false; // cancel or close obn dialog
|
||||
case FNERR_INVALIDFILENAME: errorMessage = L"Invalid File Name"; break;
|
||||
default: errorMessage = L"Open Dialog Error";
|
||||
case FNERR_INVALIDFILENAME: errorMessage = "Invalid File Name"; break;
|
||||
default: errorMessage = "Open Dialog Error";
|
||||
}
|
||||
if (!errorMessage)
|
||||
return false;
|
||||
{
|
||||
UString s = errorMessage;
|
||||
UString s (errorMessage);
|
||||
s.Add_LF();
|
||||
s += path;
|
||||
MessageBox_Error_Global(owner, s);
|
||||
|
||||
@@ -23,7 +23,7 @@ static const UInt32 kLangIDs_Colon[] =
|
||||
IDT_EDIT_VIEWER
|
||||
};
|
||||
|
||||
static LPCWSTR kEditTopic = L"FM/options.htm#editor";
|
||||
#define kEditTopic "FM/options.htm#editor"
|
||||
|
||||
bool CEditPage::OnInit()
|
||||
{
|
||||
@@ -76,17 +76,38 @@ LONG CEditPage::OnApply()
|
||||
|
||||
void CEditPage::OnNotifyHelp()
|
||||
{
|
||||
ShowHelpWindow(NULL, kEditTopic);
|
||||
ShowHelpWindow(kEditTopic);
|
||||
}
|
||||
|
||||
void SplitCmdLineSmart(const UString &cmd, UString &prg, UString ¶ms);
|
||||
|
||||
static void Edit_BrowseForFile(NWindows::NControl::CEdit &edit, HWND hwnd)
|
||||
{
|
||||
UString path;
|
||||
edit.GetText(path);
|
||||
UString cmd;
|
||||
edit.GetText(cmd);
|
||||
|
||||
UString param;
|
||||
UString prg;
|
||||
|
||||
SplitCmdLineSmart(cmd, prg, param);
|
||||
|
||||
UString resPath;
|
||||
if (MyBrowseForFile(hwnd, 0, path, NULL, L"*.exe", resPath))
|
||||
|
||||
if (MyBrowseForFile(hwnd, 0, prg, NULL, L"*.exe", resPath))
|
||||
{
|
||||
edit.SetText(resPath);
|
||||
resPath.Trim();
|
||||
cmd = resPath;
|
||||
/*
|
||||
if (!param.IsEmpty() && !resPath.IsEmpty())
|
||||
{
|
||||
cmd.InsertAtFront(L'\"');
|
||||
cmd += L'\"';
|
||||
cmd.Add_Space();
|
||||
cmd += param;
|
||||
}
|
||||
*/
|
||||
|
||||
edit.SetText(cmd);
|
||||
// Changed();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -335,20 +335,18 @@ void SetExtractErrorMessage(Int32 opRes, Int32 encrypted, const wchar_t *fileNam
|
||||
s += msg;
|
||||
else
|
||||
{
|
||||
char temp[16];
|
||||
ConvertUInt32ToString(opRes, temp);
|
||||
s.AddAscii("Error #");
|
||||
s.AddAscii(temp);
|
||||
s += "Error #";
|
||||
s.Add_UInt32(opRes);
|
||||
}
|
||||
|
||||
if (encrypted && opRes != NArchive::NExtract::NOperationResult::kWrongPassword)
|
||||
{
|
||||
// s.AddAscii(" : ");
|
||||
// s += " : ";
|
||||
// AddLangString(s, IDS_EXTRACT_MSG_ENCRYPTED);
|
||||
s.AddAscii(" : ");
|
||||
s += " : ";
|
||||
AddLangString(s, IDS_EXTRACT_MSG_WRONG_PSW_GUESS);
|
||||
}
|
||||
s.AddAscii(" : ");
|
||||
s += " : ";
|
||||
s += fileName;
|
||||
}
|
||||
}
|
||||
@@ -466,7 +464,7 @@ UString GetOpenArcErrorMessage(UInt32 errorFlags)
|
||||
continue;
|
||||
if (f == kpv_ErrorFlags_EncryptedHeadersError)
|
||||
{
|
||||
m.AddAscii(" : ");
|
||||
m += " : ";
|
||||
AddLangString(m, IDS_EXTRACT_MSG_WRONG_PSW_GUESS);
|
||||
}
|
||||
if (!s.IsEmpty())
|
||||
@@ -483,7 +481,7 @@ UString GetOpenArcErrorMessage(UInt32 errorFlags)
|
||||
ConvertUInt32ToHex(errorFlags, sz + 2);
|
||||
if (!s.IsEmpty())
|
||||
s.Add_LF();
|
||||
s.AddAscii(sz);
|
||||
s += sz;
|
||||
}
|
||||
|
||||
return s;
|
||||
@@ -503,7 +501,7 @@ static void ErrorInfo_Print(UString &s, const CArcErrorInfo &er)
|
||||
if (warningFlags != 0)
|
||||
{
|
||||
s += GetNameOfProperty(kpidWarningFlags, L"Warnings");
|
||||
s.AddAscii(":");
|
||||
s += ":";
|
||||
s.Add_LF();
|
||||
AddNewLineString(s, GetOpenArcErrorMessage(warningFlags));
|
||||
}
|
||||
@@ -511,7 +509,7 @@ static void ErrorInfo_Print(UString &s, const CArcErrorInfo &er)
|
||||
if (!er.WarningMessage.IsEmpty())
|
||||
{
|
||||
s += GetNameOfProperty(kpidWarning, L"Warning");
|
||||
s.AddAscii(": ");
|
||||
s += ": ";
|
||||
s += er.WarningMessage;
|
||||
s.Add_LF();
|
||||
}
|
||||
@@ -519,9 +517,9 @@ static void ErrorInfo_Print(UString &s, const CArcErrorInfo &er)
|
||||
|
||||
static UString GetBracedType(const wchar_t *type)
|
||||
{
|
||||
UString s = L'[';
|
||||
UString s ('[');
|
||||
s += type;
|
||||
s += L']';
|
||||
s += ']';
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -1009,7 +1007,7 @@ HRESULT CVirtFileSystem::FlushToDisk(bool closeLast)
|
||||
{
|
||||
_outFileStream.Release();
|
||||
return E_FAIL;
|
||||
// MessageBoxMyError(UString(L"Can't create file ") + fs2us(tempFilePath));
|
||||
// MessageBoxMyError(UString("Can't create file ") + fs2us(tempFilePath));
|
||||
}
|
||||
_fileIsOpen = true;
|
||||
RINOK(WriteStream(_outFileStream, file.Data, (size_t)file.Size));
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
#include "../../../../C/Alloc.h"
|
||||
|
||||
#include "../../../Common/IntToString.h"
|
||||
#include "../../../Common/StringConvert.h"
|
||||
#include "../../../Common/StringToInt.h"
|
||||
|
||||
@@ -43,16 +42,21 @@ using namespace NFind;
|
||||
#define MENU_HEIGHT 26
|
||||
|
||||
bool g_RAM_Size_Defined;
|
||||
bool g_LargePagesMode = false;
|
||||
bool g_OpenArchive = false;
|
||||
|
||||
static bool g_Maximized = false;
|
||||
|
||||
UInt64 g_RAM_Size;
|
||||
|
||||
#ifdef _WIN32
|
||||
HINSTANCE g_hInstance;
|
||||
#endif
|
||||
|
||||
HWND g_HWND;
|
||||
bool g_OpenArchive = false;
|
||||
|
||||
static UString g_MainPath;
|
||||
static UString g_ArcFormat;
|
||||
static bool g_Maximized = false;
|
||||
|
||||
// HRESULT LoadGlobalCodecs();
|
||||
void FreeGlobalCodecs();
|
||||
@@ -166,7 +170,7 @@ CApp g_App;
|
||||
|
||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
const wchar_t *kWindowClass = L"FM";
|
||||
static const wchar_t * const kWindowClass = L"FM";
|
||||
|
||||
#ifdef UNDER_CE
|
||||
#define WS_OVERLAPPEDWINDOW ( \
|
||||
@@ -185,7 +189,7 @@ static BOOL InitInstance(int nCmdShow)
|
||||
|
||||
// LoadString(hInstance, IDS_CLASS, windowClass, MAX_LOADSTRING);
|
||||
|
||||
UString title = L"7-Zip"; // LangString(IDS_APP_TITLE, 0x03000000);
|
||||
UString title ("7-Zip"); // LangString(IDS_APP_TITLE, 0x03000000);
|
||||
|
||||
/*
|
||||
//If it is already running, then focus on the window
|
||||
@@ -379,7 +383,7 @@ static void SetMemoryLock()
|
||||
NSecurity::AddLockMemoryPrivilege();
|
||||
|
||||
if (ReadLockMemoryEnable())
|
||||
NSecurity::EnablePrivilege_LockMemory();
|
||||
g_LargePagesMode = NSecurity::EnablePrivilege_LockMemory();
|
||||
}
|
||||
|
||||
bool g_SymLink_Supported = false;
|
||||
@@ -426,8 +430,13 @@ static void ErrorMessage(const wchar_t *s)
|
||||
MessageBoxW(0, s, L"7-Zip", MB_ICONERROR);
|
||||
}
|
||||
|
||||
static void ErrorMessage(const char *s)
|
||||
{
|
||||
ErrorMessage(GetUnicodeString(s));
|
||||
}
|
||||
|
||||
#define NT_CHECK_FAIL_ACTION ErrorMessage(L"Unsupported Windows version"); return 1;
|
||||
|
||||
#define NT_CHECK_FAIL_ACTION ErrorMessage("Unsupported Windows version"); return 1;
|
||||
|
||||
static int WINAPI WinMain2(int nCmdShow)
|
||||
{
|
||||
@@ -667,7 +676,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */,
|
||||
}
|
||||
catch(const AString &s)
|
||||
{
|
||||
ErrorMessage(GetUnicodeString(s));
|
||||
ErrorMessage(s.Ptr());
|
||||
return 1;
|
||||
}
|
||||
catch(const wchar_t *s)
|
||||
@@ -677,19 +686,19 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */,
|
||||
}
|
||||
catch(const char *s)
|
||||
{
|
||||
ErrorMessage(GetUnicodeString(s));
|
||||
ErrorMessage(s);
|
||||
return 1;
|
||||
}
|
||||
catch(int v)
|
||||
{
|
||||
wchar_t s[32];
|
||||
ConvertUInt32ToString(v, s);
|
||||
ErrorMessage(UString(L"Error: ") + s);
|
||||
AString e ("Error: ");
|
||||
e.Add_UInt32(v);
|
||||
ErrorMessage(e);
|
||||
return 1;
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
ErrorMessage(L"Unknown error");
|
||||
ErrorMessage("Unknown error");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -844,7 +853,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
if (needOpenFile && !archiveIsOpened || res != S_OK)
|
||||
{
|
||||
UString m = L"Error";
|
||||
UString m ("Error");
|
||||
if (res == S_FALSE || res == S_OK)
|
||||
{
|
||||
m = MyFormatNew(encrypted ?
|
||||
|
||||
@@ -45,7 +45,7 @@ RSC=rc.exe
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /Gz /MD /W4 /WX /GX /O1 /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "WIN_LONG_PATH" /D "NEW_FOLDER_INTERFACE" /D "EXTERNAL_CODECS" /D "SUPPORT_DEVICE_FILE" /FAs /Yu"StdAfx.h" /FD /c
|
||||
# ADD CPP /nologo /Gz /MD /W4 /WX /GX /O1 /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "WIN_LONG_PATH" /D "NEW_FOLDER_INTERFACE" /D "EXTERNAL_CODECS" /D "SUPPORT_DEVICE_FILE" /FAcs /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"
|
||||
|
||||
@@ -28,12 +28,14 @@ using namespace NWindows;
|
||||
using namespace NFile;
|
||||
using namespace NFind;
|
||||
|
||||
static const CFSTR kVolPrefix = FTEXT("\\\\.\\");
|
||||
static const CFSTR kSuperPrefix = FTEXT("\\\\?\\");
|
||||
static const char * const kVolPrefix = "\\\\.\\";
|
||||
static const char * const kSuperPrefix = "\\\\?\\";
|
||||
|
||||
FString CDriveInfo::GetDeviceFileIoName() const
|
||||
{
|
||||
return kVolPrefix + Name;
|
||||
FString f (kVolPrefix);
|
||||
f += Name;
|
||||
return f;
|
||||
}
|
||||
|
||||
struct CPhysTempBuffer
|
||||
@@ -179,11 +181,10 @@ STDMETHODIMP CFSDrives::LoadItems()
|
||||
// we must use IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS
|
||||
for (unsigned n = 0; n < 16; n++) // why 16 ?
|
||||
{
|
||||
FChar temp[16];
|
||||
ConvertUInt32ToString(n, temp);
|
||||
FString name = FTEXT("PhysicalDrive");
|
||||
name += temp;
|
||||
FString fullPath = kVolPrefix;
|
||||
FString name ("PhysicalDrive");
|
||||
name.Add_UInt32(n);
|
||||
|
||||
FString fullPath (kVolPrefix);
|
||||
fullPath += name;
|
||||
|
||||
CFileInfo fi;
|
||||
@@ -336,7 +337,7 @@ STDMETHODIMP CFSDrives::GetSystemIconIndex(UInt32 index, Int32 *iconIndex)
|
||||
|
||||
void CFSDrives::AddExt(FString &s, unsigned index) const
|
||||
{
|
||||
s += FTEXT('.');
|
||||
s += '.';
|
||||
const CDriveInfo &di = _drives[index];
|
||||
const char *ext;
|
||||
if (di.DriveType == DRIVE_CDROM)
|
||||
@@ -347,7 +348,7 @@ void CFSDrives::AddExt(FString &s, unsigned index) const
|
||||
ext = "fat";
|
||||
else
|
||||
ext = "img";
|
||||
s.AddAscii(ext);
|
||||
s += ext;
|
||||
}
|
||||
|
||||
HRESULT CFSDrives::GetFileSize(unsigned index, UInt64 &fileSize) const
|
||||
|
||||
@@ -73,6 +73,8 @@ HRESULT CFSFolder::Init(const FString &path /* , IFolderFolder *parentFolder */)
|
||||
// _parentFolder = parentFolder;
|
||||
_path = path;
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
_findChangeNotification.FindFirst(_path, false,
|
||||
FILE_NOTIFY_CHANGE_FILE_NAME
|
||||
| FILE_NOTIFY_CHANGE_DIR_NAME
|
||||
@@ -85,17 +87,24 @@ HRESULT CFSFolder::Init(const FString &path /* , IFolderFolder *parentFolder */)
|
||||
| FILE_NOTIFY_CHANGE_SECURITY
|
||||
*/
|
||||
);
|
||||
|
||||
if (!_findChangeNotification.IsHandleAllocated())
|
||||
{
|
||||
DWORD lastError = GetLastError();
|
||||
CFindFile findFile;
|
||||
CFileInfo fi;
|
||||
if (!findFile.FindFirst(_path + FCHAR_ANY_MASK, fi))
|
||||
FString path2 = _path;
|
||||
path2 += '*'; // CHAR_ANY_MASK;
|
||||
if (!findFile.FindFirst(path2, fi))
|
||||
return lastError;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
HRESULT CFsFolderStat::Enumerate()
|
||||
{
|
||||
if (Progress)
|
||||
@@ -103,9 +112,9 @@ HRESULT CFsFolderStat::Enumerate()
|
||||
RINOK(Progress->SetCompleted(NULL));
|
||||
}
|
||||
Path.Add_PathSepar();
|
||||
unsigned len = Path.Len();
|
||||
Path += FCHAR_ANY_MASK;
|
||||
CEnumerator enumerator(Path);
|
||||
const unsigned len = Path.Len();
|
||||
CEnumerator enumerator;
|
||||
enumerator.SetDirPrefix(Path);
|
||||
CFileInfo fi;
|
||||
while (enumerator.Next(fi))
|
||||
{
|
||||
@@ -164,7 +173,8 @@ HRESULT CFSFolder::LoadSubItems(int dirItem, const FString &relPrefix)
|
||||
{
|
||||
unsigned startIndex = Folders.Size();
|
||||
{
|
||||
CEnumerator enumerator(_path + relPrefix + FCHAR_ANY_MASK);
|
||||
CEnumerator enumerator;
|
||||
enumerator.SetDirPrefix(_path + relPrefix);
|
||||
CDirItem fi;
|
||||
fi.FolderStat_Defined = false;
|
||||
fi.NumFolders = 0;
|
||||
@@ -267,7 +277,7 @@ STDMETHODIMP CFSFolder::LoadItems()
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static CFSTR kDescriptionFileName = FTEXT("descript.ion");
|
||||
static CFSTR const kDescriptionFileName = FTEXT("descript.ion");
|
||||
|
||||
bool CFSFolder::LoadComments()
|
||||
{
|
||||
@@ -389,6 +399,7 @@ bool CFSFolder::ReadFileInfo(CDirItem &di)
|
||||
{
|
||||
di.FileInfo_WasRequested = true;
|
||||
BY_HANDLE_FILE_INFORMATION info;
|
||||
memset(&info, 0, sizeof(info)); // for vc6-O2
|
||||
if (!NIO::CFileBase::GetFileInformation(_path + GetRelPath(di), &info))
|
||||
return false;
|
||||
di.NumLinks = info.nNumberOfLinks;
|
||||
@@ -744,8 +755,6 @@ STDMETHODIMP CFSFolder::BindToFolder(const wchar_t *name, IFolderFolder **result
|
||||
return BindToFolderSpec(us2fs(name), resultFolder);
|
||||
}
|
||||
|
||||
static const CFSTR kSuperPrefix = FTEXT("\\\\?\\");
|
||||
|
||||
STDMETHODIMP CFSFolder::BindToParentFolder(IFolderFolder **resultFolder)
|
||||
{
|
||||
*resultFolder = 0;
|
||||
@@ -759,43 +768,39 @@ STDMETHODIMP CFSFolder::BindToParentFolder(IFolderFolder **resultFolder)
|
||||
*/
|
||||
if (_path.IsEmpty())
|
||||
return E_INVALIDARG;
|
||||
|
||||
#ifndef UNDER_CE
|
||||
|
||||
if (IsDriveRootPath_SuperAllowed(_path))
|
||||
{
|
||||
CFSDrives *drivesFolderSpec = new CFSDrives;
|
||||
CMyComPtr<IFolderFolder> drivesFolder = drivesFolderSpec;
|
||||
drivesFolderSpec->Init(false, IsSuperPath(_path));
|
||||
*resultFolder = drivesFolder.Detach();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
int pos = _path.ReverseFind_PathSepar();
|
||||
if (pos < 0 || pos != (int)_path.Len() - 1)
|
||||
return E_FAIL;
|
||||
FString parentPath = _path.Left(pos);
|
||||
pos = parentPath.ReverseFind_PathSepar();
|
||||
if (pos < 0)
|
||||
parentPath.DeleteFrom(pos + 1);
|
||||
|
||||
if (NName::IsDrivePath_SuperAllowed(parentPath))
|
||||
{
|
||||
#ifdef UNDER_CE
|
||||
*resultFolder = 0;
|
||||
#else
|
||||
CFSDrives *drivesFolderSpec = new CFSDrives;
|
||||
CMyComPtr<IFolderFolder> drivesFolder = drivesFolderSpec;
|
||||
drivesFolderSpec->Init();
|
||||
*resultFolder = drivesFolder.Detach();
|
||||
#endif
|
||||
return S_OK;
|
||||
CFSFolder *parentFolderSpec = new CFSFolder;
|
||||
CMyComPtr<IFolderFolder> parentFolder = parentFolderSpec;
|
||||
if (parentFolderSpec->Init(parentPath) == S_OK)
|
||||
{
|
||||
*resultFolder = parentFolder.Detach();
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
parentPath.DeleteFrom(pos + 1);
|
||||
|
||||
if (parentPath == kSuperPrefix)
|
||||
{
|
||||
#ifdef UNDER_CE
|
||||
*resultFolder = 0;
|
||||
#else
|
||||
CFSDrives *drivesFolderSpec = new CFSDrives;
|
||||
CMyComPtr<IFolderFolder> drivesFolder = drivesFolderSpec;
|
||||
drivesFolderSpec->Init(false, true);
|
||||
*resultFolder = drivesFolder.Detach();
|
||||
#endif
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
FString parentPathReduced = parentPath.Left(pos);
|
||||
|
||||
#ifndef UNDER_CE
|
||||
pos = parentPathReduced.ReverseFind_PathSepar();
|
||||
if (pos == 1)
|
||||
{
|
||||
@@ -807,13 +812,10 @@ STDMETHODIMP CFSFolder::BindToParentFolder(IFolderFolder **resultFolder)
|
||||
*resultFolder = netFolder.Detach();
|
||||
return S_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
CFSFolder *parentFolderSpec = new CFSFolder;
|
||||
CMyComPtr<IFolderFolder> parentFolder = parentFolderSpec;
|
||||
RINOK(parentFolderSpec->Init(parentPath, 0));
|
||||
*resultFolder = parentFolder.Detach();
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -844,24 +846,22 @@ STDMETHODIMP CFSFolder::GetFolderProperty(PROPID propID, PROPVARIANT *value)
|
||||
STDMETHODIMP CFSFolder::WasChanged(Int32 *wasChanged)
|
||||
{
|
||||
bool wasChangedMain = false;
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (!_findChangeNotification.IsHandleAllocated())
|
||||
{
|
||||
*wasChanged = BoolToInt(false);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
DWORD waitResult = ::WaitForSingleObject(_findChangeNotification, 0);
|
||||
bool wasChangedLoc = (waitResult == WAIT_OBJECT_0);
|
||||
if (wasChangedLoc)
|
||||
{
|
||||
_findChangeNotification.FindNext();
|
||||
wasChangedMain = true;
|
||||
}
|
||||
else
|
||||
break;
|
||||
DWORD waitResult = ::WaitForSingleObject(_findChangeNotification, 0);
|
||||
if (waitResult != WAIT_OBJECT_0)
|
||||
break;
|
||||
_findChangeNotification.FindNext();
|
||||
wasChangedMain = true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
*wasChanged = BoolToInt(wasChangedMain);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -142,7 +142,9 @@ private:
|
||||
// bool _scanAltStreams;
|
||||
bool _flatMode;
|
||||
|
||||
#ifdef _WIN32
|
||||
NWindows::NFile::NFind::CFindChangeNotification _findChangeNotification;
|
||||
#endif
|
||||
|
||||
HRESULT GetItemsFullSize(const UInt32 *indices, UInt32 numItems, CFsFolderStat &stat);
|
||||
|
||||
@@ -161,7 +163,7 @@ private:
|
||||
public:
|
||||
HRESULT Init(const FString &path /* , IFolderFolder *parentFolder */);
|
||||
#if !defined(_WIN32) || defined(UNDER_CE)
|
||||
HRESULT InitToRoot() { return Init(FSTRING_PATH_SEPARATOR /* , NULL */); }
|
||||
HRESULT InitToRoot() { return Init((FString) FSTRING_PATH_SEPARATOR /* , NULL */); }
|
||||
#endif
|
||||
|
||||
CFSFolder() : _flatMode(false)
|
||||
|
||||
@@ -75,7 +75,7 @@ HRESULT CCopyStateIO::MyCopyFile(CFSTR inPath, CFSTR outPath)
|
||||
}
|
||||
if (written != num)
|
||||
{
|
||||
ErrorMessage = L"Write error";
|
||||
ErrorMessage = "Write error";
|
||||
return S_OK;
|
||||
}
|
||||
CurrentSize += num;
|
||||
@@ -357,7 +357,7 @@ static HRESULT SendMessageError(IFolderOperationsExtractCallback *callback,
|
||||
const wchar_t *message, const FString &fileName)
|
||||
{
|
||||
UString s = message;
|
||||
s += L" : ";
|
||||
s += " : ";
|
||||
s += fs2us(fileName);
|
||||
return callback->ShowMessage(s);
|
||||
}
|
||||
@@ -514,7 +514,8 @@ static HRESULT CopyFolder(
|
||||
return E_ABORT;
|
||||
}
|
||||
|
||||
CEnumerator enumerator(CombinePath(srcPath, FSTRING_ANY_MASK));
|
||||
CEnumerator enumerator;
|
||||
enumerator.SetDirPrefix(CombinePath(srcPath, FString()));
|
||||
|
||||
for (;;)
|
||||
{
|
||||
|
||||
@@ -68,7 +68,7 @@ static void SplitNameToPureNameAndExtension(const FString &fullName,
|
||||
else
|
||||
{
|
||||
pureName.SetFrom(fullName, index);
|
||||
extensionDelimiter = FTEXT('.');
|
||||
extensionDelimiter = '.';
|
||||
extension = fullName.Ptr(index + 1);
|
||||
}
|
||||
}
|
||||
@@ -151,7 +151,7 @@ HRESULT OpenFileFolderPlugin(
|
||||
|
||||
UString progressTitle = LangString(IDS_OPENNING);
|
||||
t.OpenCallbackSpec->ProgressDialog.MainWindow = parentWindow;
|
||||
t.OpenCallbackSpec->ProgressDialog.MainTitle = L"7-Zip"; // LangString(IDS_APP_TITLE);
|
||||
t.OpenCallbackSpec->ProgressDialog.MainTitle = "7-Zip"; // LangString(IDS_APP_TITLE);
|
||||
t.OpenCallbackSpec->ProgressDialog.MainAddTitle = progressTitle + L' ';
|
||||
t.OpenCallbackSpec->ProgressDialog.WaitMode = true;
|
||||
|
||||
|
||||
@@ -27,6 +27,8 @@ static const int kWorkModeButtons[] =
|
||||
IDR_FOLDERS_WORK_SPECIFIED
|
||||
};
|
||||
|
||||
#define kFoldersTopic "fm/options.htm#folders"
|
||||
|
||||
static const unsigned kNumWorkModeButtons = ARRAY_SIZE(kWorkModeButtons);
|
||||
|
||||
bool CFoldersPage::OnInit()
|
||||
@@ -158,9 +160,7 @@ LONG CFoldersPage::OnApply()
|
||||
return PSNRET_NOERROR;
|
||||
}
|
||||
|
||||
static LPCWSTR kFoldersTopic = L"fm/options.htm#folders";
|
||||
|
||||
void CFoldersPage::OnNotifyHelp()
|
||||
{
|
||||
ShowHelpWindow(NULL, kFoldersTopic);
|
||||
ShowHelpWindow(kFoldersTopic);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#if defined(UNDER_CE) || !defined(_WIN32)
|
||||
|
||||
void ShowHelpWindow(HWND, LPCWSTR)
|
||||
void ShowHelpWindow(LPCSTR)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -18,12 +18,15 @@ void ShowHelpWindow(HWND, LPCWSTR)
|
||||
|
||||
#include "../../../Windows/DLL.h"
|
||||
|
||||
static LPCWSTR kHelpFileName = L"7-zip.chm::/";
|
||||
#define kHelpFileName "7-zip.chm::/"
|
||||
|
||||
void ShowHelpWindow(HWND hwnd, LPCWSTR topicFile)
|
||||
void ShowHelpWindow(LPCSTR topicFile)
|
||||
{
|
||||
FString path = NWindows::NDLL::GetModuleDirPrefix();
|
||||
HtmlHelp(hwnd, GetSystemString(fs2us(path) + kHelpFileName + topicFile), HH_DISPLAY_TOPIC, 0);
|
||||
path += kHelpFileName;
|
||||
path += topicFile;
|
||||
// HWND hwnd = NULL;
|
||||
HtmlHelp(NULL, GetSystemString(fs2us(path)), HH_DISPLAY_TOPIC, 0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,6 +5,6 @@
|
||||
|
||||
#include "../../../Common/MyString.h"
|
||||
|
||||
void ShowHelpWindow(HWND hwnd, LPCWSTR topicFile);
|
||||
void ShowHelpWindow(LPCSTR topicFile);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -20,13 +20,13 @@ static const UInt32 kLangIDs[] =
|
||||
IDT_LANG_LANG
|
||||
};
|
||||
|
||||
static LPCWSTR kLangTopic = L"fm/options.htm#language";
|
||||
#define kLangTopic "fm/options.htm#language"
|
||||
|
||||
static void NativeLangString(UString &dest, const wchar_t *s)
|
||||
{
|
||||
dest += L" (";
|
||||
dest += " (";
|
||||
dest += s;
|
||||
dest += L')';
|
||||
dest += ')';
|
||||
}
|
||||
|
||||
bool LangOpen(CLang &lang, CFSTR fileName);
|
||||
@@ -45,7 +45,8 @@ bool CLangPage::OnInit()
|
||||
_langCombo.SetCurSel(0);
|
||||
|
||||
const FString dirPrefix = GetLangDirPrefix();
|
||||
NFile::NFind::CEnumerator enumerator(dirPrefix + FTEXT("*.txt"));
|
||||
NFile::NFind::CEnumerator enumerator;
|
||||
enumerator.SetDirPrefix(dirPrefix);
|
||||
NFile::NFind::CFileInfo fi;
|
||||
CLang lang;
|
||||
UString error;
|
||||
@@ -54,12 +55,15 @@ bool CLangPage::OnInit()
|
||||
{
|
||||
if (fi.IsDir())
|
||||
continue;
|
||||
const int kExtSize = 4;
|
||||
const unsigned kExtSize = 4;
|
||||
if (fi.Name.Len() < kExtSize)
|
||||
continue;
|
||||
unsigned pos = fi.Name.Len() - kExtSize;
|
||||
const unsigned pos = fi.Name.Len() - kExtSize;
|
||||
if (!StringsAreEqualNoCase_Ascii(fi.Name.Ptr(pos), ".txt"))
|
||||
{
|
||||
// if (!StringsAreEqualNoCase_Ascii(fi.Name.Ptr(pos), ".ttt"))
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!LangOpen(lang, dirPrefix + fi.Name))
|
||||
{
|
||||
@@ -101,7 +105,7 @@ LONG CLangPage::OnApply()
|
||||
|
||||
void CLangPage::OnNotifyHelp()
|
||||
{
|
||||
ShowHelpWindow(NULL, kLangTopic);
|
||||
ShowHelpWindow(kLangTopic);
|
||||
}
|
||||
|
||||
bool CLangPage::OnCommand(int code, int itemID, LPARAM param)
|
||||
|
||||
@@ -25,7 +25,7 @@ static NSynchronization::CCriticalSection g_CriticalSection;
|
||||
|
||||
bool LangOpen(CLang &lang, CFSTR fileName)
|
||||
{
|
||||
return lang.Open(fileName, L"7-Zip");
|
||||
return lang.Open(fileName, "7-Zip");
|
||||
}
|
||||
|
||||
FString GetLangDirPrefix()
|
||||
@@ -94,7 +94,7 @@ void LangSetDlgItems_Colon(HWND dialog, const UInt32 *ids, unsigned numItems)
|
||||
{
|
||||
CWindow window(GetDlgItem(dialog, id));
|
||||
UString s2 = s;
|
||||
s2 += L':';
|
||||
s2 += ':';
|
||||
window.SetText(s2);
|
||||
}
|
||||
}
|
||||
@@ -139,7 +139,7 @@ void LangString_OnlyFromLangFile(UInt32 langID, UString &dest)
|
||||
dest = s;
|
||||
}
|
||||
|
||||
static const char *kLangs =
|
||||
static const char * const kLangs =
|
||||
"ar.bg.ca.zh.-tw.-cn.cs.da.de.el.en.es.fi.fr.he.hu.is."
|
||||
"it.ja.ko.nl.no.=nb.=nn.pl.pt.-br.rm.ro.ru.sr.=hr.-spl.-spc.sk.sq.sv.th.tr."
|
||||
"ur.id.uk.be.sl.et.lv.lt.tg.fa.vi.hy.az.eu.hsb.mk."
|
||||
@@ -153,7 +153,7 @@ static const char *kLangs =
|
||||
// ".gd."
|
||||
;
|
||||
|
||||
static void FindShortNames(UInt32 primeLang, UStringVector &names)
|
||||
static void FindShortNames(UInt32 primeLang, AStringVector &names)
|
||||
{
|
||||
UInt32 index = 0;
|
||||
for (const char *p = kLangs; *p != 0;)
|
||||
@@ -167,7 +167,7 @@ static void FindShortNames(UInt32 primeLang, UStringVector &names)
|
||||
{
|
||||
if (index > primeLang)
|
||||
break;
|
||||
UString s;
|
||||
AString s;
|
||||
if (isSub)
|
||||
{
|
||||
if (p[0] == '-')
|
||||
@@ -176,7 +176,7 @@ static void FindShortNames(UInt32 primeLang, UStringVector &names)
|
||||
p++;
|
||||
}
|
||||
while (p != p2)
|
||||
s += (wchar_t)(Byte)*p++;
|
||||
s += (char)(Byte)*p++;
|
||||
names.Add(s);
|
||||
}
|
||||
p = p2 + 1;
|
||||
@@ -195,7 +195,7 @@ static struct CC1Lang
|
||||
UString s;
|
||||
char ttt[32];
|
||||
ConvertUInt32ToHex(i, ttt);
|
||||
s.AddAscii(ttt);
|
||||
s += ttt;
|
||||
UStringVector names;
|
||||
FindShortNames(i, names);
|
||||
|
||||
@@ -238,18 +238,21 @@ static void OpenDefaultLang()
|
||||
WORD primLang = (WORD)(PRIMARYLANGID(langID));
|
||||
WORD subLang = (WORD)(SUBLANGID(langID));
|
||||
{
|
||||
UStringVector names;
|
||||
AStringVector names;
|
||||
FindShortNames(primLang, names);
|
||||
const FString dirPrefix = GetLangDirPrefix();
|
||||
const FString dirPrefix (GetLangDirPrefix());
|
||||
for (unsigned i = 0; i < 2; i++)
|
||||
{
|
||||
unsigned index = (i == 0 ? subLang : 0);
|
||||
if (index < names.Size())
|
||||
{
|
||||
const UString &name = names[index];
|
||||
const AString &name = names[index];
|
||||
if (!name.IsEmpty())
|
||||
{
|
||||
if (LangOpen(g_Lang, dirPrefix + us2fs(name) + FTEXT(".txt")))
|
||||
FString path (dirPrefix);
|
||||
path += name;
|
||||
path += ".txt";
|
||||
if (LangOpen(g_Lang, path))
|
||||
{
|
||||
g_LangID = name;
|
||||
return;
|
||||
@@ -280,7 +283,7 @@ void ReloadLang()
|
||||
if (s.Find(FCHAR_PATH_SEPARATOR) < 0)
|
||||
{
|
||||
if (s.Find(FTEXT('.')) < 0)
|
||||
s += FTEXT(".txt");
|
||||
s += ".txt";
|
||||
s.Insert(0, GetLangDirPrefix());
|
||||
}
|
||||
LangOpen(g_Lang, s);
|
||||
|
||||
@@ -108,11 +108,11 @@ bool CLinkDialog::OnInit()
|
||||
UString s = attr.PrintName;
|
||||
if (!attr.IsOkNamePair())
|
||||
{
|
||||
s += L" : ";
|
||||
s += " : ";
|
||||
s += attr.SubsName;
|
||||
}
|
||||
if (!res)
|
||||
s = L"ERROR: " + s;
|
||||
s.Insert(0, L"ERROR: ");
|
||||
|
||||
SetItemText(IDT_LINK_PATH_TO_CUR, s);
|
||||
|
||||
@@ -214,7 +214,7 @@ void CLinkDialog::OnButton_SetPath(bool to)
|
||||
_pathToCombo :
|
||||
_pathFromCombo;
|
||||
combo.GetText(currentPath);
|
||||
// UString title = L"Specify a location for output folder";
|
||||
// UString title = "Specify a location for output folder";
|
||||
UString title = LangString(IDS_SET_FOLDER);
|
||||
|
||||
UString resultPath;
|
||||
|
||||
@@ -35,7 +35,7 @@ static const UInt32 kLangIDs[] =
|
||||
IDT_SYSTEM_CONTEXT_MENU_ITEMS
|
||||
};
|
||||
|
||||
static LPCWSTR kSystemTopic = L"fm/options.htm#sevenZip";
|
||||
#define kMenuTopic "fm/options.htm#sevenZip"
|
||||
|
||||
struct CContextMenuItem
|
||||
{
|
||||
@@ -71,6 +71,13 @@ static const CContextMenuItem kMenuItems[] =
|
||||
extern bool g_Is_Wow64;
|
||||
#endif
|
||||
|
||||
#ifndef KEY_WOW64_64KEY
|
||||
#define KEY_WOW64_64KEY (0x0100)
|
||||
#endif
|
||||
|
||||
#ifndef KEY_WOW64_32KEY
|
||||
#define KEY_WOW64_32KEY (0x0200)
|
||||
#endif
|
||||
|
||||
bool CMenuPage::OnInit()
|
||||
{
|
||||
@@ -95,14 +102,14 @@ bool CMenuPage::OnInit()
|
||||
}
|
||||
UString bit64 = LangString(IDS_PROP_BIT64);
|
||||
if (bit64.IsEmpty())
|
||||
bit64.SetFromAscii("64-bit");
|
||||
bit64 = "64-bit";
|
||||
#ifdef _WIN64
|
||||
bit64.Replace(L"64", L"32");
|
||||
#endif
|
||||
s.Add_Space();
|
||||
s += L'(';
|
||||
s += '(';
|
||||
s += bit64;
|
||||
s += L')';
|
||||
s += ')';
|
||||
SetItemText(IDX_SYSTEM_INTEGRATE_TO_MENU_2, s);
|
||||
}
|
||||
|
||||
@@ -136,7 +143,7 @@ bool CMenuPage::OnInit()
|
||||
|
||||
FString &path = dll.Path;
|
||||
path = prefix;
|
||||
path.AddAscii(d == 0 ? "7-zip.dll" :
|
||||
path += (d == 0 ? "7-zip.dll" :
|
||||
#ifdef _WIN64
|
||||
"7-zip32.dll"
|
||||
#else
|
||||
@@ -180,10 +187,10 @@ bool CMenuPage::OnInit()
|
||||
|
||||
UString s = LangString(menuItem.ControlID);
|
||||
if (menuItem.Flag == kCRC)
|
||||
s.SetFromAscii("CRC SHA");
|
||||
s = "CRC SHA";
|
||||
if (menuItem.Flag == kOpenAs ||
|
||||
menuItem.Flag == kCRC)
|
||||
s.AddAscii(" >");
|
||||
s += " >";
|
||||
|
||||
switch (menuItem.ControlID)
|
||||
{
|
||||
@@ -200,11 +207,11 @@ bool CMenuPage::OnInit()
|
||||
{
|
||||
case kCompressTo7z:
|
||||
case kCompressTo7zEmail:
|
||||
s2.AddAscii(".7z");
|
||||
s2 += (".7z");
|
||||
break;
|
||||
case kCompressToZip:
|
||||
case kCompressToZipEmail:
|
||||
s2.AddAscii(".zip");
|
||||
s2 += (".zip");
|
||||
break;
|
||||
}
|
||||
s = MyFormatNew(s, s2);
|
||||
@@ -286,7 +293,7 @@ LONG CMenuPage::OnApply()
|
||||
|
||||
void CMenuPage::OnNotifyHelp()
|
||||
{
|
||||
ShowHelpWindow(NULL, kSystemTopic);
|
||||
ShowHelpWindow(kMenuTopic);
|
||||
}
|
||||
|
||||
bool CMenuPage::OnButtonClicked(int buttonID, HWND buttonHWND)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "../../../Windows/Menu.h"
|
||||
#include "../../../Windows/TimeUtils.h"
|
||||
#include "../../../Windows/Control/Dialog.h"
|
||||
|
||||
#include "../../PropID.h"
|
||||
@@ -22,10 +23,12 @@ using namespace NWindows;
|
||||
|
||||
static const UINT kOpenBookmarkMenuID = 830;
|
||||
static const UINT kSetBookmarkMenuID = 810;
|
||||
static const UINT kMenuID_Time_Parent = 760;
|
||||
static const UINT kMenuID_Time = 761;
|
||||
|
||||
extern HINSTANCE g_hInstance;
|
||||
|
||||
static LPCWSTR kFMHelpTopic = L"FM/index.htm";
|
||||
#define kFMHelpTopic "FM/index.htm"
|
||||
|
||||
extern void OptionsDialog(HWND hwndOwner, HINSTANCE hInstance);
|
||||
|
||||
@@ -115,10 +118,12 @@ static UINT Get_fMask_for_FType_and_String()
|
||||
static inline UINT Get_fMask_for_String() { return MIIM_TYPE; }
|
||||
static inline UINT Get_fMask_for_FType_and_String() { return MIIM_TYPE; }
|
||||
|
||||
|
||||
static void MyChangeMenu(HMENU menuLoc, int level, int menuIndex)
|
||||
{
|
||||
CMenu menu;
|
||||
menu.Attach(menuLoc);
|
||||
|
||||
for (int i = 0;; i++)
|
||||
{
|
||||
CMenuItem item;
|
||||
@@ -137,7 +142,12 @@ static void MyChangeMenu(HMENU menuLoc, int level, int menuIndex)
|
||||
{
|
||||
MyChangeMenu(item.hSubMenu, level + 1, i);
|
||||
if (level == 1 && menuIndex == kMenuIndex_View)
|
||||
langID = kToolbarsLangID;
|
||||
{
|
||||
if (item.wID == kMenuID_Time_Parent || item.StringValue.IsPrefixedBy_Ascii_NoCase("20"))
|
||||
continue;
|
||||
else
|
||||
langID = kToolbarsLangID;
|
||||
}
|
||||
else if (level == 0 && i < ARRAY_SIZE(kTopMenuLangIDs))
|
||||
langID = kTopMenuLangIDs[i];
|
||||
else
|
||||
@@ -168,7 +178,18 @@ static void MyChangeMenu(HMENU menuLoc, int level, int menuIndex)
|
||||
int tabPos = newString.Find(L"\t");
|
||||
if (tabPos >= 0)
|
||||
newString.DeleteFrom(tabPos);
|
||||
newString += (langID == IDM_OPEN_INSIDE_ONE ? L" *" : L" #");
|
||||
newString += (langID == IDM_OPEN_INSIDE_ONE ? " *" : " #");
|
||||
}
|
||||
else if (langID == IDM_BENCHMARK2)
|
||||
{
|
||||
LangString_OnlyFromLangFile(IDM_BENCHMARK, newString);
|
||||
if (newString.IsEmpty())
|
||||
continue;
|
||||
newString.Replace(L"&", L"");
|
||||
int tabPos = newString.Find(L"\t");
|
||||
if (tabPos >= 0)
|
||||
newString.DeleteFrom(tabPos);
|
||||
newString += " 2";
|
||||
}
|
||||
else
|
||||
LangString_OnlyFromLangFile(langID, newString);
|
||||
@@ -245,6 +266,8 @@ void MyLoadMenu()
|
||||
::DestroyMenu(oldMenu);
|
||||
/* BOOL b = */ g_App._commandBar.InsertMenubar(g_hInstance, IDM_MENU, 0);
|
||||
baseMenu = g_App._commandBar.GetMenu(0);
|
||||
// if (startInit)
|
||||
// SetIdsForSubMenes(baseMenu, 0, 0);
|
||||
if (!g_LangID.IsEmpty())
|
||||
MyChangeMenu(baseMenu, 0, 0);
|
||||
g_App._commandBar.DrawMenuBar(0);
|
||||
@@ -256,6 +279,8 @@ void MyLoadMenu()
|
||||
::SetMenu(hWnd, ::LoadMenu(g_hInstance, MAKEINTRESOURCE(IDM_MENU)));
|
||||
::DestroyMenu(oldMenu);
|
||||
baseMenu = ::GetMenu(hWnd);
|
||||
// if (startInit)
|
||||
// SetIdsForSubMenes(baseMenu, 0, 0);
|
||||
if (!g_LangID.IsEmpty())
|
||||
MyChangeMenu(baseMenu, 0, 0);
|
||||
::DrawMenuBar(hWnd);
|
||||
@@ -277,8 +302,10 @@ void OnMenuActivating(HWND /* hWnd */, HMENU hMenu, int position)
|
||||
::GetMenu(g_HWND)
|
||||
#endif
|
||||
;
|
||||
|
||||
if (::GetSubMenu(mainMenu, position) != hMenu)
|
||||
return;
|
||||
|
||||
if (position == kMenuIndex_File)
|
||||
{
|
||||
CMenu menu;
|
||||
@@ -316,6 +343,72 @@ void OnMenuActivating(HWND /* hWnd */, HMENU hMenu, int position)
|
||||
menu.CheckItemByID(IDM_VIEW_AUTO_REFRESH, g_App.Get_AutoRefresh_Mode());
|
||||
// menu.CheckItemByID(IDM_VIEW_SHOW_STREAMS, g_App.Get_ShowNtfsStrems_Mode());
|
||||
// menu.CheckItemByID(IDM_VIEW_SHOW_DELETED, g_App.ShowDeletedFiles);
|
||||
|
||||
for (int i = 0;; i++)
|
||||
{
|
||||
CMenuItem item;
|
||||
item.fMask = Get_fMask_for_String() | MIIM_SUBMENU | MIIM_ID;
|
||||
item.fType = MFT_STRING;
|
||||
if (!menu.GetItem(i, true, item))
|
||||
break;
|
||||
if (item.hSubMenu && (item.wID == kMenuID_Time_Parent
|
||||
|| item.StringValue.IsPrefixedBy_Ascii_NoCase("20")
|
||||
))
|
||||
{
|
||||
FILETIME ft;
|
||||
NTime::GetCurUtcFileTime(ft);
|
||||
|
||||
{
|
||||
wchar_t s[64];
|
||||
s[0] = 0;
|
||||
if (ConvertUtcFileTimeToString(ft, s, kTimestampPrintLevel_DAY))
|
||||
item.StringValue = s;
|
||||
}
|
||||
|
||||
item.fMask = Get_fMask_for_String() | MIIM_ID;
|
||||
item.fType = MFT_STRING;
|
||||
item.wID = kMenuID_Time_Parent;
|
||||
menu.SetItem(i, true, item);
|
||||
|
||||
CMenu subMenu;
|
||||
subMenu.Attach(menu.GetSubMenu(i));
|
||||
subMenu.RemoveAllItems();
|
||||
|
||||
const int k_TimeLevels[] =
|
||||
{
|
||||
kTimestampPrintLevel_DAY,
|
||||
kTimestampPrintLevel_MIN,
|
||||
kTimestampPrintLevel_SEC,
|
||||
// 1,2,3,4,5,6,
|
||||
kTimestampPrintLevel_NTFS
|
||||
};
|
||||
|
||||
unsigned last = kMenuID_Time;
|
||||
unsigned selectedCommand = 0;
|
||||
g_App._timestampLevels.Clear();
|
||||
unsigned id = kMenuID_Time;
|
||||
|
||||
for (unsigned k = 0; k < ARRAY_SIZE(k_TimeLevels); k++)
|
||||
{
|
||||
wchar_t s[64];
|
||||
s[0] = 0;
|
||||
int timestampLevel = k_TimeLevels[k];
|
||||
if (ConvertUtcFileTimeToString(ft, s, timestampLevel))
|
||||
{
|
||||
if (subMenu.AppendItem(MF_STRING, id, s))
|
||||
{
|
||||
last = id;
|
||||
g_App._timestampLevels.Add(timestampLevel);
|
||||
if (g_App.GetTimestampLevel() == timestampLevel)
|
||||
selectedCommand = id;
|
||||
id++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (selectedCommand != 0)
|
||||
menu.CheckRadioItem(kMenuID_Time, last, selectedCommand, MF_BYCOMMAND);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (position == kMenuIndex_Bookmarks)
|
||||
{
|
||||
@@ -331,9 +424,9 @@ void OnMenuActivating(HWND /* hWnd */, HMENU hMenu, int position)
|
||||
{
|
||||
UString s = LangString(IDS_BOOKMARK);
|
||||
s.Add_Space();
|
||||
wchar_t c = (wchar_t)(L'0' + i);
|
||||
char c = (char)(L'0' + i);
|
||||
s += c;
|
||||
s.AddAscii("\tAlt+Shift+");
|
||||
s += "\tAlt+Shift+";
|
||||
s += c;
|
||||
subMenu.AppendItem(MF_STRING, kSetBookmarkMenuID + i, s);
|
||||
}
|
||||
@@ -351,9 +444,9 @@ void OnMenuActivating(HWND /* hWnd */, HMENU hMenu, int position)
|
||||
s.Insert(kFirstPartSize, L" ... ");
|
||||
}
|
||||
if (s.IsEmpty())
|
||||
s = L'-';
|
||||
s.AddAscii("\tAlt+");
|
||||
s += (wchar_t)(L'0' + i);
|
||||
s = '-';
|
||||
s += "\tAlt+";
|
||||
s += (char)('0' + i);
|
||||
menu.AppendItem(MF_STRING, kOpenBookmarkMenuID + i, s);
|
||||
}
|
||||
}
|
||||
@@ -396,6 +489,15 @@ void CFileMenu::Load(HMENU hMenu, unsigned startPos)
|
||||
continue;
|
||||
|
||||
if (item.wID == IDM_OPEN_INSIDE_ONE || item.wID == IDM_OPEN_INSIDE_PARSER)
|
||||
{
|
||||
// We use diff as "super mode" marker for additional commands.
|
||||
/*
|
||||
if (diffPath.IsEmpty())
|
||||
continue;
|
||||
*/
|
||||
}
|
||||
|
||||
if (item.wID == IDM_BENCHMARK2)
|
||||
{
|
||||
// We use diff as "super mode" marker for additional commands.
|
||||
if (diffPath.IsEmpty())
|
||||
@@ -473,11 +575,11 @@ bool ExecuteFileCommand(int id)
|
||||
case IDM_MOVE_TO: g_App.MoveTo(); break;
|
||||
case IDM_DELETE: g_App.Delete(!IsKeyDown(VK_SHIFT)); break;
|
||||
|
||||
case IDM_HASH_ALL: g_App.CalculateCrc(L"*"); break;
|
||||
case IDM_CRC32: g_App.CalculateCrc(L"CRC32"); break;
|
||||
case IDM_CRC64: g_App.CalculateCrc(L"CRC64"); break;
|
||||
case IDM_SHA1: g_App.CalculateCrc(L"SHA1"); break;
|
||||
case IDM_SHA256: g_App.CalculateCrc(L"SHA256"); break;
|
||||
case IDM_HASH_ALL: g_App.CalculateCrc("*"); break;
|
||||
case IDM_CRC32: g_App.CalculateCrc("CRC32"); break;
|
||||
case IDM_CRC64: g_App.CalculateCrc("CRC64"); break;
|
||||
case IDM_SHA1: g_App.CalculateCrc("SHA1"); break;
|
||||
case IDM_SHA256: g_App.CalculateCrc("SHA256"); break;
|
||||
|
||||
case IDM_DIFF: g_App.DiffFiles(); break;
|
||||
case IDM_SPLIT: g_App.Split(); break;
|
||||
@@ -614,7 +716,7 @@ bool OnMenuCommand(HWND hWnd, int id)
|
||||
|
||||
// Help
|
||||
case IDM_HELP_CONTENTS:
|
||||
ShowHelpWindow(NULL, kFMHelpTopic);
|
||||
ShowHelpWindow(kFMHelpTopic);
|
||||
break;
|
||||
case IDM_ABOUT:
|
||||
{
|
||||
@@ -634,6 +736,12 @@ bool OnMenuCommand(HWND hWnd, int id)
|
||||
g_App.SetBookmark(id - kSetBookmarkMenuID);
|
||||
return true;
|
||||
}
|
||||
else if (id >= kMenuID_Time && (unsigned)id <= kMenuID_Time + g_App._timestampLevels.Size())
|
||||
{
|
||||
unsigned index = id - kMenuID_Time;
|
||||
g_App.SetTimestampLevel(g_App._timestampLevels[index]);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,7 +232,7 @@ STDMETHODIMP CNetFolder::BindToParentFolder(IFolderFolder **resultFolder)
|
||||
|
||||
CNetFolder *netFolder = new CNetFolder;
|
||||
CMyComPtr<IFolderFolder> subFolder = netFolder;
|
||||
netFolder->Init(&resourceParent, 0, WCHAR_PATH_SEPARATOR);
|
||||
netFolder->Init(&resourceParent, 0, WSTRING_PATH_SEPARATOR);
|
||||
*resultFolder = subFolder.Detach();
|
||||
}
|
||||
return S_OK;
|
||||
|
||||
@@ -22,10 +22,10 @@ STDMETHODIMP COpenArchiveCallback::SetTotal(const UInt64 *numFiles, const UInt64
|
||||
RINOK(ProgressDialog.Sync.CheckStop());
|
||||
{
|
||||
// NSynchronization::CCriticalSectionLock lock(_criticalSection);
|
||||
if (numFiles)
|
||||
ProgressDialog.Sync.Set_NumFilesTotal(numFiles ? *numFiles : (UInt64)(Int64)-1);
|
||||
// if (numFiles)
|
||||
{
|
||||
ProgressDialog.Sync.Set_NumFilesTotal(*numFiles);
|
||||
ProgressDialog.Sync.Set_BytesProgressMode(false);
|
||||
ProgressDialog.Sync.Set_BytesProgressMode(numFiles == NULL);
|
||||
}
|
||||
if (numBytes)
|
||||
ProgressDialog.Sync.Set_NumBytesTotal(*numBytes);
|
||||
|
||||
@@ -40,6 +40,12 @@ void COverwriteDialog::ReduceString(UString &s)
|
||||
s.Delete(size / 2, s.Len() - size);
|
||||
s.Insert(size / 2, L" ... ");
|
||||
}
|
||||
if (!s.IsEmpty() && s.Back() == ' ')
|
||||
{
|
||||
// s += (wchar_t)(0x2423);
|
||||
s.InsertAtFront(L'\"');
|
||||
s += L'\"';
|
||||
}
|
||||
}
|
||||
|
||||
void COverwriteDialog::SetFileInfoControl(int textID, int iconID,
|
||||
@@ -66,13 +72,10 @@ void COverwriteDialog::SetFileInfoControl(int textID, int iconID,
|
||||
|
||||
if (fileInfo.TimeIsDefined)
|
||||
{
|
||||
FILETIME localFileTime;
|
||||
if (!FileTimeToLocalFileTime(&fileInfo.Time, &localFileTime))
|
||||
throw 4190402;
|
||||
AddLangString(s, IDS_PROP_MTIME);
|
||||
s += L": ";
|
||||
wchar_t t[32];
|
||||
ConvertFileTimeToString(localFileTime, t);
|
||||
s += ": ";
|
||||
char t[32];
|
||||
ConvertUtcFileTimeToString(fileInfo.Time, t);
|
||||
s += t;
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ HWND CPanel::GetParent()
|
||||
return (h == 0) ? _mainWindow : h;
|
||||
}
|
||||
|
||||
static LPCWSTR kClassName = L"7-Zip::Panel";
|
||||
#define kClassName L"7-Zip::Panel"
|
||||
|
||||
|
||||
HRESULT CPanel::Create(HWND mainWindow, HWND parentWindow, UINT id,
|
||||
@@ -933,7 +933,7 @@ void CPanel::ExtractArchives()
|
||||
if (indices.Size() == 1)
|
||||
outFolder += GetSubFolderNameForExtract2(GetItemRelPath(indices[0]));
|
||||
else
|
||||
outFolder += L'*';
|
||||
outFolder += '*';
|
||||
outFolder.Add_PathSepar();
|
||||
|
||||
::ExtractArchives(paths, outFolder
|
||||
@@ -947,9 +947,9 @@ static void AddValuePair(UINT resourceID, UInt64 value, UString &s)
|
||||
{
|
||||
AddLangString(s, resourceID);
|
||||
char sz[32];
|
||||
s += L": ";
|
||||
s += ": ";
|
||||
ConvertUInt64ToString(value, sz);
|
||||
s.AddAsciiStr(sz);
|
||||
s += sz;
|
||||
s.Add_LF();
|
||||
}
|
||||
*/
|
||||
@@ -999,11 +999,11 @@ static void AddSizePair(UInt32 langID, UInt64 value, UString &s)
|
||||
AddLangString(s, langID);
|
||||
s += L' ';
|
||||
ConvertUInt64ToString(value, sz);
|
||||
s.AddAsciiStr(sz);
|
||||
s += sz;
|
||||
ConvertUInt64ToString(value >> 20, sz);
|
||||
s.AddAsciiStr(" (");
|
||||
s.AddAsciiStr(sz);
|
||||
s.AddAsciiStr(" MB)");
|
||||
s += " (";
|
||||
s += sz;
|
||||
s += " MB)";
|
||||
s.Add_LF();
|
||||
}
|
||||
*/
|
||||
@@ -1051,11 +1051,10 @@ void CPanel::TestArchives()
|
||||
extracter.Indices = indices;
|
||||
|
||||
UString title = LangString(IDS_PROGRESS_TESTING);
|
||||
UString progressWindowTitle = L"7-Zip"; // LangString(IDS_APP_TITLE);
|
||||
|
||||
extracter.ProgressDialog.CompressingMode = false;
|
||||
extracter.ProgressDialog.MainWindow = GetParent();
|
||||
extracter.ProgressDialog.MainTitle = progressWindowTitle;
|
||||
extracter.ProgressDialog.MainTitle = "7-Zip"; // LangString(IDS_APP_TITLE);
|
||||
extracter.ProgressDialog.MainAddTitle = title + L' ';
|
||||
|
||||
extracter.ExtractCallbackSpec->OverwriteMode = NExtract::NOverwriteMode::kAskBefore;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "../../../Windows/FileFind.h"
|
||||
#include "../../../Windows/FileName.h"
|
||||
#include "../../../Windows/Handle.h"
|
||||
#include "../../../Windows/PropVariantConv.h"
|
||||
#include "../../../Windows/Synchronization.h"
|
||||
|
||||
#include "../../../Windows/Control/ComboBox.h"
|
||||
@@ -373,6 +374,16 @@ public:
|
||||
// CUIntVector _realIndices;
|
||||
bool _enableItemChangeNotify;
|
||||
bool _mySelectMode;
|
||||
|
||||
int _timestampLevel;
|
||||
|
||||
|
||||
void RedrawListItems()
|
||||
{
|
||||
_listView.RedrawAllItems();
|
||||
}
|
||||
|
||||
|
||||
CBoolVector _selectedStatusVector;
|
||||
|
||||
CSelectedState _selectedState;
|
||||
@@ -466,6 +477,7 @@ public:
|
||||
UString GetItemRelPath(int itemIndex) const;
|
||||
UString GetItemRelPath2(int itemIndex) const;
|
||||
UString GetItemFullPath(int itemIndex) const;
|
||||
UInt64 GetItem_UInt64Prop(int itemIndex, PROPID propID) const;
|
||||
UInt64 GetItemSize(int itemIndex) const;
|
||||
|
||||
////////////////////////
|
||||
@@ -487,6 +499,7 @@ public:
|
||||
void CloseOpenFolders();
|
||||
void OpenRootFolder();
|
||||
|
||||
UString GetParentDirPrefix() const;
|
||||
|
||||
HRESULT Create(HWND mainWindow, HWND parentWindow,
|
||||
UINT id,
|
||||
@@ -526,7 +539,9 @@ public:
|
||||
_thereAreDeletedItems(false),
|
||||
_markDeletedItems(true),
|
||||
_enableItemChangeNotify(true),
|
||||
_dontShowMode(false)
|
||||
_dontShowMode(false),
|
||||
|
||||
_timestampLevel(kTimestampPrintLevel_MIN)
|
||||
{}
|
||||
|
||||
void SetExtendedStyle()
|
||||
|
||||
@@ -183,7 +183,7 @@ HRESULT CPanel::CopyTo(CCopyToOptions &options, const CRecordVector<UInt32> &ind
|
||||
title = LangString(titleID);
|
||||
}
|
||||
|
||||
UString progressWindowTitle = L"7-Zip"; // LangString(IDS_APP_TITLE);
|
||||
UString progressWindowTitle ("7-Zip"); // LangString(IDS_APP_TITLE);
|
||||
|
||||
extracter.ProgressDialog.MainWindow = GetParent();
|
||||
extracter.ProgressDialog.MainTitle = progressWindowTitle;
|
||||
@@ -248,9 +248,12 @@ struct CThreadUpdate
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
HRESULT CPanel::CopyFrom(bool moveMode, const UString &folderPrefix, const UStringVector &filePaths,
|
||||
bool showErrorMessages, UStringVector *messages)
|
||||
{
|
||||
// CDisableNotify disableNotify(*this);
|
||||
|
||||
HRESULT res;
|
||||
if (!_folderOperations)
|
||||
res = E_NOINTERFACE;
|
||||
@@ -265,7 +268,7 @@ HRESULT CPanel::CopyFrom(bool moveMode, const UString &folderPrefix, const UStri
|
||||
updater.UpdateCallbackSpec->ProgressDialog = &updater.ProgressDialog;
|
||||
|
||||
UString title = LangString(IDS_COPYING);
|
||||
UString progressWindowTitle = L"7-Zip"; // LangString(IDS_APP_TITLE);
|
||||
UString progressWindowTitle ("7-Zip"); // LangString(IDS_APP_TITLE);
|
||||
|
||||
updater.ProgressDialog.MainWindow = GetParent();
|
||||
updater.ProgressDialog.MainTitle = progressWindowTitle;
|
||||
@@ -321,10 +324,10 @@ void CPanel::CopyFromNoAsk(const UStringVector &filePaths)
|
||||
CSelectedState srcSelState;
|
||||
SaveSelectedState(srcSelState);
|
||||
|
||||
HRESULT result = CopyFrom(false, L"", filePaths, true, 0);
|
||||
|
||||
CDisableNotify disableNotify(*this);
|
||||
|
||||
HRESULT result = CopyFrom(false, L"", filePaths, true, 0);
|
||||
|
||||
if (result != S_OK)
|
||||
{
|
||||
disableNotify.Restore();
|
||||
@@ -345,9 +348,9 @@ void CPanel::CopyFromAsk(const UStringVector &filePaths)
|
||||
{
|
||||
UString title = LangString(IDS_CONFIRM_FILE_COPY);
|
||||
UString message = LangString(IDS_WANT_TO_COPY_FILES);
|
||||
message += L"\n\'";
|
||||
message += "\n\'";
|
||||
message += _currentFolderPrefix;
|
||||
message += L"\' ?";
|
||||
message += "\' ?";
|
||||
int res = ::MessageBoxW(*(this), message, title, MB_YESNOCANCEL | MB_ICONQUESTION);
|
||||
if (res != IDYES)
|
||||
return;
|
||||
|
||||
@@ -128,14 +128,15 @@ DWORD CDirEnumerator::GetNextFile(NFind::CFileInfo &fi, bool &filled, FString &r
|
||||
FString s = resPath;
|
||||
s.Add_PathSepar();
|
||||
Prefixes.Add(s);
|
||||
s += FCHAR_ANY_MASK;
|
||||
Enumerators.Add(NFind::CEnumerator(BasePrefix + s));
|
||||
Enumerators.AddNew().SetDirPrefix(BasePrefix + s);
|
||||
}
|
||||
|
||||
filled = true;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
class CThreadCrc: public CProgressThreadVirt
|
||||
{
|
||||
HRESULT ProcessVirt();
|
||||
@@ -364,7 +365,7 @@ HRESULT CApp::CalculateCrc2(const UString &methodName)
|
||||
UString title = LangString(IDS_CHECKSUM_CALCULATING);
|
||||
|
||||
t.ProgressDialog.MainWindow = _window;
|
||||
t.ProgressDialog.MainTitle = L"7-Zip"; // LangString(IDS_APP_TITLE);
|
||||
t.ProgressDialog.MainTitle = "7-Zip"; // LangString(IDS_APP_TITLE);
|
||||
t.ProgressDialog.MainAddTitle = title;
|
||||
t.ProgressDialog.MainAddTitle.Add_Space();
|
||||
|
||||
@@ -374,9 +375,9 @@ HRESULT CApp::CalculateCrc2(const UString &methodName)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void CApp::CalculateCrc(const UString &methodName)
|
||||
void CApp::CalculateCrc(const char *methodName)
|
||||
{
|
||||
HRESULT res = CalculateCrc2(methodName);
|
||||
HRESULT res = CalculateCrc2(UString(methodName));
|
||||
if (res != S_OK && res != E_ABORT)
|
||||
{
|
||||
unsigned srcPanelIndex = GetFocusedPanelIndex();
|
||||
|
||||
@@ -31,8 +31,9 @@ using namespace NDir;
|
||||
extern bool g_IsNT;
|
||||
#endif
|
||||
|
||||
static CFSTR kTempDirPrefix = FTEXT("7zE");
|
||||
static LPCTSTR kSvenZipSetFolderFormat = TEXT("7-Zip::SetTargetFolder");
|
||||
#define kTempDirPrefix FTEXT("7zE")
|
||||
|
||||
static LPCTSTR const kSvenZipSetFolderFormat = TEXT("7-Zip::SetTargetFolder");
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
|
||||
@@ -619,7 +620,10 @@ bool CDropTarget::IsItSameDrive() const
|
||||
return false;
|
||||
}
|
||||
else if (m_Panel->IsFSDrivesFolder() && m_SelectionIndex >= 0)
|
||||
drive = m_SubFolderName + WCHAR_PATH_SEPARATOR;
|
||||
{
|
||||
drive = m_SubFolderName;
|
||||
drive.Add_PathSepar();
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
|
||||
@@ -67,6 +67,12 @@ void CPanel::SetToRootFolder()
|
||||
rootFolderSpec->Init();
|
||||
}
|
||||
|
||||
|
||||
static bool DoesNameContainWildcard_SkipRoot(const UString &path)
|
||||
{
|
||||
return DoesNameContainWildcard(path.Ptr(NName::GetRootPrefixSize(path)));
|
||||
}
|
||||
|
||||
HRESULT CPanel::BindToPath(const UString &fullPath, const UString &arcFormat, bool &archiveIsOpened, bool &encrypted)
|
||||
{
|
||||
UString path = fullPath;
|
||||
@@ -178,11 +184,11 @@ HRESULT CPanel::BindToPath(const UString &fullPath, const UString &arcFormat, bo
|
||||
else if (fileInfo.IsDir())
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (DoesNameContainWildcard(sysPath))
|
||||
if (DoesNameContainWildcard_SkipRoot(sysPath))
|
||||
{
|
||||
FString dirPrefix, fileName;
|
||||
NDir::GetFullPathAndSplit(us2fs(sysPath), dirPrefix, fileName);
|
||||
if (DoesNameContainWildcard(dirPrefix))
|
||||
if (DoesNameContainWildcard_SkipRoot(fs2us(dirPrefix)))
|
||||
return E_INVALIDARG;
|
||||
sysPath = fs2us(dirPrefix + fileInfo.Name);
|
||||
}
|
||||
@@ -200,10 +206,10 @@ HRESULT CPanel::BindToPath(const UString &fullPath, const UString &arcFormat, bo
|
||||
HRESULT res = S_OK;
|
||||
|
||||
#ifdef _WIN32
|
||||
if (DoesNameContainWildcard(dirPrefix))
|
||||
if (DoesNameContainWildcard_SkipRoot(fs2us(dirPrefix)))
|
||||
return E_INVALIDARG;
|
||||
|
||||
if (DoesNameContainWildcard(fileName))
|
||||
if (DoesNameContainWildcard(fs2us(fileName)))
|
||||
res = S_FALSE;
|
||||
else
|
||||
#endif
|
||||
@@ -281,7 +287,17 @@ HRESULT CPanel::BindToPathAndRefresh(const UString &path)
|
||||
CDisableTimerProcessing disableTimerProcessing(*this);
|
||||
CDisableNotify disableNotify(*this);
|
||||
bool archiveIsOpened, encrypted;
|
||||
HRESULT res = BindToPath(path, UString(), archiveIsOpened, encrypted);
|
||||
UString s = path;
|
||||
|
||||
#ifdef _WIN32
|
||||
if (!s.IsEmpty() && s[0] == '\"' && s.Back() == '\"')
|
||||
{
|
||||
s.DeleteBack();
|
||||
s.Delete(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
HRESULT res = BindToPath(s, UString(), archiveIsOpened, encrypted);
|
||||
RefreshListCtrl(UString(), -1, true, UStringVector());
|
||||
return res;
|
||||
}
|
||||
@@ -349,14 +365,14 @@ void CPanel::LoadFullPathAndShow()
|
||||
#else
|
||||
1
|
||||
#endif
|
||||
&& path.Back() == WCHAR_PATH_SEPARATOR)
|
||||
&& IS_PATH_SEPAR(path.Back()))
|
||||
path.DeleteBack();
|
||||
|
||||
DWORD attrib = FILE_ATTRIBUTE_DIRECTORY;
|
||||
|
||||
// GetRealIconIndex is slow for direct DVD/UDF path. So we use dummy path
|
||||
if (path.IsPrefixedBy(L"\\\\.\\"))
|
||||
path = L"_TestFolder_";
|
||||
path = "_TestFolder_";
|
||||
else
|
||||
{
|
||||
CFileInfo fi;
|
||||
@@ -456,7 +472,7 @@ void CPanel::AddComboBoxItem(const UString &name, int iconIndex, int indent, boo
|
||||
UString s;
|
||||
iconIndex = iconIndex;
|
||||
for (int i = 0; i < indent; i++)
|
||||
s += L" ";
|
||||
s += " ";
|
||||
_headerComboBox.AddString(s + name);
|
||||
|
||||
#else
|
||||
@@ -631,6 +647,30 @@ void CPanel::FoldersHistory()
|
||||
BindToPathAndRefresh(selectString);
|
||||
}
|
||||
|
||||
|
||||
UString CPanel::GetParentDirPrefix() const
|
||||
{
|
||||
UString s;
|
||||
if (!_currentFolderPrefix.IsEmpty())
|
||||
{
|
||||
wchar_t c = _currentFolderPrefix.Back();
|
||||
if (IS_PATH_SEPAR(c) || c == ':')
|
||||
{
|
||||
s = _currentFolderPrefix;
|
||||
s.DeleteBack();
|
||||
if (s != L"\\\\." &&
|
||||
s != L"\\\\?")
|
||||
{
|
||||
int pos = s.ReverseFind_PathSepar();
|
||||
if (pos >= 0)
|
||||
s.DeleteFrom(pos + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
void CPanel::OpenParentFolder()
|
||||
{
|
||||
LoadFullPath(); // Maybe we don't need it ??
|
||||
@@ -641,12 +681,12 @@ void CPanel::OpenParentFolder()
|
||||
if (!_currentFolderPrefix.IsEmpty())
|
||||
{
|
||||
wchar_t c = _currentFolderPrefix.Back();
|
||||
if (c == WCHAR_PATH_SEPARATOR || c == ':')
|
||||
if (IS_PATH_SEPAR(c) || c == ':')
|
||||
{
|
||||
focusedName = _currentFolderPrefix;
|
||||
focusedName.DeleteBack();
|
||||
/*
|
||||
if (c == ':' && !focusedName.IsEmpty() && focusedName.Back() == WCHAR_PATH_SEPARATOR)
|
||||
if (c == ':' && !focusedName.IsEmpty() && IS_PATH_SEPAR(focusedName.Back()))
|
||||
{
|
||||
focusedName.DeleteBack();
|
||||
}
|
||||
@@ -825,7 +865,7 @@ void CPanel::OpenAltStreams()
|
||||
path.DeleteBack();
|
||||
}
|
||||
|
||||
path += L':';
|
||||
path += ':';
|
||||
BindToPathAndRefresh(path);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ extern UInt64 g_RAM_Size;
|
||||
extern bool g_IsNT;
|
||||
#endif
|
||||
|
||||
static CFSTR kTempDirPrefix = FTEXT("7zO");
|
||||
#define kTempDirPrefix FTEXT("7zO")
|
||||
|
||||
// #define SHOW_DEBUG_INFO
|
||||
|
||||
@@ -534,23 +534,23 @@ HRESULT CPanel::OpenAsArc(IInStream *inStream,
|
||||
UString s2;
|
||||
if (!values[3].IsEmpty())
|
||||
{
|
||||
s2 = L"Can not open the file as [" + values[3] + L"] archive";
|
||||
s2 = "Can not open the file as [" + values[3] + "] archive";
|
||||
if (level2 != 0)
|
||||
s2 += L"\nThe file is open as [" + values[2] + L"] archive";
|
||||
s2 += "\nThe file is open as [" + values[2] + "] archive";
|
||||
}
|
||||
if (!values[0].IsEmpty())
|
||||
{
|
||||
if (!s2.IsEmpty())
|
||||
s2.Add_LF();
|
||||
s2 += L"[";
|
||||
s2 += "[";
|
||||
s2 += values[2];
|
||||
s2 += L"] Error: ";
|
||||
s2 += "] Error: ";
|
||||
s2 += values[0];
|
||||
}
|
||||
if (!s2.IsEmpty())
|
||||
{
|
||||
if (!s.IsEmpty())
|
||||
s += L"--------------------\n";
|
||||
s += "--------------------\n";
|
||||
s += values[1];
|
||||
s.Add_LF();
|
||||
s += s2;
|
||||
@@ -587,7 +587,7 @@ HRESULT CPanel::OpenAsArc_Msg(IInStream *inStream,
|
||||
|
||||
if (showErrorMessage && encrypted)
|
||||
{
|
||||
UString message = L"Error";
|
||||
UString message("Error");
|
||||
if (res == S_FALSE)
|
||||
{
|
||||
message = MyFormatNew(
|
||||
@@ -663,11 +663,15 @@ HRESULT CPanel::OpenParentArchiveFolder()
|
||||
}
|
||||
|
||||
|
||||
static const char *kStartExtensions =
|
||||
static const char * const kExeExtensions =
|
||||
" exe bat ps1 com"
|
||||
" ";
|
||||
|
||||
static const char * const kStartExtensions =
|
||||
#ifdef UNDER_CE
|
||||
" cab"
|
||||
#endif
|
||||
" exe bat com"
|
||||
" exe bat ps1 com"
|
||||
" chm"
|
||||
" msi doc xls ppt pps wps wpt wks xlr wdb vsd pub"
|
||||
|
||||
@@ -718,6 +722,51 @@ static bool DoItemAlwaysStart(const UString &name)
|
||||
|
||||
UString GetQuotedString(const UString &s);
|
||||
|
||||
|
||||
void SplitCmdLineSmart(const UString &cmd, UString &prg, UString ¶ms)
|
||||
{
|
||||
params.Empty();
|
||||
prg = cmd;
|
||||
prg.Trim();
|
||||
if (prg.Len() >= 2 && prg[0] == L'"')
|
||||
{
|
||||
int pos = prg.Find(L'"', 1);
|
||||
if (pos >= 0)
|
||||
{
|
||||
if ((unsigned)pos + 1 == prg.Len() || prg[pos + 1] == ' ')
|
||||
{
|
||||
params = prg.Ptr(pos + 1);
|
||||
params.Trim();
|
||||
prg.DeleteFrom(pos);
|
||||
prg.DeleteFrontal(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static WRes StartAppWithParams(const UString &cmd, const UStringVector ¶mVector, CProcess &process)
|
||||
{
|
||||
UString param;
|
||||
UString prg;
|
||||
|
||||
SplitCmdLineSmart(cmd, prg, param);
|
||||
|
||||
param.Trim();
|
||||
|
||||
// int pos = params.Find(L"%1");
|
||||
|
||||
FOR_VECTOR (i, paramVector)
|
||||
{
|
||||
if (!param.IsEmpty() && param.Back() != ' ')
|
||||
param.Add_Space();
|
||||
param += GetQuotedString(paramVector[i]);
|
||||
}
|
||||
|
||||
return process.Create(prg, param, NULL);
|
||||
}
|
||||
|
||||
|
||||
static HRESULT StartEditApplication(const UString &path, bool useEditor, HWND window, CProcess &process)
|
||||
{
|
||||
UString command;
|
||||
@@ -725,7 +774,7 @@ static HRESULT StartEditApplication(const UString &path, bool useEditor, HWND wi
|
||||
if (command.IsEmpty())
|
||||
{
|
||||
#ifdef UNDER_CE
|
||||
command = L"\\Windows\\";
|
||||
command = "\\Windows\\";
|
||||
#else
|
||||
FString winDir;
|
||||
if (!GetWindowsDir(winDir))
|
||||
@@ -733,15 +782,19 @@ static HRESULT StartEditApplication(const UString &path, bool useEditor, HWND wi
|
||||
NName::NormalizeDirPathPrefix(winDir);
|
||||
command = fs2us(winDir);
|
||||
#endif
|
||||
command += L"notepad.exe";
|
||||
command += "notepad.exe";
|
||||
}
|
||||
|
||||
HRESULT res = process.Create(command, GetQuotedString(path), NULL);
|
||||
UStringVector params;
|
||||
params.Add(path);
|
||||
|
||||
HRESULT res = StartAppWithParams(command, params, process);
|
||||
if (res != SZ_OK)
|
||||
::MessageBoxW(window, LangString(IDS_CANNOT_START_EDITOR), L"7-Zip", MB_OK | MB_ICONSTOP);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
void CApp::DiffFiles()
|
||||
{
|
||||
const CPanel &panel = GetFocusedPanel();
|
||||
@@ -779,16 +832,21 @@ void CApp::DiffFiles()
|
||||
if (command.IsEmpty())
|
||||
return;
|
||||
|
||||
UString param = GetQuotedString(path1);
|
||||
param.Add_Space();
|
||||
param += GetQuotedString(path2);
|
||||
UStringVector params;
|
||||
params.Add(path1);
|
||||
params.Add(path2);
|
||||
|
||||
HRESULT res = MyCreateProcess(command, param);
|
||||
HRESULT res;
|
||||
{
|
||||
CProcess process;
|
||||
res = StartAppWithParams(command, params, process);
|
||||
}
|
||||
if (res == SZ_OK)
|
||||
return;
|
||||
::MessageBoxW(_window, LangString(IDS_CANNOT_START_EDITOR), L"7-Zip", MB_OK | MB_ICONSTOP);
|
||||
}
|
||||
|
||||
|
||||
#ifndef _UNICODE
|
||||
typedef BOOL (WINAPI * ShellExecuteExWP)(LPSHELLEXECUTEINFOW lpExecInfo);
|
||||
#endif
|
||||
@@ -802,7 +860,7 @@ static HRESULT StartApplication(const UString &dir, const UString &path, HWND wi
|
||||
int dot = path2.ReverseFind_Dot();
|
||||
int separ = path2.ReverseFind_PathSepar();
|
||||
if (dot < 0 || dot < separ)
|
||||
path2 += L'.';
|
||||
path2 += '.';
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -841,8 +899,8 @@ static HRESULT StartApplication(const UString &dir, const UString &path, HWND wi
|
||||
;
|
||||
execInfo.hwnd = NULL;
|
||||
execInfo.lpVerb = NULL;
|
||||
const CSysString sysPath = GetSystemString(path2);
|
||||
const CSysString sysDir = GetSystemString(dir);
|
||||
const CSysString sysPath (GetSystemString(path2));
|
||||
const CSysString sysDir (GetSystemString(dir));
|
||||
execInfo.lpFile = sysPath;
|
||||
execInfo.lpParameters = NULL;
|
||||
execInfo.lpDirectory =
|
||||
@@ -896,27 +954,36 @@ void CPanel::EditItem(int index, bool useEditor)
|
||||
StartEditApplication(GetItemFullPath(index), useEditor, (HWND)*this, process);
|
||||
}
|
||||
|
||||
|
||||
void CPanel::OpenFolderExternal(int index)
|
||||
{
|
||||
UString fsPrefix = GetFsPath();
|
||||
UString name;
|
||||
UString prefix = GetFsPath();
|
||||
UString path = prefix;
|
||||
|
||||
if (index == kParentIndex)
|
||||
{
|
||||
int pos = fsPrefix.ReverseFind_PathSepar();
|
||||
if (pos >= 0 && pos == (int)fsPrefix.Len() - 1)
|
||||
{
|
||||
UString s = fsPrefix.Left(pos);
|
||||
pos = s.ReverseFind_PathSepar();
|
||||
if (pos >= 0)
|
||||
fsPrefix.SetFrom(s, pos + 1);
|
||||
}
|
||||
name = fsPrefix;
|
||||
if (prefix.IsEmpty())
|
||||
return;
|
||||
const wchar_t c = prefix.Back();
|
||||
if (!IS_PATH_SEPAR(c) && c != ':')
|
||||
return;
|
||||
prefix.DeleteBack();
|
||||
int pos = prefix.ReverseFind_PathSepar();
|
||||
if (pos < 0)
|
||||
return;
|
||||
prefix.DeleteFrom(pos + 1);
|
||||
path = prefix;
|
||||
}
|
||||
else
|
||||
name = fsPrefix + GetItemRelPath(index) + WCHAR_PATH_SEPARATOR;
|
||||
StartApplicationDontWait(fsPrefix, name, (HWND)*this);
|
||||
{
|
||||
path += GetItemRelPath(index);
|
||||
path.Add_PathSepar();
|
||||
}
|
||||
|
||||
StartApplicationDontWait(prefix, path, (HWND)*this);
|
||||
}
|
||||
|
||||
|
||||
bool CPanel::IsVirus_Message(const UString &name)
|
||||
{
|
||||
UString name2;
|
||||
@@ -928,12 +995,12 @@ bool CPanel::IsVirus_Message(const UString &name)
|
||||
|
||||
if (name2.Find(cRLO) >= 0)
|
||||
{
|
||||
UString badString = cRLO;
|
||||
const UString badString(cRLO);
|
||||
name2.Replace(badString, L"[RLO]");
|
||||
isVirus = true;
|
||||
}
|
||||
{
|
||||
const wchar_t *kVirusSpaces = L" ";
|
||||
const wchar_t * const kVirusSpaces = L" ";
|
||||
// const unsigned kNumSpaces = strlen(kVirusSpaces);
|
||||
for (;;)
|
||||
{
|
||||
@@ -945,6 +1012,27 @@ bool CPanel::IsVirus_Message(const UString &name)
|
||||
name2.Replace(kVirusSpaces, L" ");
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
{
|
||||
unsigned i;
|
||||
for (i = name2.Len(); i != 0;)
|
||||
{
|
||||
wchar_t c = name2[i - 1];
|
||||
if (c != '.' && c != ' ')
|
||||
break;
|
||||
i--;
|
||||
name2.ReplaceOneCharAtPos(i, '_');
|
||||
}
|
||||
if (i != name2.Len())
|
||||
{
|
||||
UString name3 = name2;
|
||||
name3.DeleteFrom(i);
|
||||
if (FindExt(kExeExtensions, name3))
|
||||
isVirus = true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!isVirus)
|
||||
return false;
|
||||
@@ -983,8 +1071,9 @@ void CPanel::OpenItem(int index, bool tryInternal, bool tryExternal, const wchar
|
||||
CDisableTimerProcessing disableTimerProcessing(*this);
|
||||
UString name = GetItemRelPath2(index);
|
||||
|
||||
if (IsVirus_Message(name))
|
||||
return;
|
||||
if (tryExternal)
|
||||
if (IsVirus_Message(name))
|
||||
return;
|
||||
|
||||
if (!_parentFolders.IsEmpty())
|
||||
{
|
||||
@@ -1330,7 +1419,7 @@ static THREAD_FUNC_DECL MyThreadFunction(void *param)
|
||||
|
||||
|
||||
#if defined(_WIN32) && !defined(UNDER_CE)
|
||||
static const FChar *k_ZoneId_StreamName = FTEXT(":Zone.Identifier");
|
||||
static const FChar * const k_ZoneId_StreamName = FTEXT(":Zone.Identifier");
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1443,7 +1532,7 @@ HRESULT CBufSeqOutStream_WithFile::FlushToFile()
|
||||
{
|
||||
outFileStream.Release();
|
||||
return E_FAIL;
|
||||
// MessageBoxMyError(UString(L"Can't create file ") + fs2us(tempFilePath));
|
||||
// MessageBoxMyError(UString("Can't create file ") + fs2us(tempFilePath));
|
||||
}
|
||||
}
|
||||
while (_fileWritePos != _pos)
|
||||
@@ -1494,8 +1583,9 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo
|
||||
const UString name = GetItemName(index);
|
||||
const UString relPath = GetItemRelPath(index);
|
||||
|
||||
if (IsVirus_Message(name))
|
||||
return;
|
||||
if (tryExternal)
|
||||
if (IsVirus_Message(name))
|
||||
return;
|
||||
|
||||
if (!_folderOperations)
|
||||
{
|
||||
|
||||
@@ -532,7 +532,7 @@ HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool
|
||||
|
||||
if (showDots)
|
||||
{
|
||||
UString itemName = L"..";
|
||||
UString itemName ("..");
|
||||
item.iItem = listViewItemCount;
|
||||
if (itemName == focusedName)
|
||||
cursorIndex = item.iItem;
|
||||
@@ -587,7 +587,7 @@ HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool
|
||||
unsigned prefixLen = 0;
|
||||
_folderGetItemName->GetItemPrefix(i, &prefix, &prefixLen);
|
||||
if (prefix)
|
||||
relPath += prefix;
|
||||
relPath = prefix;
|
||||
}
|
||||
if (!prefix)
|
||||
{
|
||||
@@ -595,7 +595,7 @@ HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool
|
||||
if (_folder->GetProperty(i, kpidPrefix, &prop) != S_OK)
|
||||
throw 2723400;
|
||||
if (prop.vt == VT_BSTR)
|
||||
relPath += prop.bstrVal;
|
||||
relPath.SetFromBstr(prop.bstrVal);
|
||||
}
|
||||
}
|
||||
relPath += name;
|
||||
@@ -637,7 +637,7 @@ HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool
|
||||
if (j < finish)
|
||||
{
|
||||
correctedName.Empty();
|
||||
correctedName = L"virus";
|
||||
correctedName = "virus";
|
||||
int pos = 0;
|
||||
for (;;)
|
||||
{
|
||||
@@ -648,7 +648,7 @@ HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool
|
||||
break;
|
||||
}
|
||||
correctedName += itemName.Mid(pos, posNew - pos);
|
||||
correctedName += L" ... ";
|
||||
correctedName += " ... ";
|
||||
pos = posNew;
|
||||
while (itemName[++pos] == ' ');
|
||||
}
|
||||
@@ -664,19 +664,6 @@ HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool
|
||||
LPSTR_TEXTCALLBACKW can be 2-3 times faster for loading in this loop. */
|
||||
}
|
||||
|
||||
UInt32 attrib = 0;
|
||||
// for (int yyy = 0; yyy < 6000000; yyy++) {
|
||||
NCOM::CPropVariant prop;
|
||||
RINOK(_folder->GetProperty(i, kpidAttrib, &prop));
|
||||
if (prop.vt == VT_UI4)
|
||||
{
|
||||
// char s[256]; sprintf(s, "attrib = %7x", attrib); OutputDebugStringA(s);
|
||||
attrib = prop.ulVal;
|
||||
}
|
||||
else if (IsItem_Folder(i))
|
||||
attrib |= FILE_ATTRIBUTE_DIRECTORY;
|
||||
// }
|
||||
|
||||
bool defined = false;
|
||||
|
||||
if (folderGetSystemIconIndex)
|
||||
@@ -684,8 +671,19 @@ HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool
|
||||
folderGetSystemIconIndex->GetSystemIconIndex(i, &item.iImage);
|
||||
defined = (item.iImage > 0);
|
||||
}
|
||||
|
||||
if (!defined)
|
||||
{
|
||||
UInt32 attrib = 0;
|
||||
{
|
||||
NCOM::CPropVariant prop;
|
||||
RINOK(_folder->GetProperty(i, kpidAttrib, &prop));
|
||||
if (prop.vt == VT_UI4)
|
||||
attrib = prop.ulVal;
|
||||
}
|
||||
if (IsItem_Folder(i))
|
||||
attrib |= FILE_ATTRIBUTE_DIRECTORY;
|
||||
|
||||
if (_currentFolderPrefix.IsEmpty())
|
||||
{
|
||||
int iconIndexTemp;
|
||||
@@ -993,7 +991,7 @@ void CPanel::GetItemName(int itemIndex, UString &s) const
|
||||
{
|
||||
if (itemIndex == kParentIndex)
|
||||
{
|
||||
s = L"..";
|
||||
s = "..";
|
||||
return;
|
||||
}
|
||||
NCOM::CPropVariant prop;
|
||||
@@ -1073,14 +1071,12 @@ bool CPanel::IsItem_AltStream(int itemIndex) const
|
||||
return GetItem_BoolProp(itemIndex, kpidIsAltStream);
|
||||
}
|
||||
|
||||
UInt64 CPanel::GetItemSize(int itemIndex) const
|
||||
UInt64 CPanel::GetItem_UInt64Prop(int itemIndex, PROPID propID) const
|
||||
{
|
||||
if (itemIndex == kParentIndex)
|
||||
return 0;
|
||||
if (_folderGetItemName)
|
||||
return _folderGetItemName->GetItemSize(itemIndex);
|
||||
NCOM::CPropVariant prop;
|
||||
if (_folder->GetProperty(itemIndex, kpidSize, &prop) != S_OK)
|
||||
if (_folder->GetProperty(itemIndex, propID, &prop) != S_OK)
|
||||
throw 2723400;
|
||||
UInt64 val = 0;
|
||||
if (ConvertPropVariantToUInt64(prop, val))
|
||||
@@ -1088,6 +1084,14 @@ UInt64 CPanel::GetItemSize(int itemIndex) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
UInt64 CPanel::GetItemSize(int itemIndex) const
|
||||
{
|
||||
if (itemIndex == kParentIndex)
|
||||
return 0;
|
||||
if (_folderGetItemName)
|
||||
return _folderGetItemName->GetItemSize(itemIndex);
|
||||
return GetItem_UInt64Prop(itemIndex, kpidSize);
|
||||
}
|
||||
|
||||
void CPanel::SaveListViewInfo()
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
// static LPCWSTR kHelpTopic = L"FM/index.htm";
|
||||
// #define kHelpTopic "FM/index.htm"
|
||||
|
||||
struct CVKeyPropIDPair
|
||||
{
|
||||
|
||||
@@ -19,6 +19,18 @@
|
||||
|
||||
using namespace NWindows;
|
||||
|
||||
/* Unicode characters for space:
|
||||
0x009C STRING TERMINATOR
|
||||
0x00B7 Middle dot
|
||||
0x237D Shouldered open box
|
||||
0x2420 Symbol for space
|
||||
0x2422 Blank symbol
|
||||
0x2423 Open box
|
||||
*/
|
||||
|
||||
#define SPACE_REPLACE_CHAR (wchar_t)(0x2423)
|
||||
#define SPACE_TERMINATOR_CHAR (wchar_t)(0x9C)
|
||||
|
||||
#define INT_TO_STR_SPEC(v) \
|
||||
while (v >= 10) { temp[i++] = (unsigned char)('0' + (unsigned)(v % 10)); v /= 10; } \
|
||||
*s++ = (unsigned char)('0' + (unsigned)v);
|
||||
@@ -42,7 +54,7 @@ static void ConvertSizeToString(UInt64 val, wchar_t *s) throw()
|
||||
{
|
||||
if (i != 0)
|
||||
{
|
||||
*s++ = temp[i - 1];
|
||||
*s++ = temp[(size_t)i - 1];
|
||||
if (i == 2)
|
||||
*s++ = temp[0];
|
||||
}
|
||||
@@ -62,9 +74,9 @@ static void ConvertSizeToString(UInt64 val, wchar_t *s) throw()
|
||||
do
|
||||
{
|
||||
s[0] = ' ';
|
||||
s[1] = temp[i - 1];
|
||||
s[2] = temp[i - 2];
|
||||
s[3] = temp[i - 3];
|
||||
s[1] = temp[(size_t)i - 1];
|
||||
s[2] = temp[(size_t)i - 2];
|
||||
s[3] = temp[(size_t)i - 3];
|
||||
s += 4;
|
||||
}
|
||||
while (i -= 3);
|
||||
@@ -337,17 +349,17 @@ LRESULT CPanel::SetItemText(LVITEMW &item)
|
||||
{
|
||||
if (c != 0x202E) // RLO
|
||||
continue;
|
||||
text[dest - 1] = '_';
|
||||
text[(size_t)dest - 1] = '_';
|
||||
continue;
|
||||
}
|
||||
|
||||
if (name[i + 1] != ' ')
|
||||
if (name[i] != ' ')
|
||||
continue;
|
||||
|
||||
unsigned t = 2;
|
||||
unsigned t = 1;
|
||||
for (; name[i + t] == ' '; t++);
|
||||
|
||||
if (t >= 4 && dest + 4 <= limit)
|
||||
|
||||
if (t >= 4 && dest + 4 < limit)
|
||||
{
|
||||
text[dest++] = '.';
|
||||
text[dest++] = '.';
|
||||
@@ -356,6 +368,20 @@ LRESULT CPanel::SetItemText(LVITEMW &item)
|
||||
i += t;
|
||||
}
|
||||
}
|
||||
|
||||
if (dest == 0)
|
||||
text[dest++]= '_';
|
||||
|
||||
#ifdef _WIN32
|
||||
else if (text[(size_t)dest - 1] == ' ')
|
||||
{
|
||||
if (dest < limit)
|
||||
text[dest++] = SPACE_TERMINATOR_CHAR;
|
||||
else
|
||||
text[dest - 1] = SPACE_REPLACE_CHAR;
|
||||
}
|
||||
#endif
|
||||
|
||||
text[dest] = 0;
|
||||
// OutputDebugStringW(text);
|
||||
return 0;
|
||||
@@ -392,7 +418,7 @@ LRESULT CPanel::SetItemText(LVITEMW &item)
|
||||
if (res != S_OK)
|
||||
{
|
||||
MyStringCopy(text, L"Error: ");
|
||||
// s = UString(L"Error: ") + HResultToMessage(res);
|
||||
// s = UString("Error: ") + HResultToMessage(res);
|
||||
}
|
||||
else if ((prop.vt == VT_UI8 || prop.vt == VT_UI4 || prop.vt == VT_UI2) && IsSizeProp(propID))
|
||||
{
|
||||
@@ -418,7 +444,7 @@ LRESULT CPanel::SetItemText(LVITEMW &item)
|
||||
else
|
||||
{
|
||||
char temp[64];
|
||||
ConvertPropertyToShortString(temp, prop, propID, false);
|
||||
ConvertPropertyToShortString2(temp, prop, propID, _timestampLevel);
|
||||
unsigned i;
|
||||
unsigned limit = item.cchTextMax - 1;
|
||||
for (i = 0; i < limit; i++)
|
||||
@@ -712,7 +738,7 @@ void CPanel::Refresh_StatusBar()
|
||||
{
|
||||
char dateString2[32];
|
||||
dateString2[0] = 0;
|
||||
ConvertPropertyToShortString(dateString2, prop, kpidMTime, false);
|
||||
ConvertPropertyToShortString2(dateString2, prop, kpidMTime);
|
||||
for (unsigned i = 0;; i++)
|
||||
{
|
||||
char c = dateString2[i];
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "../Explorer/ContextMenu.h"
|
||||
|
||||
#include "App.h"
|
||||
#include "FormatUtils.h"
|
||||
#include "LangUtils.h"
|
||||
#include "MyLoadMenu.h"
|
||||
#include "PropertyName.h"
|
||||
@@ -49,9 +50,9 @@ void CPanel::InvokeSystemCommand(const char *command)
|
||||
contextMenu->InvokeCommand(&ci);
|
||||
}
|
||||
|
||||
static const char *kSeparator = "----------------------------\n";
|
||||
static const char *kSeparatorSmall = "----\n";
|
||||
static const char *kPropValueSeparator = ": ";
|
||||
static const char * const kSeparator = "----------------------------\n";
|
||||
static const char * const kSeparatorSmall = "----\n";
|
||||
static const char * const kPropValueSeparator = ": ";
|
||||
|
||||
extern UString ConvertSizeToString(UInt64 value) throw();
|
||||
bool IsSizeProp(UINT propID) throw();
|
||||
@@ -82,12 +83,12 @@ static void AddPropertyString(PROPID propID, const wchar_t *nameBSTR,
|
||||
val = ConvertSizeToString(v);
|
||||
}
|
||||
else
|
||||
ConvertPropertyToString(val, prop, propID);
|
||||
ConvertPropertyToString2(val, prop, propID);
|
||||
|
||||
if (!val.IsEmpty())
|
||||
{
|
||||
s += GetNameOfProperty(propID, nameBSTR);
|
||||
s.AddAscii(kPropValueSeparator);
|
||||
s += kPropValueSeparator;
|
||||
/*
|
||||
if (propID == kpidComment)
|
||||
s.Add_LF();
|
||||
@@ -98,6 +99,14 @@ static void AddPropertyString(PROPID propID, const wchar_t *nameBSTR,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void AddPropertyString(PROPID propID, UInt64 val, UString &s)
|
||||
{
|
||||
NCOM::CPropVariant prop = val;
|
||||
AddPropertyString(propID, NULL, prop, s);
|
||||
}
|
||||
|
||||
|
||||
static inline char GetHex(Byte value)
|
||||
{
|
||||
return (char)((value < 10) ? ('0' + value) : ('A' + (value - 10)));
|
||||
@@ -132,10 +141,11 @@ void CPanel::Properties()
|
||||
|
||||
CRecordVector<UInt32> operatedIndices;
|
||||
GetOperatedItemIndices(operatedIndices);
|
||||
|
||||
if (operatedIndices.Size() == 1)
|
||||
{
|
||||
UInt32 index = operatedIndices[0];
|
||||
// message += L"Item:\n";
|
||||
// message += "Item:\n");
|
||||
UInt32 numProps;
|
||||
if (_folder->GetNumberOfProperties(&numProps) == S_OK)
|
||||
{
|
||||
@@ -182,10 +192,8 @@ void CPanel::Properties()
|
||||
const UInt32 kMaxDataSize = 64;
|
||||
if (dataSize > kMaxDataSize)
|
||||
{
|
||||
char temp[64];
|
||||
s += "data:";
|
||||
ConvertUInt32ToString(dataSize, temp);
|
||||
s += temp;
|
||||
s.Add_UInt32(dataSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -198,15 +206,53 @@ void CPanel::Properties()
|
||||
}
|
||||
}
|
||||
message += GetNameOfProperty(propID, name);
|
||||
message.AddAscii(kPropValueSeparator);
|
||||
message.AddAscii(s);
|
||||
message += kPropValueSeparator;
|
||||
message += s.Ptr();
|
||||
message.Add_LF();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
message.AddAscii(kSeparator);
|
||||
message += kSeparator;
|
||||
}
|
||||
else if (operatedIndices.Size() >= 1)
|
||||
{
|
||||
UInt64 packSize = 0;
|
||||
UInt64 unpackSize = 0;
|
||||
UInt64 numFiles = 0;
|
||||
UInt64 numDirs = 0;
|
||||
|
||||
FOR_VECTOR (i, operatedIndices)
|
||||
{
|
||||
const UInt32 index = operatedIndices[i];
|
||||
unpackSize += GetItemSize(index);
|
||||
packSize += GetItem_UInt64Prop(index, kpidPackSize);
|
||||
if (IsItem_Folder(index))
|
||||
{
|
||||
numDirs++;
|
||||
numDirs += GetItem_UInt64Prop(index, kpidNumSubDirs);
|
||||
numFiles += GetItem_UInt64Prop(index, kpidNumSubFiles);;
|
||||
}
|
||||
else
|
||||
numFiles++;
|
||||
}
|
||||
{
|
||||
wchar_t temp[32];
|
||||
ConvertUInt32ToString(operatedIndices.Size(), temp);
|
||||
message += MyFormatNew(g_App.LangString_N_SELECTED_ITEMS, temp);
|
||||
message.Add_LF();
|
||||
}
|
||||
|
||||
if (numDirs != 0)
|
||||
AddPropertyString(kpidNumSubDirs, numDirs, message);
|
||||
if (numFiles != 0)
|
||||
AddPropertyString(kpidNumSubFiles, numFiles, message);
|
||||
AddPropertyString(kpidSize, unpackSize, message);
|
||||
AddPropertyString(kpidPackSize, packSize, message);
|
||||
|
||||
message += kSeparator;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
AddLangString(message, IDS_PROP_FILE_TYPE);
|
||||
@@ -263,7 +309,7 @@ void CPanel::Properties()
|
||||
{
|
||||
const int kNumSpecProps = ARRAY_SIZE(kSpecProps);
|
||||
|
||||
message.AddAscii(kSeparator);
|
||||
message += kSeparator;
|
||||
|
||||
for (Int32 i = -(int)kNumSpecProps; i < (Int32)numProps; i++)
|
||||
{
|
||||
@@ -288,7 +334,7 @@ void CPanel::Properties()
|
||||
UInt32 numProps;
|
||||
if (getProps->GetArcNumProps2(level, &numProps) == S_OK)
|
||||
{
|
||||
message.AddAscii(kSeparatorSmall);
|
||||
message += kSeparatorSmall;
|
||||
for (Int32 i = 0; i < (Int32)numProps; i++)
|
||||
{
|
||||
CMyComBSTR name;
|
||||
@@ -331,8 +377,8 @@ void CPanel::EditCopy()
|
||||
GetSelectedItemsIndices(indices);
|
||||
FOR_VECTOR (i, indices)
|
||||
{
|
||||
if (i > 0)
|
||||
s += L"\xD\n";
|
||||
if (i != 0)
|
||||
s += "\xD\n";
|
||||
s += GetItemName(indices[i]);
|
||||
}
|
||||
ClipboardSetText(_mainWindow, s);
|
||||
@@ -755,7 +801,7 @@ bool CPanel::InvokePluginCommand(int id,
|
||||
commandInfo.hwnd = GetParent();
|
||||
commandInfo.lpVerb = (LPCSTR)(MAKEINTRESOURCE(offset));
|
||||
commandInfo.lpParameters = NULL;
|
||||
CSysString currentFolderSys = GetSystemString(_currentFolderPrefix);
|
||||
const CSysString currentFolderSys (GetSystemString(_currentFolderPrefix));
|
||||
commandInfo.lpDirectory = (LPCSTR)(LPCTSTR)(currentFolderSys);
|
||||
commandInfo.nShow = SW_SHOW;
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ HRESULT CThreadFolderOperations::DoOperation(CPanel &panel, const UString &progr
|
||||
|
||||
|
||||
ProgressDialog.MainWindow = panel._mainWindow; // panel.GetParent()
|
||||
ProgressDialog.MainTitle = L"7-Zip"; // LangString(IDS_APP_TITLE);
|
||||
ProgressDialog.MainTitle = "7-Zip"; // LangString(IDS_APP_TITLE);
|
||||
ProgressDialog.MainAddTitle = progressTitle + L' ';
|
||||
|
||||
RINOK(Create(progressTitle, ProgressDialog.MainWindow));
|
||||
@@ -138,7 +138,7 @@ void CPanel::DeleteItems(bool NON_CE_VAR(toRecycleBin))
|
||||
CDynamicBuffer<CHAR> buffer;
|
||||
FOR_VECTOR (i, indices)
|
||||
{
|
||||
const AString path = GetSystemString(GetItemFullPath(indices[i]));
|
||||
const AString path (GetSystemString(GetItemFullPath(indices[i])));
|
||||
buffer.AddData(path, path.Len() + 1);
|
||||
}
|
||||
*buffer.GetCurPtrAndGrow(1) = 0;
|
||||
@@ -502,7 +502,7 @@ void CPanel::ChangeComment()
|
||||
UString name = GetItemRelPath2(realIndex);
|
||||
CComboDialog dlg;
|
||||
dlg.Title = name;
|
||||
dlg.Title += L" : ";
|
||||
dlg.Title += " : ";
|
||||
AddLangString(dlg.Title, IDS_COMMENT);
|
||||
dlg.Value = comment;
|
||||
LangString(IDS_COMMENT2, dlg.Static);
|
||||
|
||||
@@ -156,7 +156,7 @@ void CPanel::SelectSpec(bool selectMode)
|
||||
CComboDialog dlg;
|
||||
LangString(selectMode ? IDS_SELECT : IDS_DESELECT, dlg.Title );
|
||||
LangString(IDS_SELECT_MASK, dlg.Static);
|
||||
dlg.Value = L'*';
|
||||
dlg.Value = '*';
|
||||
if (dlg.Create(GetParent()) != IDOK)
|
||||
return;
|
||||
const UString &mask = dlg.Value;
|
||||
@@ -192,7 +192,7 @@ void CPanel::SelectByType(bool selectMode)
|
||||
}
|
||||
else
|
||||
{
|
||||
UString mask = L'*';
|
||||
UString mask ('*');
|
||||
mask += name.Ptr(pos);
|
||||
FOR_VECTOR (i, _selectedStatusVector)
|
||||
if (IsItem_Folder(i) == isItemFolder && DoesWildcardMatchName(mask, GetItemName(i)))
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user