mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-08 22:07:07 -06:00
4.49 beta
This commit is contained in:
committed by
Kornel Lesiński
parent
fd8b1d78b4
commit
7038848692
@@ -3,6 +3,21 @@
|
||||
#include "StdAfx.h"
|
||||
#include "ExtractingFilePath.h"
|
||||
|
||||
static UString ReplaceIncorrectChars(const UString &s)
|
||||
{
|
||||
UString res;
|
||||
for (int i = 0; i < s.Length(); i++)
|
||||
{
|
||||
wchar_t c = s[i];
|
||||
#ifdef _WIN32
|
||||
if (c < 0x20 || c == '*' || c == '?' || c == '<' || c == '>' || c == '|' || c == ':' || c == '"')
|
||||
c = '_';
|
||||
#endif
|
||||
res += c;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
static void ReplaceDisk(UString &s)
|
||||
{
|
||||
int i;
|
||||
@@ -58,7 +73,7 @@ UString GetCorrectPath(const UString &path)
|
||||
result.Replace(L"../", L"");
|
||||
|
||||
ReplaceDisk(result);
|
||||
return result;
|
||||
return ReplaceIncorrectChars(result);
|
||||
}
|
||||
|
||||
void MakeCorrectPath(UStringVector &pathParts)
|
||||
|
||||
@@ -28,15 +28,21 @@ static const UINT kIconTypesResId = 100;
|
||||
using namespace NWindows;
|
||||
using namespace NFile;
|
||||
|
||||
#ifdef _WIN32
|
||||
extern HINSTANCE g_hInstance;
|
||||
#endif
|
||||
|
||||
static CSysString GetLibraryFolderPrefix()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
TCHAR fullPath[MAX_PATH + 1];
|
||||
::GetModuleFileName(g_hInstance, fullPath, MAX_PATH);
|
||||
CSysString path = fullPath;
|
||||
int pos = path.ReverseFind(TEXT(CHAR_PATH_SEPARATOR));
|
||||
return path.Left(pos + 1);
|
||||
#else
|
||||
return CSysString(); // FIX IT
|
||||
#endif
|
||||
}
|
||||
|
||||
#define kCodecsFolderName TEXT("Codecs")
|
||||
|
||||
@@ -69,6 +69,7 @@ static const char kArchiveAttributeChar = 'A';
|
||||
|
||||
static const char *kListing = "Listing archive: ";
|
||||
static const wchar_t *kFilesMessage = L"files";
|
||||
static const wchar_t *kDirsMessage = L"folders";
|
||||
|
||||
static void GetAttributesString(DWORD wa, bool directory, char *s)
|
||||
{
|
||||
@@ -118,7 +119,7 @@ CFieldInfoInit kStandardFieldTable[] =
|
||||
{ kpidAttributes, L"Attr", kRight, kCenter, 1, 5 },
|
||||
{ kpidSize, L"Size", kRight, kRight, 1, 12 },
|
||||
{ kpidPackedSize, L"Compressed", kRight, kRight, 1, 12 },
|
||||
{ kpidPath, L"Name", kLeft, kLeft, 2, 12 }
|
||||
{ kpidPath, L"Name", kLeft, kLeft, 2, 24 }
|
||||
};
|
||||
|
||||
void PrintSpaces(int numSpaces)
|
||||
@@ -162,8 +163,8 @@ public:
|
||||
const NWindows::NFile::NFind::CFileInfoW &archiveFileInfo,
|
||||
UInt32 index,
|
||||
bool techMode);
|
||||
HRESULT PrintSummaryInfo(UInt64 numFiles, const UInt64 *size,
|
||||
const UInt64 *compressedSize);
|
||||
HRESULT PrintSummaryInfo(UInt64 numFiles, UInt64 numDirs,
|
||||
const UInt64 *size, const UInt64 *compressedSize);
|
||||
};
|
||||
|
||||
void CFieldPrinter::Init(const CFieldInfoInit *standardFieldTable, int numItems)
|
||||
@@ -354,7 +355,7 @@ void PrintNumberString(EAdjustment adjustment, int width, const UInt64 *value)
|
||||
}
|
||||
|
||||
|
||||
HRESULT CFieldPrinter::PrintSummaryInfo(UInt64 numFiles,
|
||||
HRESULT CFieldPrinter::PrintSummaryInfo(UInt64 numFiles, UInt64 numDirs,
|
||||
const UInt64 *size, const UInt64 *compressedSize)
|
||||
{
|
||||
for (int i = 0; i < _fields.Size(); i++)
|
||||
@@ -373,6 +374,11 @@ HRESULT CFieldPrinter::PrintSummaryInfo(UInt64 numFiles,
|
||||
UString temp = textString;
|
||||
temp += L" ";
|
||||
temp += kFilesMessage;
|
||||
temp += L", ";
|
||||
ConvertUInt64ToString(numDirs, textString);
|
||||
temp += textString;
|
||||
temp += L" ";
|
||||
temp += kDirsMessage;
|
||||
PrintString(fieldInfo.TextAdjustment, 0, temp);
|
||||
}
|
||||
else
|
||||
@@ -403,7 +409,7 @@ HRESULT ListArchives(
|
||||
if (!techMode)
|
||||
fieldPrinter.Init(kStandardFieldTable, sizeof(kStandardFieldTable) / sizeof(kStandardFieldTable[0]));
|
||||
|
||||
UInt64 numFiles2 = 0, totalPackSize2 = 0, totalUnPackSize2 = 0;
|
||||
UInt64 numFiles2 = 0, numDirs2 = 0, totalPackSize2 = 0, totalUnPackSize2 = 0;
|
||||
UInt64 *totalPackSizePointer2 = 0, *totalUnPackSizePointer2 = 0;
|
||||
for (int i = 0; i < archivePaths.Size(); i++)
|
||||
{
|
||||
@@ -465,7 +471,7 @@ HRESULT ListArchives(
|
||||
{
|
||||
RINOK(fieldPrinter.Init(archive));
|
||||
}
|
||||
UInt64 numFiles = 0, totalPackSize = 0, totalUnPackSize = 0;
|
||||
UInt64 numFiles = 0, numDirs = 0, totalPackSize = 0, totalUnPackSize = 0;
|
||||
UInt64 *totalPackSizePointer = 0, *totalUnPackSizePointer = 0;
|
||||
UInt32 numItems;
|
||||
RINOK(archive->GetNumberOfItems(&numItems));
|
||||
@@ -495,8 +501,11 @@ HRESULT ListArchives(
|
||||
totalPackSizePointer = &totalPackSize;
|
||||
|
||||
g_StdOut << endl;
|
||||
|
||||
numFiles++;
|
||||
|
||||
if (isFolder)
|
||||
numDirs++;
|
||||
else
|
||||
numFiles++;
|
||||
totalPackSize += packSize;
|
||||
totalUnPackSize += unpackSize;
|
||||
}
|
||||
@@ -504,7 +513,7 @@ HRESULT ListArchives(
|
||||
{
|
||||
fieldPrinter.PrintTitleLines();
|
||||
g_StdOut << endl;
|
||||
fieldPrinter.PrintSummaryInfo(numFiles, totalUnPackSizePointer, totalPackSizePointer);
|
||||
fieldPrinter.PrintSummaryInfo(numFiles, numDirs, totalUnPackSizePointer, totalPackSizePointer);
|
||||
g_StdOut << endl;
|
||||
}
|
||||
if (totalPackSizePointer != 0)
|
||||
@@ -518,13 +527,14 @@ HRESULT ListArchives(
|
||||
totalUnPackSize2 += totalUnPackSize;
|
||||
}
|
||||
numFiles2 += numFiles;
|
||||
numDirs2 += numDirs;
|
||||
}
|
||||
if (enableHeaders && !techMode && archivePaths.Size() > 1)
|
||||
{
|
||||
g_StdOut << endl;
|
||||
fieldPrinter.PrintTitleLines();
|
||||
g_StdOut << endl;
|
||||
fieldPrinter.PrintSummaryInfo(numFiles2, totalUnPackSizePointer2, totalPackSizePointer2);
|
||||
fieldPrinter.PrintSummaryInfo(numFiles2, numDirs2, totalUnPackSizePointer2, totalPackSizePointer2);
|
||||
g_StdOut << endl;
|
||||
g_StdOut << "Archives: " << archivePaths.Size() << endl;
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ STDMETHODIMP CExtractCallBackImp::SetCompleted(const UINT64 *completeValue)
|
||||
|
||||
STDMETHODIMP CExtractCallBackImp::AskOverwrite(
|
||||
const wchar_t *existName, const FILETIME *existTime, const UINT64 *existSize,
|
||||
const wchar_t *newName, const FILETIME *aNewTime, const UINT64 *newSize,
|
||||
const wchar_t *newName, const FILETIME *newTime, const UINT64 *newSize,
|
||||
INT32 *answer)
|
||||
{
|
||||
NOverwriteDialog::CFileInfo oldFileInfo, newFileInfo;
|
||||
@@ -67,8 +67,9 @@ STDMETHODIMP CExtractCallBackImp::AskOverwrite(
|
||||
oldFileInfo.Size = *existSize;
|
||||
oldFileInfo.Name = GetSystemString(existName, m_CodePage);
|
||||
|
||||
|
||||
newFileInfo.Time = *aNewTime;
|
||||
newFileInfo.TimeIsDefined = (newTime != 0);
|
||||
if (newFileInfo.TimeIsDefined)
|
||||
newFileInfo.Time = *newTime;
|
||||
|
||||
newFileInfo.SizeIsDefined = (newSize != NULL);
|
||||
if (newFileInfo.SizeIsDefined)
|
||||
|
||||
@@ -42,14 +42,17 @@ void SetFileInfoStrings(const CFileInfo &fileInfo,
|
||||
fileInfoStrings.Size = "";
|
||||
}
|
||||
|
||||
FILETIME localFileTime;
|
||||
if (!FileTimeToLocalFileTime(&fileInfo.Time, &localFileTime))
|
||||
throw 4190402;
|
||||
UString timeString = ConvertFileTimeToString(localFileTime);
|
||||
|
||||
fileInfoStrings.Time = g_StartupInfo.GetMsgString(NMessageID::kOverwriteModifiedOn);
|
||||
fileInfoStrings.Time += " ";
|
||||
fileInfoStrings.Time += GetSystemString(timeString, CP_OEMCP);
|
||||
FILETIME localFileTime;
|
||||
fileInfoStrings.Time.Empty();
|
||||
if (fileInfo.TimeIsDefined)
|
||||
{
|
||||
if (!FileTimeToLocalFileTime(&fileInfo.Time, &localFileTime))
|
||||
throw 4190402;
|
||||
UString timeString = ConvertFileTimeToString(localFileTime);
|
||||
fileInfoStrings.Time = g_StartupInfo.GetMsgString(NMessageID::kOverwriteModifiedOn);
|
||||
fileInfoStrings.Time += " ";
|
||||
fileInfoStrings.Time += GetSystemString(timeString, CP_OEMCP);
|
||||
}
|
||||
}
|
||||
|
||||
NResult::EEnum Execute(const CFileInfo &oldFileInfo, const CFileInfo &newFileInfo)
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace NOverwriteDialog {
|
||||
struct CFileInfo
|
||||
{
|
||||
bool SizeIsDefined;
|
||||
bool TimeIsDefined;
|
||||
UINT64 Size;
|
||||
FILETIME Time;
|
||||
CSysString Name;
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "Plugin.h"
|
||||
|
||||
#include "Common/Wildcard.h"
|
||||
#include "Common/StringConvert.h"
|
||||
|
||||
#include "Windows/FileDir.h"
|
||||
@@ -318,6 +319,80 @@ NFileOperationReturnCode::EEnum CPlugin::PutFiles(
|
||||
return NFileOperationReturnCode::kSuccess;
|
||||
}
|
||||
|
||||
namespace NPathType
|
||||
{
|
||||
enum EEnum
|
||||
{
|
||||
kLocal,
|
||||
kUNC
|
||||
};
|
||||
EEnum GetPathType(const UString &path);
|
||||
}
|
||||
|
||||
struct CParsedPath
|
||||
{
|
||||
UString Prefix; // Disk or UNC with slash
|
||||
UStringVector PathParts;
|
||||
void ParsePath(const UString &path);
|
||||
UString MergePath() const;
|
||||
};
|
||||
|
||||
static const wchar_t kDirDelimiter = WCHAR_PATH_SEPARATOR;
|
||||
static const wchar_t kDiskDelimiter = L':';
|
||||
|
||||
namespace NPathType
|
||||
{
|
||||
EEnum GetPathType(const UString &path)
|
||||
{
|
||||
if (path.Length() <= 2)
|
||||
return kLocal;
|
||||
if (path[0] == kDirDelimiter && path[1] == kDirDelimiter)
|
||||
return kUNC;
|
||||
return kLocal;
|
||||
}
|
||||
}
|
||||
|
||||
void CParsedPath::ParsePath(const UString &path)
|
||||
{
|
||||
int curPos = 0;
|
||||
switch (NPathType::GetPathType(path))
|
||||
{
|
||||
case NPathType::kLocal:
|
||||
{
|
||||
int posDiskDelimiter = path.Find(kDiskDelimiter);
|
||||
if(posDiskDelimiter >= 0)
|
||||
{
|
||||
curPos = posDiskDelimiter + 1;
|
||||
if (path.Length() > curPos)
|
||||
if(path[curPos] == kDirDelimiter)
|
||||
curPos++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case NPathType::kUNC:
|
||||
{
|
||||
int curPos = path.Find(kDirDelimiter, 2);
|
||||
if(curPos < 0)
|
||||
curPos = path.Length();
|
||||
else
|
||||
curPos++;
|
||||
}
|
||||
}
|
||||
Prefix = path.Left(curPos);
|
||||
SplitPathToParts(path.Mid(curPos), PathParts);
|
||||
}
|
||||
|
||||
UString CParsedPath::MergePath() const
|
||||
{
|
||||
UString result = Prefix;
|
||||
for(int i = 0; i < PathParts.Size(); i++)
|
||||
{
|
||||
if (i != 0)
|
||||
result += kDirDelimiter;
|
||||
result += PathParts[i];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@@ -375,7 +450,7 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
|
||||
|
||||
UString resultPath;
|
||||
{
|
||||
NName::CParsedPath parsedPath;
|
||||
CParsedPath parsedPath;
|
||||
parsedPath.ParsePath(fileNames.Front());
|
||||
if(parsedPath.PathParts.Size() == 0)
|
||||
return E_FAIL;
|
||||
|
||||
Reference in New Issue
Block a user