Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/CPP/7zip/UI
diff options
context:
space:
mode:
authorIgor Pavlov <ipavlov@users.sourceforge.net>2007-07-11 04:00:00 +0400
committerKornel LesiƄski <kornel@geekhood.net>2016-05-28 02:15:52 +0300
commit7038848692e7049234f223703522681a19db49a5 (patch)
tree38c5acef39a775a1f58f81b13be81fc6ef8c72e3 /CPP/7zip/UI
parentfd8b1d78b496fe38193bf8c5e86af3b43f0b022d (diff)
4.49 beta
Diffstat (limited to 'CPP/7zip/UI')
-rwxr-xr-xCPP/7zip/UI/Common/ExtractingFilePath.cpp17
-rwxr-xr-xCPP/7zip/UI/Common/LoadCodecs.cpp6
-rwxr-xr-xCPP/7zip/UI/Console/List.cpp30
-rwxr-xr-xCPP/7zip/UI/Far/ExtractEngine.cpp7
-rwxr-xr-xCPP/7zip/UI/Far/OverwriteDialog.cpp19
-rwxr-xr-xCPP/7zip/UI/Far/OverwriteDialog.h1
-rwxr-xr-xCPP/7zip/UI/Far/PluginWrite.cpp77
7 files changed, 134 insertions, 23 deletions
diff --git a/CPP/7zip/UI/Common/ExtractingFilePath.cpp b/CPP/7zip/UI/Common/ExtractingFilePath.cpp
index a0b17282..cfd4ae79 100755
--- a/CPP/7zip/UI/Common/ExtractingFilePath.cpp
+++ b/CPP/7zip/UI/Common/ExtractingFilePath.cpp
@@ -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)
diff --git a/CPP/7zip/UI/Common/LoadCodecs.cpp b/CPP/7zip/UI/Common/LoadCodecs.cpp
index 63b59045..a6c97aed 100755
--- a/CPP/7zip/UI/Common/LoadCodecs.cpp
+++ b/CPP/7zip/UI/Common/LoadCodecs.cpp
@@ -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")
diff --git a/CPP/7zip/UI/Console/List.cpp b/CPP/7zip/UI/Console/List.cpp
index 7891d5f3..48b8506a 100755
--- a/CPP/7zip/UI/Console/List.cpp
+++ b/CPP/7zip/UI/Console/List.cpp
@@ -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;
}
diff --git a/CPP/7zip/UI/Far/ExtractEngine.cpp b/CPP/7zip/UI/Far/ExtractEngine.cpp
index a71d22b8..d9499a04 100755
--- a/CPP/7zip/UI/Far/ExtractEngine.cpp
+++ b/CPP/7zip/UI/Far/ExtractEngine.cpp
@@ -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)
diff --git a/CPP/7zip/UI/Far/OverwriteDialog.cpp b/CPP/7zip/UI/Far/OverwriteDialog.cpp
index 4fbcbc9f..9272942f 100755
--- a/CPP/7zip/UI/Far/OverwriteDialog.cpp
+++ b/CPP/7zip/UI/Far/OverwriteDialog.cpp
@@ -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)
diff --git a/CPP/7zip/UI/Far/OverwriteDialog.h b/CPP/7zip/UI/Far/OverwriteDialog.h
index 6ff4590a..4715e53f 100755
--- a/CPP/7zip/UI/Far/OverwriteDialog.h
+++ b/CPP/7zip/UI/Far/OverwriteDialog.h
@@ -10,6 +10,7 @@ namespace NOverwriteDialog {
struct CFileInfo
{
bool SizeIsDefined;
+ bool TimeIsDefined;
UINT64 Size;
FILETIME Time;
CSysString Name;
diff --git a/CPP/7zip/UI/Far/PluginWrite.cpp b/CPP/7zip/UI/Far/PluginWrite.cpp
index 79fdbf8f..80f9916a 100755
--- a/CPP/7zip/UI/Far/PluginWrite.cpp
+++ b/CPP/7zip/UI/Far/PluginWrite.cpp
@@ -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;