This commit is contained in:
Igor Pavlov
2010-11-11 00:00:00 +00:00
committed by Kornel Lesiński
parent c65230d858
commit b75af1bba6
25 changed files with 314 additions and 275 deletions

View File

@@ -187,6 +187,7 @@ static const char *kIncorrectWildCardInListFile = "Incorrect wildcard in listfil
static const char *kIncorrectWildCardInCommandLine = "Incorrect wildcard in command line";
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 terminal";
static const char *kEmptyFilePath = "Empty file path";
static void ThrowException(const char *errorMessage)
{
@@ -301,6 +302,8 @@ static void AddToCensorFromNonSwitchesStrings(
for (int i = startIndex; i < nonSwitchStrings.Size(); i++)
{
const UString &s = nonSwitchStrings[i];
if (s.IsEmpty())
throw kEmptyFilePath;
if (s[0] == kFileListID)
AddToCensorFromListFile(wildcardCensor, s.Mid(1), true, type, codePage);
else
@@ -861,6 +864,8 @@ void CArchiveCommandLineParser::Parse2(CArchiveCommandLineOptions &options)
if (curCommandIndex >= numNonSwitchStrings)
ThrowUserErrorException();
options.ArchiveName = nonSwitchStrings[curCommandIndex++];
if (options.ArchiveName.IsEmpty())
ThrowUserErrorException();
}
AddToCensorFromNonSwitchesStrings(

View File

@@ -387,12 +387,11 @@ static HRESULT Compress(
CMyComPtr<ISequentialOutStream> outStream;
const UString &archiveName = archivePath.GetFinalPath();
if (!stdOutMode)
{
UString resultPath;
int pos;
if (!NFile::NDirectory::MyGetFullPathName(archiveName, resultPath, pos))
if (!NFile::NDirectory::MyGetFullPathName(archivePath.GetFinalPath(), resultPath, pos))
throw 1417161;
NFile::NDirectory::CreateComplexDirectory(resultPath.Left(pos));
}
@@ -676,35 +675,38 @@ HRESULT UpdateArchive(
}
}
const UString archiveName = options.ArchivePath.GetFinalPath();
CArchiveLink archiveLink;
NFind::CFileInfoW archiveFileInfo;
CArchiveLink arcLink;
const UString arcPath = options.ArchivePath.GetFinalPath();
if (archiveFileInfo.Find(archiveName))
if (!options.ArchivePath.OriginalPath.IsEmpty())
{
if (archiveFileInfo.IsDir())
throw "there is no such archive";
if (options.VolumesSizes.Size() > 0)
return E_NOTIMPL;
CIntVector formatIndices;
if (options.MethodMode.FormatIndex >= 0)
formatIndices.Add(options.MethodMode.FormatIndex);
HRESULT result = archiveLink.Open2(codecs, formatIndices, false, NULL, archiveName, openCallback);
if (result == E_ABORT)
return result;
RINOK(callback->OpenResult(archiveName, result));
RINOK(result);
if (archiveLink.VolumePaths.Size() > 1)
NFind::CFileInfoW fi;
if (fi.Find(arcPath))
{
errorInfo.SystemError = (DWORD)E_NOTIMPL;
errorInfo.Message = L"Updating for multivolume archives is not implemented";
return E_NOTIMPL;
if (fi.IsDir())
throw "there is no such archive";
if (options.VolumesSizes.Size() > 0)
return E_NOTIMPL;
CIntVector formatIndices;
if (options.MethodMode.FormatIndex >= 0)
formatIndices.Add(options.MethodMode.FormatIndex);
HRESULT result = arcLink.Open2(codecs, formatIndices, false, NULL, arcPath, openCallback);
if (result == E_ABORT)
return result;
RINOK(callback->OpenResult(arcPath, result));
RINOK(result);
if (arcLink.VolumePaths.Size() > 1)
{
errorInfo.SystemError = (DWORD)E_NOTIMPL;
errorInfo.Message = L"Updating for multivolume archives is not implemented";
return E_NOTIMPL;
}
CArc &arc = arcLink.Arcs.Back();
arc.MTimeDefined = !fi.IsDevice;
arc.MTime = fi.MTime;
}
CArc &arc = archiveLink.Arcs.Back();
arc.MTimeDefined = !archiveFileInfo.IsDevice;
arc.MTime = archiveFileInfo.MTime;
}
else
{
@@ -771,7 +773,7 @@ HRESULT UpdateArchive(
bool createTempFile = false;
bool thereIsInArchive = archiveLink.IsOpen;
bool thereIsInArchive = arcLink.IsOpen;
if (!options.StdOutMode && options.UpdateArchiveItself)
{
@@ -800,7 +802,8 @@ HRESULT UpdateArchive(
// ap.Temp = true;
// ap.TempPrefix = tempDirPrefix;
}
if (i > 0 || !createTempFile)
if (!options.StdOutMode &&
(i > 0 || !createTempFile))
{
const UString &path = ap.GetFinalPath();
if (NFind::DoesFileOrDirExist(path))
@@ -816,18 +819,18 @@ HRESULT UpdateArchive(
CObjectVector<CArcItem> arcItems;
if (thereIsInArchive)
{
RINOK(EnumerateInArchiveItems(censor, archiveLink.Arcs.Back(), arcItems));
RINOK(EnumerateInArchiveItems(censor, arcLink.Arcs.Back(), arcItems));
}
RINOK(UpdateWithItemLists(codecs, options,
thereIsInArchive ? archiveLink.GetArchive() : 0,
thereIsInArchive ? arcLink.GetArchive() : 0,
arcItems, dirItems,
tempFiles, errorInfo, callback));
if (thereIsInArchive)
{
RINOK(archiveLink.Close());
archiveLink.Release();
RINOK(arcLink.Close());
arcLink.Release();
}
tempFiles.Paths.Clear();
@@ -838,19 +841,19 @@ HRESULT UpdateArchive(
CArchivePath &ap = options.Commands[0].ArchivePath;
const UString &tempPath = ap.GetTempPath();
if (thereIsInArchive)
if (!NDirectory::DeleteFileAlways(archiveName))
if (!NDirectory::DeleteFileAlways(arcPath))
{
errorInfo.SystemError = ::GetLastError();
errorInfo.Message = L"7-Zip cannot delete the file";
errorInfo.FileName = archiveName;
errorInfo.FileName = arcPath;
return E_FAIL;
}
if (!NDirectory::MyMoveFile(tempPath, archiveName))
if (!NDirectory::MyMoveFile(tempPath, arcPath))
{
errorInfo.SystemError = ::GetLastError();
errorInfo.Message = L"7-Zip cannot move the file";
errorInfo.FileName = tempPath;
errorInfo.FileName2 = archiveName;
errorInfo.FileName2 = arcPath;
return E_FAIL;
}
}

View File

@@ -1,20 +1,20 @@
// Update.h
#ifndef __UPDATE_H
#define __UPDATE_H
#ifndef __COMMON_UPDATE_H
#define __COMMON_UPDATE_H
#include "Common/Wildcard.h"
#include "Windows/FileFind.h"
#include "../../Archive/IArchive.h"
#include "UpdateAction.h"
#include "ArchiveOpenCallback.h"
#include "UpdateCallback.h"
#include "Property.h"
#include "LoadCodecs.h"
#include "Property.h"
#include "UpdateAction.h"
#include "UpdateCallback.h"
struct CArchivePath
{
UString OriginalPath;
UString Prefix; // path(folder) prefix including slash
UString Name; // base name
UString BaseExtension; // archive type extension or "exe" extension
@@ -28,11 +28,11 @@ struct CArchivePath
void ParseFromPath(const UString &path)
{
OriginalPath = path;
SplitPathToParts(path, Prefix, Name);
if (Name.IsEmpty())
return;
int dotPos = Name.ReverseFind(L'.');
if (dotPos <= 0)
if (dotPos < 0)
return;
if (dotPos == Name.Length() - 1)
{

View File

@@ -53,9 +53,33 @@ NUserAnswerMode::EEnum ScanUserYesNoAllQuit(CStdOutStream *outStream)
}
}
#ifdef _WIN32
#ifndef UNDER_CE
#define MY_DISABLE_ECHO
#endif
#endif
UString GetPassword(CStdOutStream *outStream)
{
(*outStream) << "\nEnter password:";
(*outStream) << "\nEnter password"
#ifdef MY_DISABLE_ECHO
" (will not be echoed)"
#endif
":";
outStream->Flush();
#ifdef MY_DISABLE_ECHO
HANDLE console = GetStdHandle(STD_INPUT_HANDLE);
bool wasChanged = false;
DWORD mode = 0;
if (console != INVALID_HANDLE_VALUE && console != 0)
if (GetConsoleMode(console, &mode))
wasChanged = (SetConsoleMode(console, mode & ~ENABLE_ECHO_INPUT) != 0);
UString res = g_StdIn.ScanUStringUntilNewLine();
if (wasChanged)
SetConsoleMode(console, mode);
return res;
#else
return g_StdIn.ScanUStringUntilNewLine();
#endif
}

View File

@@ -125,6 +125,8 @@ bool CListViewDialog::OnNotify(UINT /* controlID */, LPNMHDR header)
}
case 'A':
{
// probably that code is unused ?
/*
bool ctrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0;
if (ctrl)
{
@@ -133,6 +135,7 @@ bool CListViewDialog::OnNotify(UINT /* controlID */, LPNMHDR header)
_listView.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
return true;
}
*/
}
}
}

View File

@@ -210,7 +210,7 @@ static const char *kStartExtensions =
#endif
" exe bat com"
" chm"
" msi doc xls ppt pps wps wpt wks xlr wdb vsd"
" msi doc xls ppt pps wps wpt wks xlr wdb vsd pub"
" docx docm dotx dotm xlsx xlsm xltx xltm xlsb"
" xlam pptx pptm potx potm ppam ppsx ppsm xsn"

View File

@@ -439,6 +439,7 @@ HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool
{
if (focusedPos >= _listView.GetItemCount())
focusedPos = _listView.GetItemCount() - 1;
// we select item only in showDots mode.
SetFocusedSelectedItem(focusedPos, showDots);
}
// m_RedrawEnabled = true;
@@ -484,7 +485,7 @@ void CPanel::GetOperatedItemIndices(CRecordVector<UInt32> &indices) const
{
int realIndex = GetRealItemIndex(focusedItem);
if (realIndex != kParentIndex)
indices.Add(realIndex);
indices.Add(realIndex);
}
}
}

View File

@@ -245,7 +245,14 @@ void CPanel::KillSelection()
{
int focused = _listView.GetFocusedItem();
if (focused >= 0)
{
// CPanel::OnItemChanged notify for LVIS_SELECTED change doesn't work here. Why?
// so we change _selectedStatusVector[realIndex] here.
int realIndex = GetRealItemIndex(focused);
if (realIndex != kParentIndex)
_selectedStatusVector[realIndex] = true;
_listView.SetItemState(focused, LVIS_SELECTED, LVIS_SELECTED);
}
}
}
@@ -297,4 +304,3 @@ void CPanel::OnLeftClick(MY_NMLISTVIEW_NMITEMACTIVATE *itemActivate)
}
return;
}