[llvm-commits] [test-suite] r170306 [5/7] - in /test-suite/trunk: ./ MultiSource/Benchmarks/ MultiSource/Benchmarks/7zip/ MultiSource/Benchmarks/7zip/C/ MultiSource/Benchmarks/7zip/C/LzmaUtil/ MultiSource/Benchmarks/7zip/CPP/ MultiSource/Benchmarks/7zip/CPP/7zip/ MultiSource/Benchmarks/7zip/CPP/7zip/Archive/ MultiSource/Benchmarks/7zip/CPP/7zip/Archive/7z/ MultiSource/Benchmarks/7zip/CPP/7zip/Archive/Cab/ MultiSource/Benchmarks/7zip/CPP/7zip/Archive/Chm/ MultiSource/Benchmarks/7zip/CPP/7zip/Archive/Com/ MultiSource/Ben...
Michael Gottesman
mgottesman at apple.com
Sun Dec 16 21:23:34 PST 2012
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/Update.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/Update.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/Update.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/Update.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,912 @@
+// Update.cpp
+
+#include "StdAfx.h"
+
+#include "Update.h"
+
+#include "Common/IntToString.h"
+#include "Common/StringConvert.h"
+
+#ifdef _WIN32
+#include "Windows/DLL.h"
+#endif
+
+#include "Windows/FileDir.h"
+#include "Windows/FileFind.h"
+#include "Windows/FileName.h"
+#include "Windows/PropVariant.h"
+#include "Windows/PropVariantConversions.h"
+#include "Windows/Time.h"
+
+#include "../../Common/FileStreams.h"
+
+#include "../../Compress/CopyCoder.h"
+
+#include "../Common/DirItem.h"
+#include "../Common/EnumDirItems.h"
+#include "../Common/OpenArchive.h"
+#include "../Common/UpdateProduce.h"
+
+#include "EnumDirItems.h"
+#include "SetProperties.h"
+#include "TempFiles.h"
+#include "UpdateCallback.h"
+
+static const char *kUpdateIsNotSupoorted =
+ "update operations are not supported for this archive";
+
+using namespace NWindows;
+using namespace NCOM;
+using namespace NFile;
+using namespace NName;
+
+#ifdef _WIN32
+static const wchar_t *kTempFolderPrefix = L"7zE";
+#endif
+
+using namespace NUpdateArchive;
+
+class COutMultiVolStream:
+ public IOutStream,
+ public CMyUnknownImp
+{
+ int _streamIndex; // required stream
+ UInt64 _offsetPos; // offset from start of _streamIndex index
+ UInt64 _absPos;
+ UInt64 _length;
+
+ struct CSubStreamInfo
+ {
+ COutFileStream *StreamSpec;
+ CMyComPtr<IOutStream> Stream;
+ UString Name;
+ UInt64 Pos;
+ UInt64 RealSize;
+ };
+ CObjectVector<CSubStreamInfo> Streams;
+public:
+ // CMyComPtr<IArchiveUpdateCallback2> VolumeCallback;
+ CRecordVector<UInt64> Sizes;
+ UString Prefix;
+ CTempFiles *TempFiles;
+
+ void Init()
+ {
+ _streamIndex = 0;
+ _offsetPos = 0;
+ _absPos = 0;
+ _length = 0;
+ }
+
+ HRESULT Close();
+
+ MY_UNKNOWN_IMP1(IOutStream)
+
+ STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
+ STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
+ STDMETHOD(SetSize)(UInt64 newSize);
+};
+
+// static NSynchronization::CCriticalSection g_TempPathsCS;
+
+HRESULT COutMultiVolStream::Close()
+{
+ HRESULT res = S_OK;
+ for (int i = 0; i < Streams.Size(); i++)
+ {
+ CSubStreamInfo &s = Streams[i];
+ if (s.StreamSpec)
+ {
+ HRESULT res2 = s.StreamSpec->Close();
+ if (res2 != S_OK)
+ res = res2;
+ }
+ }
+ return res;
+}
+
+STDMETHODIMP COutMultiVolStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
+{
+ if (processedSize != NULL)
+ *processedSize = 0;
+ while(size > 0)
+ {
+ if (_streamIndex >= Streams.Size())
+ {
+ CSubStreamInfo subStream;
+
+ wchar_t temp[16];
+ ConvertUInt32ToString(_streamIndex + 1, temp);
+ UString res = temp;
+ while (res.Length() < 3)
+ res = UString(L'0') + res;
+ UString name = Prefix + res;
+ subStream.StreamSpec = new COutFileStream;
+ subStream.Stream = subStream.StreamSpec;
+ if (!subStream.StreamSpec->Create(name, false))
+ return ::GetLastError();
+ {
+ // NSynchronization::CCriticalSectionLock lock(g_TempPathsCS);
+ TempFiles->Paths.Add(name);
+ }
+
+ subStream.Pos = 0;
+ subStream.RealSize = 0;
+ subStream.Name = name;
+ Streams.Add(subStream);
+ continue;
+ }
+ CSubStreamInfo &subStream = Streams[_streamIndex];
+
+ int index = _streamIndex;
+ if (index >= Sizes.Size())
+ index = Sizes.Size() - 1;
+ UInt64 volSize = Sizes[index];
+
+ if (_offsetPos >= volSize)
+ {
+ _offsetPos -= volSize;
+ _streamIndex++;
+ continue;
+ }
+ if (_offsetPos != subStream.Pos)
+ {
+ // CMyComPtr<IOutStream> outStream;
+ // RINOK(subStream.Stream.QueryInterface(IID_IOutStream, &outStream));
+ RINOK(subStream.Stream->Seek(_offsetPos, STREAM_SEEK_SET, NULL));
+ subStream.Pos = _offsetPos;
+ }
+
+ UInt32 curSize = (UInt32)MyMin((UInt64)size, volSize - subStream.Pos);
+ UInt32 realProcessed;
+ RINOK(subStream.Stream->Write(data, curSize, &realProcessed));
+ data = (void *)((Byte *)data + realProcessed);
+ size -= realProcessed;
+ subStream.Pos += realProcessed;
+ _offsetPos += realProcessed;
+ _absPos += realProcessed;
+ if (_absPos > _length)
+ _length = _absPos;
+ if (_offsetPos > subStream.RealSize)
+ subStream.RealSize = _offsetPos;
+ if (processedSize != NULL)
+ *processedSize += realProcessed;
+ if (subStream.Pos == volSize)
+ {
+ _streamIndex++;
+ _offsetPos = 0;
+ }
+ if (realProcessed == 0 && curSize != 0)
+ return E_FAIL;
+ break;
+ }
+ return S_OK;
+}
+
+STDMETHODIMP COutMultiVolStream::Seek(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition)
+{
+ if (seekOrigin >= 3)
+ return STG_E_INVALIDFUNCTION;
+ switch(seekOrigin)
+ {
+ case STREAM_SEEK_SET:
+ _absPos = offset;
+ break;
+ case STREAM_SEEK_CUR:
+ _absPos += offset;
+ break;
+ case STREAM_SEEK_END:
+ _absPos = _length + offset;
+ break;
+ }
+ _offsetPos = _absPos;
+ if (newPosition != NULL)
+ *newPosition = _absPos;
+ _streamIndex = 0;
+ return S_OK;
+}
+
+STDMETHODIMP COutMultiVolStream::SetSize(UInt64 newSize)
+{
+ if (newSize < 0)
+ return E_INVALIDARG;
+ int i = 0;
+ while (i < Streams.Size())
+ {
+ CSubStreamInfo &subStream = Streams[i++];
+ if ((UInt64)newSize < subStream.RealSize)
+ {
+ RINOK(subStream.Stream->SetSize(newSize));
+ subStream.RealSize = newSize;
+ break;
+ }
+ newSize -= subStream.RealSize;
+ }
+ while (i < Streams.Size())
+ {
+ {
+ CSubStreamInfo &subStream = Streams.Back();
+ subStream.Stream.Release();
+ NDirectory::DeleteFileAlways(subStream.Name);
+ }
+ Streams.DeleteBack();
+ }
+ _offsetPos = _absPos;
+ _streamIndex = 0;
+ _length = newSize;
+ return S_OK;
+}
+
+static const wchar_t *kDefaultArchiveType = L"7z";
+static const wchar_t *kSFXExtension =
+ #ifdef _WIN32
+ L"exe";
+ #else
+ L"";
+ #endif
+
+bool CUpdateOptions::Init(const CCodecs *codecs, const CIntVector &formatIndices, const UString &arcPath)
+{
+ if (formatIndices.Size() > 1)
+ return false;
+ int arcTypeIndex = -1;
+ if (formatIndices.Size() != 0)
+ arcTypeIndex = formatIndices[0];
+ if (arcTypeIndex >= 0)
+ MethodMode.FormatIndex = arcTypeIndex;
+ else
+ {
+ MethodMode.FormatIndex = codecs->FindFormatForArchiveName(arcPath);
+ // It works incorrectly for update command if archive has some non-default extension!
+ if (MethodMode.FormatIndex < 0)
+ MethodMode.FormatIndex = codecs->FindFormatForArchiveType(kDefaultArchiveType);
+ }
+ if (MethodMode.FormatIndex < 0)
+ return false;
+ const CArcInfoEx &arcInfo = codecs->Formats[MethodMode.FormatIndex];
+ if (!arcInfo.UpdateEnabled)
+ return false;
+ UString typeExt = arcInfo.GetMainExt();
+ UString ext = typeExt;
+ if (SfxMode)
+ ext = kSFXExtension;
+ ArchivePath.BaseExtension = ext;
+ ArchivePath.VolExtension = typeExt;
+ ArchivePath.ParseFromPath(arcPath);
+ for (int i = 0; i < Commands.Size(); i++)
+ {
+ CUpdateArchiveCommand &uc = Commands[i];
+ uc.ArchivePath.BaseExtension = ext;
+ uc.ArchivePath.VolExtension = typeExt;
+ uc.ArchivePath.ParseFromPath(uc.UserArchivePath);
+ }
+ return true;
+}
+
+/*
+struct CUpdateProduceCallbackImp: public IUpdateProduceCallback
+{
+ const CObjectVector<CArcItem> *_arcItems;
+ IUpdateCallbackUI *_callback;
+
+ CUpdateProduceCallbackImp(const CObjectVector<CArcItem> *a,
+ IUpdateCallbackUI *callback): _arcItems(a), _callback(callback) {}
+ virtual HRESULT ShowDeleteFile(int arcIndex);
+};
+
+HRESULT CUpdateProduceCallbackImp::ShowDeleteFile(int arcIndex)
+{
+ return _callback->ShowDeleteFile((*_arcItems)[arcIndex].Name);
+}
+*/
+
+static HRESULT Compress(
+ CCodecs *codecs,
+ const CActionSet &actionSet,
+ IInArchive *archive,
+ const CCompressionMethodMode &compressionMethod,
+ CArchivePath &archivePath,
+ const CObjectVector<CArcItem> &arcItems,
+ bool shareForWrite,
+ bool stdInMode,
+ /* const UString & stdInFileName, */
+ bool stdOutMode,
+ const CDirItems &dirItems,
+ bool sfxMode,
+ const UString &sfxModule,
+ const CRecordVector<UInt64> &volumesSizes,
+ CTempFiles &tempFiles,
+ CUpdateErrorInfo &errorInfo,
+ IUpdateCallbackUI *callback)
+{
+ CMyComPtr<IOutArchive> outArchive;
+ if (archive != NULL)
+ {
+ CMyComPtr<IInArchive> archive2 = archive;
+ HRESULT result = archive2.QueryInterface(IID_IOutArchive, &outArchive);
+ if (result != S_OK)
+ throw kUpdateIsNotSupoorted;
+ }
+ else
+ {
+ RINOK(codecs->CreateOutArchive(compressionMethod.FormatIndex, outArchive));
+
+ #ifdef EXTERNAL_CODECS
+ {
+ CMyComPtr<ISetCompressCodecsInfo> setCompressCodecsInfo;
+ outArchive.QueryInterface(IID_ISetCompressCodecsInfo, (void **)&setCompressCodecsInfo);
+ if (setCompressCodecsInfo)
+ {
+ RINOK(setCompressCodecsInfo->SetCompressCodecsInfo(codecs));
+ }
+ }
+ #endif
+ }
+ if (outArchive == 0)
+ throw kUpdateIsNotSupoorted;
+
+ NFileTimeType::EEnum fileTimeType;
+ UInt32 value;
+ RINOK(outArchive->GetFileTimeType(&value));
+
+ switch(value)
+ {
+ case NFileTimeType::kWindows:
+ case NFileTimeType::kUnix:
+ case NFileTimeType::kDOS:
+ fileTimeType = (NFileTimeType::EEnum)value;
+ break;
+ default:
+ return E_FAIL;
+ }
+
+ CRecordVector<CUpdatePair2> updatePairs2;
+
+ {
+ CRecordVector<CUpdatePair> updatePairs;
+ GetUpdatePairInfoList(dirItems, arcItems, fileTimeType, updatePairs); // must be done only once!!!
+ // CUpdateProduceCallbackImp upCallback(&arcItems, callback);
+ UpdateProduce(updatePairs, actionSet, updatePairs2, NULL /* &upCallback */);
+ }
+
+ UInt32 numFiles = 0;
+ for (int i = 0; i < updatePairs2.Size(); i++)
+ if (updatePairs2[i].NewData)
+ numFiles++;
+
+ RINOK(callback->SetNumFiles(numFiles));
+
+
+ CArchiveUpdateCallback *updateCallbackSpec = new CArchiveUpdateCallback;
+ CMyComPtr<IArchiveUpdateCallback> updateCallback(updateCallbackSpec);
+
+ updateCallbackSpec->ShareForWrite = shareForWrite;
+ updateCallbackSpec->StdInMode = stdInMode;
+ updateCallbackSpec->Callback = callback;
+ updateCallbackSpec->DirItems = &dirItems;
+ updateCallbackSpec->ArcItems = &arcItems;
+ updateCallbackSpec->UpdatePairs = &updatePairs2;
+
+ CMyComPtr<ISequentialOutStream> outStream;
+
+ if (!stdOutMode)
+ {
+ UString resultPath;
+ int pos;
+ if (!NFile::NDirectory::MyGetFullPathName(archivePath.GetFinalPath(), resultPath, pos))
+ throw 1417161;
+ NFile::NDirectory::CreateComplexDirectory(resultPath.Left(pos));
+ }
+
+ COutFileStream *outStreamSpec = NULL;
+ COutMultiVolStream *volStreamSpec = NULL;
+
+ if (volumesSizes.Size() == 0)
+ {
+ if (stdOutMode)
+ outStream = new CStdOutFileStream;
+ else
+ {
+ outStreamSpec = new COutFileStream;
+ outStream = outStreamSpec;
+ bool isOK = false;
+ UString realPath;
+ for (int i = 0; i < (1 << 16); i++)
+ {
+ if (archivePath.Temp)
+ {
+ if (i > 0)
+ {
+ wchar_t s[16];
+ ConvertUInt32ToString(i, s);
+ archivePath.TempPostfix = s;
+ }
+ realPath = archivePath.GetTempPath();
+ }
+ else
+ realPath = archivePath.GetFinalPath();
+ if (outStreamSpec->Create(realPath, false))
+ {
+ tempFiles.Paths.Add(realPath);
+ isOK = true;
+ break;
+ }
+ if (::GetLastError() != ERROR_FILE_EXISTS)
+ break;
+ if (!archivePath.Temp)
+ break;
+ }
+ if (!isOK)
+ {
+ errorInfo.SystemError = ::GetLastError();
+ errorInfo.FileName = realPath;
+ errorInfo.Message = L"7-Zip cannot open file";
+ return E_FAIL;
+ }
+ }
+ }
+ else
+ {
+ if (stdOutMode)
+ return E_FAIL;
+ volStreamSpec = new COutMultiVolStream;
+ outStream = volStreamSpec;
+ volStreamSpec->Sizes = volumesSizes;
+ volStreamSpec->Prefix = archivePath.GetFinalPath() + UString(L".");
+ volStreamSpec->TempFiles = &tempFiles;
+ volStreamSpec->Init();
+
+ /*
+ updateCallbackSpec->VolumesSizes = volumesSizes;
+ updateCallbackSpec->VolName = archivePath.Prefix + archivePath.Name;
+ if (!archivePath.VolExtension.IsEmpty())
+ updateCallbackSpec->VolExt = UString(L'.') + archivePath.VolExtension;
+ */
+ }
+
+ RINOK(SetProperties(outArchive, compressionMethod.Properties));
+
+ if (sfxMode)
+ {
+ CInFileStream *sfxStreamSpec = new CInFileStream;
+ CMyComPtr<IInStream> sfxStream(sfxStreamSpec);
+ if (!sfxStreamSpec->Open(sfxModule))
+ {
+ errorInfo.SystemError = ::GetLastError();
+ errorInfo.Message = L"7-Zip cannot open SFX module";
+ errorInfo.FileName = sfxModule;
+ return E_FAIL;
+ }
+
+ CMyComPtr<ISequentialOutStream> sfxOutStream;
+ COutFileStream *outStreamSpec = NULL;
+ if (volumesSizes.Size() == 0)
+ sfxOutStream = outStream;
+ else
+ {
+ outStreamSpec = new COutFileStream;
+ sfxOutStream = outStreamSpec;
+ UString realPath = archivePath.GetFinalPath();
+ if (!outStreamSpec->Create(realPath, false))
+ {
+ errorInfo.SystemError = ::GetLastError();
+ errorInfo.FileName = realPath;
+ errorInfo.Message = L"7-Zip cannot open file";
+ return E_FAIL;
+ }
+ }
+ RINOK(NCompress::CopyStream(sfxStream, sfxOutStream, NULL));
+ if (outStreamSpec)
+ {
+ RINOK(outStreamSpec->Close());
+ }
+ }
+
+ HRESULT result = outArchive->UpdateItems(outStream, updatePairs2.Size(), updateCallback);
+ callback->Finilize();
+ RINOK(result);
+ if (outStreamSpec)
+ result = outStreamSpec->Close();
+ else if (volStreamSpec)
+ result = volStreamSpec->Close();
+ return result;
+}
+
+HRESULT EnumerateInArchiveItems(const NWildcard::CCensor &censor,
+ const CArc &arc,
+ CObjectVector<CArcItem> &arcItems)
+{
+ arcItems.Clear();
+ UInt32 numItems;
+ IInArchive *archive = arc.Archive;
+ RINOK(archive->GetNumberOfItems(&numItems));
+ arcItems.Reserve(numItems);
+ for (UInt32 i = 0; i < numItems; i++)
+ {
+ CArcItem ai;
+
+ RINOK(arc.GetItemPath(i, ai.Name));
+ RINOK(IsArchiveItemFolder(archive, i, ai.IsDir));
+ ai.Censored = censor.CheckPath(ai.Name, !ai.IsDir);
+ RINOK(arc.GetItemMTime(i, ai.MTime, ai.MTimeDefined));
+
+ {
+ CPropVariant prop;
+ RINOK(archive->GetProperty(i, kpidSize, &prop));
+ ai.SizeDefined = (prop.vt != VT_EMPTY);
+ if (ai.SizeDefined)
+ ai.Size = ConvertPropVariantToUInt64(prop);
+ }
+
+ {
+ CPropVariant prop;
+ RINOK(archive->GetProperty(i, kpidTimeType, &prop));
+ if (prop.vt == VT_UI4)
+ {
+ ai.TimeType = (int)(NFileTimeType::EEnum)prop.ulVal;
+ switch(ai.TimeType)
+ {
+ case NFileTimeType::kWindows:
+ case NFileTimeType::kUnix:
+ case NFileTimeType::kDOS:
+ break;
+ default:
+ return E_FAIL;
+ }
+ }
+ }
+
+ ai.IndexInServer = i;
+ arcItems.Add(ai);
+ }
+ return S_OK;
+}
+
+
+static HRESULT UpdateWithItemLists(
+ CCodecs *codecs,
+ CUpdateOptions &options,
+ IInArchive *archive,
+ const CObjectVector<CArcItem> &arcItems,
+ CDirItems &dirItems,
+ CTempFiles &tempFiles,
+ CUpdateErrorInfo &errorInfo,
+ IUpdateCallbackUI2 *callback)
+{
+ for(int i = 0; i < options.Commands.Size(); i++)
+ {
+ CUpdateArchiveCommand &command = options.Commands[i];
+ if (options.StdOutMode)
+ {
+ RINOK(callback->StartArchive(L"stdout", archive != 0));
+ }
+ else
+ {
+ RINOK(callback->StartArchive(command.ArchivePath.GetFinalPath(),
+ i == 0 && options.UpdateArchiveItself && archive != 0));
+ }
+
+ RINOK(Compress(
+ codecs,
+ command.ActionSet, archive,
+ options.MethodMode,
+ command.ArchivePath,
+ arcItems,
+ options.OpenShareForWrite,
+ options.StdInMode,
+ /* options.StdInFileName, */
+ options.StdOutMode,
+ dirItems,
+ options.SfxMode, options.SfxModule,
+ options.VolumesSizes,
+ tempFiles,
+ errorInfo, callback));
+
+ RINOK(callback->FinishArchive());
+ }
+ return S_OK;
+}
+
+#if defined(_WIN32) && !defined(UNDER_CE)
+class CCurrentDirRestorer
+{
+ UString _path;
+public:
+ CCurrentDirRestorer() { NFile::NDirectory::MyGetCurrentDirectory(_path); }
+ ~CCurrentDirRestorer() { RestoreDirectory();}
+ bool RestoreDirectory() { return BOOLToBool(NFile::NDirectory::MySetCurrentDirectory(_path)); }
+};
+#endif
+
+struct CEnumDirItemUpdateCallback: public IEnumDirItemCallback
+{
+ IUpdateCallbackUI2 *Callback;
+ HRESULT ScanProgress(UInt64 numFolders, UInt64 numFiles, const wchar_t *path)
+ {
+ return Callback->ScanProgress(numFolders, numFiles, path);
+ }
+};
+
+#ifdef _WIN32
+typedef ULONG (FAR PASCAL MY_MAPISENDDOCUMENTS)(
+ ULONG_PTR ulUIParam,
+ LPSTR lpszDelimChar,
+ LPSTR lpszFilePaths,
+ LPSTR lpszFileNames,
+ ULONG ulReserved
+);
+typedef MY_MAPISENDDOCUMENTS FAR *MY_LPMAPISENDDOCUMENTS;
+#endif
+
+HRESULT UpdateArchive(
+ CCodecs *codecs,
+ const NWildcard::CCensor &censor,
+ CUpdateOptions &options,
+ CUpdateErrorInfo &errorInfo,
+ IOpenCallbackUI *openCallback,
+ IUpdateCallbackUI2 *callback)
+{
+ if (options.StdOutMode && options.EMailMode)
+ return E_FAIL;
+
+ if (options.VolumesSizes.Size() > 0 && (options.EMailMode || options.SfxMode))
+ return E_NOTIMPL;
+
+ if (options.SfxMode)
+ {
+ CProperty property;
+ property.Name = L"rsfx";
+ property.Value = L"on";
+ options.MethodMode.Properties.Add(property);
+ if (options.SfxModule.IsEmpty())
+ {
+ errorInfo.Message = L"SFX file is not specified";
+ return E_FAIL;
+ }
+ UString name = options.SfxModule;
+ #ifdef UNDER_CE
+ if (!NFind::DoesFileExist(name))
+ #else
+ if (!NDirectory::MySearchPath(NULL, name, NULL, options.SfxModule))
+ #endif
+ {
+ errorInfo.SystemError = ::GetLastError();
+ errorInfo.Message = L"7-Zip cannot find specified SFX module";
+ errorInfo.FileName = name;
+ return E_FAIL;
+ }
+ }
+
+
+ CArchiveLink arcLink;
+ const UString arcPath = options.ArchivePath.GetFinalPath();
+
+ if (!options.ArchivePath.OriginalPath.IsEmpty())
+ {
+ NFind::CFileInfoW fi;
+ if (fi.Find(arcPath))
+ {
+ 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;
+ }
+ }
+ else
+ {
+ /*
+ if (archiveType.IsEmpty())
+ throw "type of archive is not specified";
+ */
+ }
+
+ CDirItems dirItems;
+ if (options.StdInMode)
+ {
+ CDirItem di;
+ di.Name = options.StdInFileName;
+ di.Size = (UInt64)(Int64)-1;
+ di.Attrib = 0;
+ NTime::GetCurUtcFileTime(di.MTime);
+ di.CTime = di.ATime = di.MTime;
+ dirItems.Items.Add(di);
+ }
+ else
+ {
+ bool needScanning = false;
+ for(int i = 0; i < options.Commands.Size(); i++)
+ if (options.Commands[i].ActionSet.NeedScanning())
+ needScanning = true;
+ if (needScanning)
+ {
+ CEnumDirItemUpdateCallback enumCallback;
+ enumCallback.Callback = callback;
+ RINOK(callback->StartScanning());
+ UStringVector errorPaths;
+ CRecordVector<DWORD> errorCodes;
+ HRESULT res = EnumerateItems(censor, dirItems, &enumCallback, errorPaths, errorCodes);
+ for (int i = 0; i < errorPaths.Size(); i++)
+ {
+ RINOK(callback->CanNotFindError(errorPaths[i], errorCodes[i]));
+ }
+ if (res != S_OK)
+ {
+ if (res != E_ABORT)
+ errorInfo.Message = L"Scanning error";
+ return res;
+ }
+ RINOK(callback->FinishScanning());
+ }
+ }
+
+ UString tempDirPrefix;
+ bool usesTempDir = false;
+
+ #ifdef _WIN32
+ NDirectory::CTempDirectoryW tempDirectory;
+ if (options.EMailMode && options.EMailRemoveAfter)
+ {
+ tempDirectory.Create(kTempFolderPrefix);
+ tempDirPrefix = tempDirectory.GetPath();
+ NormalizeDirPathPrefix(tempDirPrefix);
+ usesTempDir = true;
+ }
+ #endif
+
+ CTempFiles tempFiles;
+
+ bool createTempFile = false;
+
+ bool thereIsInArchive = arcLink.IsOpen;
+
+ if (!options.StdOutMode && options.UpdateArchiveItself)
+ {
+ CArchivePath &ap = options.Commands[0].ArchivePath;
+ ap = options.ArchivePath;
+ // if ((archive != 0 && !usesTempDir) || !options.WorkingDir.IsEmpty())
+ if ((thereIsInArchive || !options.WorkingDir.IsEmpty()) && !usesTempDir && options.VolumesSizes.Size() == 0)
+ {
+ createTempFile = true;
+ ap.Temp = true;
+ if (!options.WorkingDir.IsEmpty())
+ {
+ ap.TempPrefix = options.WorkingDir;
+ NormalizeDirPathPrefix(ap.TempPrefix);
+ }
+ }
+ }
+
+ for(int i = 0; i < options.Commands.Size(); i++)
+ {
+ CArchivePath &ap = options.Commands[i].ArchivePath;
+ if (usesTempDir)
+ {
+ // Check it
+ ap.Prefix = tempDirPrefix;
+ // ap.Temp = true;
+ // ap.TempPrefix = tempDirPrefix;
+ }
+ if (!options.StdOutMode &&
+ (i > 0 || !createTempFile))
+ {
+ const UString &path = ap.GetFinalPath();
+ if (NFind::DoesFileOrDirExist(path))
+ {
+ errorInfo.SystemError = 0;
+ errorInfo.Message = L"The file already exists";
+ errorInfo.FileName = path;
+ return E_FAIL;
+ }
+ }
+ }
+
+ CObjectVector<CArcItem> arcItems;
+ if (thereIsInArchive)
+ {
+ RINOK(EnumerateInArchiveItems(censor, arcLink.Arcs.Back(), arcItems));
+ }
+
+ RINOK(UpdateWithItemLists(codecs, options,
+ thereIsInArchive ? arcLink.GetArchive() : 0,
+ arcItems, dirItems,
+ tempFiles, errorInfo, callback));
+
+ if (thereIsInArchive)
+ {
+ RINOK(arcLink.Close());
+ arcLink.Release();
+ }
+
+ tempFiles.Paths.Clear();
+ if (createTempFile)
+ {
+ try
+ {
+ CArchivePath &ap = options.Commands[0].ArchivePath;
+ const UString &tempPath = ap.GetTempPath();
+ if (thereIsInArchive)
+ if (!NDirectory::DeleteFileAlways(arcPath))
+ {
+ errorInfo.SystemError = ::GetLastError();
+ errorInfo.Message = L"7-Zip cannot delete the file";
+ errorInfo.FileName = arcPath;
+ return E_FAIL;
+ }
+ if (!NDirectory::MyMoveFile(tempPath, arcPath))
+ {
+ errorInfo.SystemError = ::GetLastError();
+ errorInfo.Message = L"7-Zip cannot move the file";
+ errorInfo.FileName = tempPath;
+ errorInfo.FileName2 = arcPath;
+ return E_FAIL;
+ }
+ }
+ catch(...)
+ {
+ throw;
+ }
+ }
+
+ #if defined(_WIN32) && !defined(UNDER_CE)
+ if (options.EMailMode)
+ {
+ NDLL::CLibrary mapiLib;
+ if (!mapiLib.Load(TEXT("Mapi32.dll")))
+ {
+ errorInfo.SystemError = ::GetLastError();
+ errorInfo.Message = L"7-Zip cannot load Mapi32.dll";
+ return E_FAIL;
+ }
+ MY_LPMAPISENDDOCUMENTS fnSend = (MY_LPMAPISENDDOCUMENTS)mapiLib.GetProc("MAPISendDocuments");
+ if (fnSend == 0)
+ {
+ errorInfo.SystemError = ::GetLastError();
+ errorInfo.Message = L"7-Zip cannot find MAPISendDocuments function";
+ return E_FAIL;
+ }
+ UStringVector fullPaths;
+ int i;
+ for(i = 0; i < options.Commands.Size(); i++)
+ {
+ CArchivePath &ap = options.Commands[i].ArchivePath;
+ UString arcPath;
+ if (!NFile::NDirectory::MyGetFullPathName(ap.GetFinalPath(), arcPath))
+ {
+ errorInfo.SystemError = ::GetLastError();
+ errorInfo.Message = L"GetFullPathName error";
+ return E_FAIL;
+ }
+ fullPaths.Add(arcPath);
+ }
+ CCurrentDirRestorer curDirRestorer;
+ for(i = 0; i < fullPaths.Size(); i++)
+ {
+ UString arcPath = fullPaths[i];
+ UString fileName = ExtractFileNameFromPath(arcPath);
+ AString path = GetAnsiString(arcPath);
+ AString name = GetAnsiString(fileName);
+ // Warning!!! MAPISendDocuments function changes Current directory
+ fnSend(0, ";", (LPSTR)(LPCSTR)path, (LPSTR)(LPCSTR)name, 0);
+ }
+ }
+ #endif
+ return S_OK;
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/Update.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/Update.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/Update.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/Update.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,175 @@
+// Update.h
+
+#ifndef __COMMON_UPDATE_H
+#define __COMMON_UPDATE_H
+
+#include "Common/Wildcard.h"
+
+#include "ArchiveOpenCallback.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
+ UString VolExtension; // archive type extension for volumes
+
+ bool Temp;
+ UString TempPrefix; // path(folder) for temp location
+ UString TempPostfix;
+
+ CArchivePath(): Temp(false) {};
+
+ void ParseFromPath(const UString &path)
+ {
+ OriginalPath = path;
+
+ SplitPathToParts(path, Prefix, Name);
+ int dotPos = Name.ReverseFind(L'.');
+ if (dotPos < 0)
+ return;
+ if (dotPos == Name.Length() - 1)
+ {
+ Name = Name.Left(dotPos);
+ BaseExtension.Empty();
+ return;
+ }
+ if (BaseExtension.CompareNoCase(Name.Mid(dotPos + 1)) == 0)
+ {
+ BaseExtension = Name.Mid(dotPos + 1);
+ Name = Name.Left(dotPos);
+ }
+ else
+ BaseExtension.Empty();
+ }
+
+ UString GetPathWithoutExt() const
+ {
+ return Prefix + Name;
+ }
+
+ UString GetFinalPath() const
+ {
+ UString path = GetPathWithoutExt();
+ if (!BaseExtension.IsEmpty())
+ path += UString(L'.') + BaseExtension;
+ return path;
+ }
+
+
+ UString GetTempPath() const
+ {
+ UString path = TempPrefix + Name;
+ if (!BaseExtension.IsEmpty())
+ path += UString(L'.') + BaseExtension;
+ path += L".tmp";
+ path += TempPostfix;
+ return path;
+ }
+};
+
+struct CUpdateArchiveCommand
+{
+ UString UserArchivePath;
+ CArchivePath ArchivePath;
+ NUpdateArchive::CActionSet ActionSet;
+};
+
+struct CCompressionMethodMode
+{
+ int FormatIndex;
+ CObjectVector<CProperty> Properties;
+ CCompressionMethodMode(): FormatIndex(-1) {}
+};
+
+struct CUpdateOptions
+{
+ CCompressionMethodMode MethodMode;
+
+ CObjectVector<CUpdateArchiveCommand> Commands;
+ bool UpdateArchiveItself;
+ CArchivePath ArchivePath;
+
+ bool SfxMode;
+ UString SfxModule;
+
+ bool OpenShareForWrite;
+
+ bool StdInMode;
+ UString StdInFileName;
+ bool StdOutMode;
+
+ bool EMailMode;
+ bool EMailRemoveAfter;
+ UString EMailAddress;
+
+ UString WorkingDir;
+
+ bool Init(const CCodecs *codecs, const CIntVector &formatIndices, const UString &arcPath);
+
+ CUpdateOptions():
+ UpdateArchiveItself(true),
+ SfxMode(false),
+ StdInMode(false),
+ StdOutMode(false),
+ EMailMode(false),
+ EMailRemoveAfter(false),
+ OpenShareForWrite(false)
+ {};
+
+ void SetAddActionCommand()
+ {
+ Commands.Clear();
+ CUpdateArchiveCommand c;
+ c.ActionSet = NUpdateArchive::kAddActionSet;
+ Commands.Add(c);
+ }
+
+ CRecordVector<UInt64> VolumesSizes;
+};
+
+struct CErrorInfo
+{
+ DWORD SystemError;
+ UString FileName;
+ UString FileName2;
+ UString Message;
+ // UStringVector ErrorPaths;
+ // CRecordVector<DWORD> ErrorCodes;
+ CErrorInfo(): SystemError(0) {};
+};
+
+struct CUpdateErrorInfo: public CErrorInfo
+{
+};
+
+#define INTERFACE_IUpdateCallbackUI2(x) \
+ INTERFACE_IUpdateCallbackUI(x) \
+ virtual HRESULT OpenResult(const wchar_t *name, HRESULT result) x; \
+ virtual HRESULT StartScanning() x; \
+ virtual HRESULT ScanProgress(UInt64 numFolders, UInt64 numFiles, const wchar_t *path) x; \
+ virtual HRESULT CanNotFindError(const wchar_t *name, DWORD systemError) x; \
+ virtual HRESULT FinishScanning() x; \
+ virtual HRESULT StartArchive(const wchar_t *name, bool updating) x; \
+ virtual HRESULT FinishArchive() x; \
+
+struct IUpdateCallbackUI2: public IUpdateCallbackUI
+{
+ INTERFACE_IUpdateCallbackUI2(=0)
+};
+
+HRESULT UpdateArchive(
+ CCodecs *codecs,
+ const NWildcard::CCensor &censor,
+ CUpdateOptions &options,
+ CUpdateErrorInfo &errorInfo,
+ IOpenCallbackUI *openCallback,
+ IUpdateCallbackUI2 *callback);
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/UpdateAction.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/UpdateAction.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/UpdateAction.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/UpdateAction.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,64 @@
+// UpdateAction.cpp
+
+#include "StdAfx.h"
+
+#include "UpdateAction.h"
+
+namespace NUpdateArchive {
+
+const CActionSet kAddActionSet =
+{{
+ NPairAction::kCopy,
+ NPairAction::kCopy,
+ NPairAction::kCompress,
+ NPairAction::kCompress,
+ NPairAction::kCompress,
+ NPairAction::kCompress,
+ NPairAction::kCompress
+}};
+
+const CActionSet kUpdateActionSet =
+{{
+ NPairAction::kCopy,
+ NPairAction::kCopy,
+ NPairAction::kCompress,
+ NPairAction::kCopy,
+ NPairAction::kCompress,
+ NPairAction::kCopy,
+ NPairAction::kCompress
+}};
+
+const CActionSet kFreshActionSet =
+{{
+ NPairAction::kCopy,
+ NPairAction::kCopy,
+ NPairAction::kIgnore,
+ NPairAction::kCopy,
+ NPairAction::kCompress,
+ NPairAction::kCopy,
+ NPairAction::kCompress
+}};
+
+const CActionSet kSynchronizeActionSet =
+{{
+ NPairAction::kCopy,
+ NPairAction::kIgnore,
+ NPairAction::kCompress,
+ NPairAction::kCopy,
+ NPairAction::kCompress,
+ NPairAction::kCopy,
+ NPairAction::kCompress,
+}};
+
+const CActionSet kDeleteActionSet =
+{{
+ NPairAction::kCopy,
+ NPairAction::kIgnore,
+ NPairAction::kIgnore,
+ NPairAction::kIgnore,
+ NPairAction::kIgnore,
+ NPairAction::kIgnore,
+ NPairAction::kIgnore
+}};
+
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/UpdateAction.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/UpdateAction.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/UpdateAction.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/UpdateAction.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,57 @@
+// UpdateAction.h
+
+#ifndef __UPDATE_ACTION_H
+#define __UPDATE_ACTION_H
+
+namespace NUpdateArchive {
+
+ namespace NPairState
+ {
+ const int kNumValues = 7;
+ enum EEnum
+ {
+ kNotMasked = 0,
+ kOnlyInArchive,
+ kOnlyOnDisk,
+ kNewInArchive,
+ kOldInArchive,
+ kSameFiles,
+ kUnknowNewerFiles
+ };
+ }
+
+ namespace NPairAction
+ {
+ enum EEnum
+ {
+ kIgnore = 0,
+ kCopy,
+ kCompress,
+ kCompressAsAnti
+ };
+ }
+
+ struct CActionSet
+ {
+ NPairAction::EEnum StateActions[NPairState::kNumValues];
+ bool NeedScanning() const
+ {
+ int i;
+ for (i = 0; i < NPairState::kNumValues; i++)
+ if (StateActions[i] == NPairAction::kCompress)
+ return true;
+ for (i = 1; i < NPairState::kNumValues; i++)
+ if (StateActions[i] != NPairAction::kIgnore)
+ return true;
+ return false;
+ }
+ };
+
+ extern const CActionSet kAddActionSet;
+ extern const CActionSet kUpdateActionSet;
+ extern const CActionSet kFreshActionSet;
+ extern const CActionSet kSynchronizeActionSet;
+ extern const CActionSet kDeleteActionSet;
+}
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/UpdateCallback.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/UpdateCallback.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/UpdateCallback.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/UpdateCallback.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,249 @@
+// UpdateCallback.cpp
+
+#include "StdAfx.h"
+
+#include "Common/ComTry.h"
+#include "Common/Defs.h"
+#include "Common/IntToString.h"
+#include "Common/StringConvert.h"
+
+#include "Windows/PropVariant.h"
+
+#include "../../Common/FileStreams.h"
+
+#include "UpdateCallback.h"
+
+using namespace NWindows;
+
+CArchiveUpdateCallback::CArchiveUpdateCallback():
+ Callback(0),
+ ShareForWrite(false),
+ StdInMode(false),
+ DirItems(0),
+ ArcItems(0),
+ UpdatePairs(0),
+ NewNames(0)
+ {}
+
+
+STDMETHODIMP CArchiveUpdateCallback::SetTotal(UInt64 size)
+{
+ COM_TRY_BEGIN
+ return Callback->SetTotal(size);
+ COM_TRY_END
+}
+
+STDMETHODIMP CArchiveUpdateCallback::SetCompleted(const UInt64 *completeValue)
+{
+ COM_TRY_BEGIN
+ return Callback->SetCompleted(completeValue);
+ COM_TRY_END
+}
+
+STDMETHODIMP CArchiveUpdateCallback::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize)
+{
+ COM_TRY_BEGIN
+ return Callback->SetRatioInfo(inSize, outSize);
+ COM_TRY_END
+}
+
+
+/*
+STATPROPSTG kProperties[] =
+{
+ { NULL, kpidPath, VT_BSTR},
+ { NULL, kpidIsDir, VT_BOOL},
+ { NULL, kpidSize, VT_UI8},
+ { NULL, kpidCTime, VT_FILETIME},
+ { NULL, kpidATime, VT_FILETIME},
+ { NULL, kpidMTime, VT_FILETIME},
+ { NULL, kpidAttrib, VT_UI4},
+ { NULL, kpidIsAnti, VT_BOOL}
+};
+
+STDMETHODIMP CArchiveUpdateCallback::EnumProperties(IEnumSTATPROPSTG **)
+{
+ return CStatPropEnumerator::CreateEnumerator(kProperties, sizeof(kProperties) / sizeof(kProperties[0]), enumerator);
+}
+*/
+
+STDMETHODIMP CArchiveUpdateCallback::GetUpdateItemInfo(UInt32 index,
+ Int32 *newData, Int32 *newProps, UInt32 *indexInArchive)
+{
+ COM_TRY_BEGIN
+ RINOK(Callback->CheckBreak());
+ const CUpdatePair2 &up = (*UpdatePairs)[index];
+ if (newData != NULL) *newData = BoolToInt(up.NewData);
+ if (newProps != NULL) *newProps = BoolToInt(up.NewProps);
+ if (indexInArchive != NULL)
+ {
+ *indexInArchive = (UInt32)-1;
+ if (up.ExistInArchive())
+ *indexInArchive = (ArcItems == 0) ? up.ArcIndex : (*ArcItems)[up.ArcIndex].IndexInServer;
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CArchiveUpdateCallback::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ const CUpdatePair2 &up = (*UpdatePairs)[index];
+ NWindows::NCOM::CPropVariant prop;
+
+ if (propID == kpidIsAnti)
+ {
+ prop = up.IsAnti;
+ prop.Detach(value);
+ return S_OK;
+ }
+
+ if (up.IsAnti)
+ {
+ switch(propID)
+ {
+ case kpidIsDir:
+ case kpidPath:
+ break;
+ case kpidSize:
+ prop = (UInt64)0;
+ prop.Detach(value);
+ return S_OK;
+ default:
+ prop.Detach(value);
+ return S_OK;
+ }
+ }
+
+ if (up.ExistOnDisk())
+ {
+ const CDirItem &di = DirItems->Items[up.DirIndex];
+ switch(propID)
+ {
+ case kpidPath: prop = DirItems->GetLogPath(up.DirIndex); break;
+ case kpidIsDir: prop = di.IsDir(); break;
+ case kpidSize: prop = di.Size; break;
+ case kpidAttrib: prop = di.Attrib; break;
+ case kpidCTime: prop = di.CTime; break;
+ case kpidATime: prop = di.ATime; break;
+ case kpidMTime: prop = di.MTime; break;
+ }
+ }
+ else
+ {
+ if (propID == kpidPath)
+ {
+ if (up.NewNameIndex >= 0)
+ {
+ prop = (*NewNames)[up.NewNameIndex];
+ prop.Detach(value);
+ return S_OK;
+ }
+ }
+ if (up.ExistInArchive() && Archive)
+ {
+ UInt32 indexInArchive;
+ if (ArcItems == 0)
+ indexInArchive = up.ArcIndex;
+ else
+ indexInArchive = (*ArcItems)[up.ArcIndex].IndexInServer;
+ return Archive->GetProperty(indexInArchive, propID, value);
+ }
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CArchiveUpdateCallback::GetStream(UInt32 index, ISequentialInStream **inStream)
+{
+ COM_TRY_BEGIN
+ const CUpdatePair2 &up = (*UpdatePairs)[index];
+ if (!up.NewData)
+ return E_FAIL;
+
+ RINOK(Callback->CheckBreak());
+ RINOK(Callback->Finilize());
+
+ if (up.IsAnti)
+ {
+ return Callback->GetStream((*ArcItems)[up.ArcIndex].Name, true);
+ }
+ const CDirItem &di = DirItems->Items[up.DirIndex];
+ RINOK(Callback->GetStream(DirItems->GetLogPath(up.DirIndex), false));
+
+ if (di.IsDir())
+ return S_OK;
+
+ if (StdInMode)
+ {
+ CStdInFileStream *inStreamSpec = new CStdInFileStream;
+ CMyComPtr<ISequentialInStream> inStreamLoc(inStreamSpec);
+ *inStream = inStreamLoc.Detach();
+ }
+ else
+ {
+ CInFileStream *inStreamSpec = new CInFileStream;
+ CMyComPtr<ISequentialInStream> inStreamLoc(inStreamSpec);
+ const UString path = DirItems->GetPhyPath(up.DirIndex);
+ if (!inStreamSpec->OpenShared(path, ShareForWrite))
+ {
+ return Callback->OpenFileError(path, ::GetLastError());
+ }
+ *inStream = inStreamLoc.Detach();
+ }
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CArchiveUpdateCallback::SetOperationResult(Int32 operationResult)
+{
+ COM_TRY_BEGIN
+ return Callback->SetOperationResult(operationResult);
+ COM_TRY_END
+}
+
+STDMETHODIMP CArchiveUpdateCallback::GetVolumeSize(UInt32 index, UInt64 *size)
+{
+ if (VolumesSizes.Size() == 0)
+ return S_FALSE;
+ if (index >= (UInt32)VolumesSizes.Size())
+ index = VolumesSizes.Size() - 1;
+ *size = VolumesSizes[index];
+ return S_OK;
+}
+
+STDMETHODIMP CArchiveUpdateCallback::GetVolumeStream(UInt32 index, ISequentialOutStream **volumeStream)
+{
+ COM_TRY_BEGIN
+ wchar_t temp[16];
+ ConvertUInt32ToString(index + 1, temp);
+ UString res = temp;
+ while (res.Length() < 2)
+ res = UString(L'0') + res;
+ UString fileName = VolName;
+ fileName += L'.';
+ fileName += res;
+ fileName += VolExt;
+ COutFileStream *streamSpec = new COutFileStream;
+ CMyComPtr<ISequentialOutStream> streamLoc(streamSpec);
+ if (!streamSpec->Create(fileName, false))
+ return ::GetLastError();
+ *volumeStream = streamLoc.Detach();
+ return S_OK;
+ COM_TRY_END
+}
+
+STDMETHODIMP CArchiveUpdateCallback::CryptoGetTextPassword2(Int32 *passwordIsDefined, BSTR *password)
+{
+ COM_TRY_BEGIN
+ return Callback->CryptoGetTextPassword2(passwordIsDefined, password);
+ COM_TRY_END
+}
+
+STDMETHODIMP CArchiveUpdateCallback::CryptoGetTextPassword(BSTR *password)
+{
+ COM_TRY_BEGIN
+ return Callback->CryptoGetTextPassword(password);
+ COM_TRY_END
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/UpdateCallback.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/UpdateCallback.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/UpdateCallback.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/UpdateCallback.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,74 @@
+// UpdateCallback.h
+
+#ifndef __UPDATECALLBACK_H
+#define __UPDATECALLBACK_H
+
+#include "Common/MyCom.h"
+#include "Common/MyString.h"
+
+#include "../../IPassword.h"
+#include "../../ICoder.h"
+
+#include "../Common/UpdatePair.h"
+#include "../Common/UpdateProduce.h"
+
+#define INTERFACE_IUpdateCallbackUI(x) \
+ virtual HRESULT SetTotal(UInt64 size) x; \
+ virtual HRESULT SetCompleted(const UInt64 *completeValue) x; \
+ virtual HRESULT SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize) x; \
+ virtual HRESULT CheckBreak() x; \
+ virtual HRESULT Finilize() x; \
+ virtual HRESULT SetNumFiles(UInt64 numFiles) x; \
+ virtual HRESULT GetStream(const wchar_t *name, bool isAnti) x; \
+ virtual HRESULT OpenFileError(const wchar_t *name, DWORD systemError) x; \
+ virtual HRESULT SetOperationResult(Int32 operationResult) x; \
+ virtual HRESULT CryptoGetTextPassword2(Int32 *passwordIsDefined, BSTR *password) x; \
+ virtual HRESULT CryptoGetTextPassword(BSTR *password) x; \
+ /* virtual HRESULT ShowDeleteFile(const wchar_t *name) x; */ \
+ /* virtual HRESULT CloseProgress() { return S_OK; }; */
+
+struct IUpdateCallbackUI
+{
+ INTERFACE_IUpdateCallbackUI(=0)
+};
+
+class CArchiveUpdateCallback:
+ public IArchiveUpdateCallback2,
+ public ICryptoGetTextPassword2,
+ public ICryptoGetTextPassword,
+ public ICompressProgressInfo,
+ public CMyUnknownImp
+{
+public:
+ MY_UNKNOWN_IMP4(
+ IArchiveUpdateCallback2,
+ ICryptoGetTextPassword2,
+ ICryptoGetTextPassword,
+ ICompressProgressInfo)
+
+ STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
+
+ INTERFACE_IArchiveUpdateCallback2(;)
+
+ STDMETHOD(CryptoGetTextPassword2)(Int32 *passwordIsDefined, BSTR *password);
+ STDMETHOD(CryptoGetTextPassword)(BSTR *password);
+
+public:
+ CRecordVector<UInt64> VolumesSizes;
+ UString VolName;
+ UString VolExt;
+
+ IUpdateCallbackUI *Callback;
+
+ bool ShareForWrite;
+ bool StdInMode;
+ const CDirItems *DirItems;
+ const CObjectVector<CArcItem> *ArcItems;
+ const CRecordVector<CUpdatePair2> *UpdatePairs;
+ const UStringVector *NewNames;
+ CMyComPtr<IInArchive> Archive;
+
+ CArchiveUpdateCallback();
+};
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/UpdatePair.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/UpdatePair.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/UpdatePair.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/UpdatePair.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,158 @@
+// UpdatePair.cpp
+
+#include "StdAfx.h"
+
+#include <time.h>
+
+#include "Common/Defs.h"
+#include "Common/Wildcard.h"
+
+#include "Windows/Time.h"
+
+#include "SortUtils.h"
+#include "UpdatePair.h"
+
+using namespace NWindows;
+using namespace NTime;
+
+static int MyCompareTime(NFileTimeType::EEnum fileTimeType, const FILETIME &time1, const FILETIME &time2)
+{
+ switch(fileTimeType)
+ {
+ case NFileTimeType::kWindows:
+ return ::CompareFileTime(&time1, &time2);
+ case NFileTimeType::kUnix:
+ {
+ UInt32 unixTime1, unixTime2;
+ FileTimeToUnixTime(time1, unixTime1);
+ FileTimeToUnixTime(time2, unixTime2);
+ return MyCompare(unixTime1, unixTime2);
+ }
+ case NFileTimeType::kDOS:
+ {
+ UInt32 dosTime1, dosTime2;
+ FileTimeToDosTime(time1, dosTime1);
+ FileTimeToDosTime(time2, dosTime2);
+ return MyCompare(dosTime1, dosTime2);
+ }
+ }
+ throw 4191618;
+}
+
+static const wchar_t *kDuplicateFileNameMessage = L"Duplicate filename:";
+static const wchar_t *kNotCensoredCollisionMessaged = L"Internal file name collision (file on disk, file in archive):";
+
+static void ThrowError(const UString &message, const UString &s1, const UString &s2)
+{
+ UString m = message;
+ m += L'\n';
+ m += s1;
+ m += L'\n';
+ m += s2;
+ throw m;
+}
+
+static void TestDuplicateString(const UStringVector &strings, const CIntVector &indices)
+{
+ for(int i = 0; i + 1 < indices.Size(); i++)
+ if (CompareFileNames(strings[indices[i]], strings[indices[i + 1]]) == 0)
+ ThrowError(kDuplicateFileNameMessage, strings[indices[i]], strings[indices[i + 1]]);
+}
+
+void GetUpdatePairInfoList(
+ const CDirItems &dirItems,
+ const CObjectVector<CArcItem> &arcItems,
+ NFileTimeType::EEnum fileTimeType,
+ CRecordVector<CUpdatePair> &updatePairs)
+{
+ CIntVector dirIndices, arcIndices;
+
+ int numDirItems = dirItems.Items.Size();
+ int numArcItems = arcItems.Size();
+
+
+ {
+ UStringVector arcNames;
+ arcNames.Reserve(numArcItems);
+ for (int i = 0; i < numArcItems; i++)
+ arcNames.Add(arcItems[i].Name);
+ SortFileNames(arcNames, arcIndices);
+ TestDuplicateString(arcNames, arcIndices);
+ }
+
+ UStringVector dirNames;
+ {
+ dirNames.Reserve(numDirItems);
+ for (int i = 0; i < numDirItems; i++)
+ dirNames.Add(dirItems.GetLogPath(i));
+ SortFileNames(dirNames, dirIndices);
+ TestDuplicateString(dirNames, dirIndices);
+ }
+
+ int dirIndex = 0, arcIndex = 0;
+ while (dirIndex < numDirItems && arcIndex < numArcItems)
+ {
+ CUpdatePair pair;
+ int dirIndex2 = dirIndices[dirIndex];
+ int arcIndex2 = arcIndices[arcIndex];
+ const CDirItem &di = dirItems.Items[dirIndex2];
+ const CArcItem &ai = arcItems[arcIndex2];
+ int compareResult = CompareFileNames(dirNames[dirIndex2], ai.Name);
+ if (compareResult < 0)
+ {
+ pair.State = NUpdateArchive::NPairState::kOnlyOnDisk;
+ pair.DirIndex = dirIndex2;
+ dirIndex++;
+ }
+ else if (compareResult > 0)
+ {
+ pair.State = ai.Censored ?
+ NUpdateArchive::NPairState::kOnlyInArchive:
+ NUpdateArchive::NPairState::kNotMasked;
+ pair.ArcIndex = arcIndex2;
+ arcIndex++;
+ }
+ else
+ {
+ if (!ai.Censored)
+ ThrowError(kNotCensoredCollisionMessaged, dirNames[dirIndex2], ai.Name);
+ pair.DirIndex = dirIndex2;
+ pair.ArcIndex = arcIndex2;
+ switch (ai.MTimeDefined ? MyCompareTime(
+ ai.TimeType != - 1 ? (NFileTimeType::EEnum)ai.TimeType : fileTimeType,
+ di.MTime, ai.MTime): 0)
+ {
+ case -1: pair.State = NUpdateArchive::NPairState::kNewInArchive; break;
+ case 1: pair.State = NUpdateArchive::NPairState::kOldInArchive; break;
+ default:
+ pair.State = (ai.SizeDefined && di.Size == ai.Size) ?
+ NUpdateArchive::NPairState::kSameFiles :
+ NUpdateArchive::NPairState::kUnknowNewerFiles;
+ }
+ dirIndex++;
+ arcIndex++;
+ }
+ updatePairs.Add(pair);
+ }
+
+ for (; dirIndex < numDirItems; dirIndex++)
+ {
+ CUpdatePair pair;
+ pair.State = NUpdateArchive::NPairState::kOnlyOnDisk;
+ pair.DirIndex = dirIndices[dirIndex];
+ updatePairs.Add(pair);
+ }
+
+ for (; arcIndex < numArcItems; arcIndex++)
+ {
+ CUpdatePair pair;
+ int arcIndex2 = arcIndices[arcIndex];
+ pair.State = arcItems[arcIndex2].Censored ?
+ NUpdateArchive::NPairState::kOnlyInArchive:
+ NUpdateArchive::NPairState::kNotMasked;
+ pair.ArcIndex = arcIndex2;
+ updatePairs.Add(pair);
+ }
+
+ updatePairs.ReserveDown();
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/UpdatePair.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/UpdatePair.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/UpdatePair.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/UpdatePair.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,25 @@
+// UpdatePair.h
+
+#ifndef __UPDATE_PAIR_H
+#define __UPDATE_PAIR_H
+
+#include "DirItem.h"
+#include "UpdateAction.h"
+
+#include "../../Archive/IArchive.h"
+
+struct CUpdatePair
+{
+ NUpdateArchive::NPairState::EEnum State;
+ int ArcIndex;
+ int DirIndex;
+ CUpdatePair(): ArcIndex(-1), DirIndex(-1) {}
+};
+
+void GetUpdatePairInfoList(
+ const CDirItems &dirItems,
+ const CObjectVector<CArcItem> &arcItems,
+ NFileTimeType::EEnum fileTimeType,
+ CRecordVector<CUpdatePair> &updatePairs);
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/UpdateProduce.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/UpdateProduce.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/UpdateProduce.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/UpdateProduce.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,58 @@
+// UpdateProduce.cpp
+
+#include "StdAfx.h"
+
+#include "UpdateProduce.h"
+
+using namespace NUpdateArchive;
+
+static const char *kUpdateActionSetCollision = "Internal collision in update action set";
+
+void UpdateProduce(
+ const CRecordVector<CUpdatePair> &updatePairs,
+ const CActionSet &actionSet,
+ CRecordVector<CUpdatePair2> &operationChain,
+ IUpdateProduceCallback *callback)
+{
+ for (int i = 0; i < updatePairs.Size(); i++)
+ {
+ const CUpdatePair &pair = updatePairs[i];
+
+ CUpdatePair2 up2;
+ up2.IsAnti = false;
+ up2.DirIndex = pair.DirIndex;
+ up2.ArcIndex = pair.ArcIndex;
+ up2.NewData = up2.NewProps = true;
+
+ switch(actionSet.StateActions[pair.State])
+ {
+ case NPairAction::kIgnore:
+ /*
+ if (pair.State != NPairState::kOnlyOnDisk)
+ IgnoreArchiveItem(m_ArchiveItems[pair.ArcIndex]);
+ // cout << "deleting";
+ */
+ if (callback)
+ callback->ShowDeleteFile(pair.ArcIndex);
+ continue;
+
+ case NPairAction::kCopy:
+ if (pair.State == NPairState::kOnlyOnDisk)
+ throw kUpdateActionSetCollision;
+ up2.NewData = up2.NewProps = false;
+ break;
+
+ case NPairAction::kCompress:
+ if (pair.State == NPairState::kOnlyInArchive ||
+ pair.State == NPairState::kNotMasked)
+ throw kUpdateActionSetCollision;
+ break;
+
+ case NPairAction::kCompressAsAnti:
+ up2.IsAnti = true;
+ break;
+ }
+ operationChain.Add(up2);
+ }
+ operationChain.ReserveDown();
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/UpdateProduce.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/UpdateProduce.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/UpdateProduce.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/UpdateProduce.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,35 @@
+// UpdateProduce.h
+
+#ifndef __UPDATE_PRODUCE_H
+#define __UPDATE_PRODUCE_H
+
+#include "UpdatePair.h"
+
+struct CUpdatePair2
+{
+ bool NewData;
+ bool NewProps;
+ bool IsAnti;
+
+ int DirIndex;
+ int ArcIndex;
+ int NewNameIndex;
+
+ bool ExistOnDisk() const { return DirIndex != -1; }
+ bool ExistInArchive() const { return ArcIndex != -1; }
+
+ CUpdatePair2(): IsAnti(false), DirIndex(-1), ArcIndex(-1), NewNameIndex(-1) {}
+};
+
+struct IUpdateProduceCallback
+{
+ virtual HRESULT ShowDeleteFile(int arcIndex) = 0;
+};
+
+void UpdateProduce(
+ const CRecordVector<CUpdatePair> &updatePairs,
+ const NUpdateArchive::CActionSet &actionSet,
+ CRecordVector<CUpdatePair2> &operationChain,
+ IUpdateProduceCallback *callback);
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/WorkDir.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/WorkDir.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/WorkDir.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/WorkDir.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,59 @@
+// WorkDir.cpp
+
+#include "StdAfx.h"
+
+#include "Common/StringConvert.h"
+#include "Common/Wildcard.h"
+
+#include "Windows/FileDir.h"
+#include "Windows/FileName.h"
+
+#include "WorkDir.h"
+
+using namespace NWindows;
+using namespace NFile;
+
+UString GetWorkDir(const NWorkDir::CInfo &workDirInfo, const UString &path)
+{
+ NWorkDir::NMode::EEnum mode = workDirInfo.Mode;
+ #if !defined(UNDER_CE) && defined(_WIN32)
+ if (workDirInfo.ForRemovableOnly)
+ {
+ mode = NWorkDir::NMode::kCurrent;
+ UString prefix = path.Left(3);
+ if (prefix[1] == L':' && prefix[2] == L'\\')
+ {
+ UINT driveType = GetDriveType(GetSystemString(prefix, ::AreFileApisANSI() ? CP_ACP : CP_OEMCP));
+ if (driveType == DRIVE_CDROM || driveType == DRIVE_REMOVABLE)
+ mode = workDirInfo.Mode;
+ }
+ /*
+ CParsedPath parsedPath;
+ parsedPath.ParsePath(archiveName);
+ UINT driveType = GetDriveType(parsedPath.Prefix);
+ if ((driveType != DRIVE_CDROM) && (driveType != DRIVE_REMOVABLE))
+ mode = NZipSettings::NWorkDir::NMode::kCurrent;
+ */
+ }
+ #endif
+ switch(mode)
+ {
+ case NWorkDir::NMode::kCurrent:
+ {
+ return ExtractDirPrefixFromPath(path);
+ }
+ case NWorkDir::NMode::kSpecified:
+ {
+ UString tempDir = workDirInfo.Path;
+ NName::NormalizeDirPathPrefix(tempDir);
+ return tempDir;
+ }
+ default:
+ {
+ UString tempDir;
+ if (!NDirectory::MyGetTempPath(tempDir))
+ throw 141717;
+ return tempDir;
+ }
+ }
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/WorkDir.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/WorkDir.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/WorkDir.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/WorkDir.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,10 @@
+// WorkDir.h
+
+#ifndef __WORKDIR_H
+#define __WORKDIR_H
+
+#include "ZipRegistry.h"
+
+UString GetWorkDir(const NWorkDir::CInfo &workDirInfo, const UString &path);
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/ZipRegistry.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/ZipRegistry.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/ZipRegistry.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/ZipRegistry.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,293 @@
+// ZipRegistry.cpp
+
+#include "StdAfx.h"
+
+#include "Common/IntToString.h"
+#include "Common/StringConvert.h"
+
+#include "Windows/FileDir.h"
+#include "Windows/Registry.h"
+#include "Windows/Synchronization.h"
+
+#include "ZipRegistry.h"
+
+using namespace NWindows;
+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 CSysString GetKeyPath(const CSysString &path) { return kCuPrefix + path; }
+
+static LONG OpenMainKey(CKey &key, LPCTSTR keyName)
+{
+ return key.Open(HKEY_CURRENT_USER, GetKeyPath(keyName), KEY_READ);
+}
+
+static LONG CreateMainKey(CKey &key, LPCTSTR keyName)
+{
+ return key.Create(HKEY_CURRENT_USER, GetKeyPath(keyName));
+}
+
+namespace NExtract
+{
+
+static const TCHAR *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");
+
+void CInfo::Save() const
+{
+ CS_LOCK
+ CKey key;
+ CreateMainKey(key, kKeyName);
+ key.SetValue(kExtractMode, (UInt32)PathMode);
+ key.SetValue(kOverwriteMode, (UInt32)OverwriteMode);
+ key.SetValue(kShowPassword, ShowPassword);
+ key.RecurseDeleteKey(kPathHistory);
+ key.SetValue_Strings(kPathHistory, Paths);
+}
+
+
+void CInfo::Load()
+{
+ PathMode = NPathMode::kCurrentPathnames;
+ OverwriteMode = NOverwriteMode::kAskBefore;
+ ShowPassword = false;
+ Paths.Clear();
+
+ CS_LOCK
+ CKey key;
+ if (OpenMainKey(key, kKeyName) != ERROR_SUCCESS)
+ return;
+
+ key.GetValue_Strings(kPathHistory, Paths);
+ UInt32 v;
+ if (key.QueryValue(kExtractMode, v) == ERROR_SUCCESS && v <= NPathMode::kNoPathnames)
+ PathMode = (NPathMode::EEnum)v;
+ if (key.QueryValue(kOverwriteMode, v) == ERROR_SUCCESS && v <= NOverwriteMode::kAutoRenameExisting)
+ OverwriteMode = (NOverwriteMode::EEnum)v;
+ key.GetValue_IfOk(kShowPassword, ShowPassword);
+}
+
+}
+
+namespace NCompression
+{
+
+static const TCHAR *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 const TCHAR *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 void SetRegString(CKey &key, const WCHAR *name, const UString &value)
+{
+ if (value.IsEmpty())
+ key.DeleteValue(name);
+ else
+ key.SetValue(name, value);
+}
+
+static void SetRegUInt32(CKey &key, const TCHAR *name, UInt32 value)
+{
+ if (value == (UInt32)-1)
+ key.DeleteValue(name);
+ else
+ key.SetValue(name, value);
+}
+
+static void GetRegString(CKey &key, const WCHAR *name, UString &value)
+{
+ if (key.QueryValue(name, value) != ERROR_SUCCESS)
+ value.Empty();
+}
+
+static void GetRegUInt32(CKey &key, const TCHAR *name, UInt32 &value)
+{
+ if (key.QueryValue(name, value) != ERROR_SUCCESS)
+ value = (UInt32)-1;
+}
+
+void CInfo::Save() const
+{
+ CS_LOCK
+
+ CKey key;
+ CreateMainKey(key, kKeyName);
+ key.SetValue(kLevel, (UInt32)Level);
+ key.SetValue(kArchiver, ArcType);
+ key.SetValue(kShowPassword, ShowPassword);
+ key.SetValue(kEncryptHeaders, EncryptHeaders);
+ key.RecurseDeleteKey(kArcHistory);
+ key.SetValue_Strings(kArcHistory, ArcPaths);
+
+ key.RecurseDeleteKey(kOptionsKeyName);
+ {
+ CKey optionsKey;
+ optionsKey.Create(key, kOptionsKeyName);
+ for (int i = 0; i < Formats.Size(); i++)
+ {
+ const CFormatOptions &fo = Formats[i];
+ CKey fk;
+ fk.Create(optionsKey, fo.FormatID);
+
+ SetRegUInt32(fk, kLevel, fo.Level);
+ SetRegUInt32(fk, kDictionary, fo.Dictionary);
+ SetRegUInt32(fk, kOrder, fo.Order);
+ SetRegUInt32(fk, kBlockSize, fo.BlockLogSize);
+ SetRegUInt32(fk, kNumThreads, fo.NumThreads);
+
+ SetRegString(fk, kMethod, fo.Method);
+ SetRegString(fk, kOptions, fo.Options);
+ SetRegString(fk, kEncryptionMethod, fo.EncryptionMethod);
+ }
+ }
+}
+
+void CInfo::Load()
+{
+ ArcPaths.Clear();
+ Formats.Clear();
+
+ Level = 5;
+ ArcType = L"7z";
+ ShowPassword = false;
+ EncryptHeaders = false;
+
+ CS_LOCK
+ CKey key;
+
+ if (OpenMainKey(key, kKeyName) != ERROR_SUCCESS)
+ return;
+
+ key.GetValue_Strings(kArcHistory, ArcPaths);
+
+ {
+ CKey optionsKey;
+ if (optionsKey.Open(key, kOptionsKeyName, KEY_READ) == ERROR_SUCCESS)
+ {
+ CSysStringVector formatIDs;
+ optionsKey.EnumKeys(formatIDs);
+ for (int i = 0; i < formatIDs.Size(); i++)
+ {
+ CKey fk;
+ CFormatOptions fo;
+ fo.FormatID = formatIDs[i];
+ if (fk.Open(optionsKey, fo.FormatID, KEY_READ) == ERROR_SUCCESS)
+ {
+ GetRegString(fk, kOptions, fo.Options);
+ GetRegString(fk, kMethod, fo.Method);
+ GetRegString(fk, kEncryptionMethod, fo.EncryptionMethod);
+
+ GetRegUInt32(fk, kLevel, fo.Level);
+ GetRegUInt32(fk, kDictionary, fo.Dictionary);
+ GetRegUInt32(fk, kOrder, fo.Order);
+ GetRegUInt32(fk, kBlockSize, fo.BlockLogSize);
+ GetRegUInt32(fk, kNumThreads, fo.NumThreads);
+
+ Formats.Add(fo);
+ }
+ }
+ }
+ }
+
+ UString a;
+ if (key.QueryValue(kArchiver, a) == ERROR_SUCCESS)
+ ArcType = a;
+ key.GetValue_IfOk(kLevel, Level);
+ key.GetValue_IfOk(kShowPassword, ShowPassword);
+ key.GetValue_IfOk(kEncryptHeaders, EncryptHeaders);
+}
+
+}
+
+static const TCHAR *kOptionsInfoKeyName = TEXT("Options");
+
+namespace NWorkDir
+{
+static const TCHAR *kWorkDirType = TEXT("WorkDirType");
+static const WCHAR *kWorkDirPath = L"WorkDirPath";
+static const TCHAR *kTempRemovableOnly = TEXT("TempRemovableOnly");
+
+
+void CInfo::Save()const
+{
+ CS_LOCK
+ CKey key;
+ CreateMainKey(key, kOptionsInfoKeyName);
+ key.SetValue(kWorkDirType, (UInt32)Mode);
+ key.SetValue(kWorkDirPath, Path);
+ key.SetValue(kTempRemovableOnly, ForRemovableOnly);
+}
+
+void CInfo::Load()
+{
+ SetDefault();
+
+ CS_LOCK
+ CKey key;
+ if (OpenMainKey(key, kOptionsInfoKeyName) != ERROR_SUCCESS)
+ return;
+
+ UInt32 dirType;
+ if (key.QueryValue(kWorkDirType, dirType) != ERROR_SUCCESS)
+ return;
+ switch (dirType)
+ {
+ case NMode::kSystem:
+ case NMode::kCurrent:
+ case NMode::kSpecified:
+ Mode = (NMode::EEnum)dirType;
+ }
+ if (key.QueryValue(kWorkDirPath, Path) != ERROR_SUCCESS)
+ {
+ Path.Empty();
+ if (Mode == NMode::kSpecified)
+ Mode = NMode::kSystem;
+ }
+ key.GetValue_IfOk(kTempRemovableOnly, ForRemovableOnly);
+}
+
+}
+
+static const TCHAR *kCascadedMenu = TEXT("CascadedMenu");
+static const TCHAR *kContextMenu = TEXT("ContextMenu");
+
+void CContextMenuInfo::Save() const
+{
+ CS_LOCK
+ CKey key;
+ CreateMainKey(key, kOptionsInfoKeyName);
+ key.SetValue(kCascadedMenu, Cascaded);
+ key.SetValue(kContextMenu, Flags);
+}
+
+void CContextMenuInfo::Load()
+{
+ Cascaded = true;
+ Flags = (UInt32)-1;
+ CS_LOCK
+ CKey key;
+ if (OpenMainKey(key, kOptionsInfoKeyName) != ERROR_SUCCESS)
+ return;
+ key.GetValue_IfOk(kCascadedMenu, Cascaded);
+ key.GetValue_IfOk(kContextMenu, Flags);
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/ZipRegistry.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/ZipRegistry.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/ZipRegistry.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/ZipRegistry.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,105 @@
+// ZipRegistry.h
+
+#ifndef __ZIP_REGISTRY_H
+#define __ZIP_REGISTRY_H
+
+#include "Common/MyString.h"
+#include "Common/Types.h"
+
+#include "ExtractMode.h"
+
+namespace NExtract
+{
+ struct CInfo
+ {
+ NPathMode::EEnum PathMode;
+ NOverwriteMode::EEnum OverwriteMode;
+ bool ShowPassword;
+ UStringVector Paths;
+
+ void Save() const;
+ void Load();
+ };
+}
+
+namespace NCompression
+{
+ struct CFormatOptions
+ {
+ UInt32 Level;
+ UInt32 Dictionary;
+ UInt32 Order;
+ UInt32 BlockLogSize;
+ UInt32 NumThreads;
+
+ CSysString FormatID;
+ UString Method;
+ UString Options;
+ UString EncryptionMethod;
+
+ void ResetForLevelChange()
+ {
+ BlockLogSize = NumThreads = Level = Dictionary = Order = UInt32(-1);
+ Method.Empty();
+ // Options.Empty();
+ // EncryptionMethod.Empty();
+ }
+ CFormatOptions() { ResetForLevelChange(); }
+ };
+
+ struct CInfo
+ {
+ UInt32 Level;
+ bool ShowPassword;
+ bool EncryptHeaders;
+ UString ArcType;
+ UStringVector ArcPaths;
+
+ CObjectVector<CFormatOptions> Formats;
+
+ void Save() const;
+ void Load();
+ };
+}
+
+namespace NWorkDir
+{
+ namespace NMode
+ {
+ enum EEnum
+ {
+ kSystem,
+ kCurrent,
+ kSpecified
+ };
+ }
+ struct CInfo
+ {
+ NMode::EEnum Mode;
+ UString Path;
+ bool ForRemovableOnly;
+
+ void SetForRemovableOnlyDefault() { ForRemovableOnly = true; }
+ void SetDefault()
+ {
+ Mode = NMode::kSystem;
+ Path.Empty();
+ SetForRemovableOnlyDefault();
+ }
+
+ void Save() const;
+ void Load();
+ };
+}
+
+
+struct CContextMenuInfo
+{
+ bool Cascaded;
+ UInt32 Flags;
+
+ void Save() const;
+ void Load();
+};
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/BenchCon.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/BenchCon.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/BenchCon.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/BenchCon.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,297 @@
+// BenchCon.cpp
+
+#include "StdAfx.h"
+
+#include "../../../Common/IntToString.h"
+#include "../../../Common/MyCom.h"
+
+#if !defined(_7ZIP_ST) || defined(_WIN32)
+#include "../../../Windows/System.h"
+#endif
+
+#include "../Common/Bench.h"
+
+#include "BenchCon.h"
+#include "ConsoleClose.h"
+
+struct CTotalBenchRes
+{
+ UInt64 NumIterations;
+ UInt64 Rating;
+ UInt64 Usage;
+ UInt64 RPU;
+ void Init() { NumIterations = 0; Rating = 0; Usage = 0; RPU = 0; }
+ void Normalize()
+ {
+ if (NumIterations == 0)
+ return;
+ Rating /= NumIterations;
+ Usage /= NumIterations;
+ RPU /= NumIterations;
+ NumIterations = 1;
+ }
+ void SetMid(const CTotalBenchRes &r1, const CTotalBenchRes &r2)
+ {
+ Rating = (r1.Rating + r2.Rating) / 2;
+ Usage = (r1.Usage + r2.Usage) / 2;
+ RPU = (r1.RPU + r2.RPU) / 2;
+ NumIterations = (r1.NumIterations + r2.NumIterations) / 2;
+ }
+};
+
+struct CBenchCallback: public IBenchCallback
+{
+ CTotalBenchRes EncodeRes;
+ CTotalBenchRes DecodeRes;
+ FILE *f;
+ void Init() { EncodeRes.Init(); DecodeRes.Init(); }
+ void Normalize() { EncodeRes.Normalize(); DecodeRes.Normalize(); }
+ UInt32 dictionarySize;
+ HRESULT SetEncodeResult(const CBenchInfo &info, bool final);
+ HRESULT SetDecodeResult(const CBenchInfo &info, bool final);
+};
+
+static void NormalizeVals(UInt64 &v1, UInt64 &v2)
+{
+ while (v1 > 1000000)
+ {
+ v1 >>= 1;
+ v2 >>= 1;
+ }
+}
+
+static UInt64 MyMultDiv64(UInt64 value, UInt64 elapsedTime, UInt64 freq)
+{
+ UInt64 elTime = elapsedTime;
+ NormalizeVals(freq, elTime);
+ if (elTime == 0)
+ elTime = 1;
+ return value * freq / elTime;
+}
+
+static void PrintNumber(FILE *f, UInt64 value, int size)
+{
+ char s[32];
+ ConvertUInt64ToString(value, s);
+ fprintf(f, " ");
+ for (int len = (int)strlen(s); len < size; len++)
+ fprintf(f, " ");
+ fputs(s, f);
+}
+
+static void PrintRating(FILE *f, UInt64 rating)
+{
+ PrintNumber(f, rating / 1000000, 6);
+}
+
+static void PrintResults(FILE *f, UInt64 usage, UInt64 rpu, UInt64 rating)
+{
+ PrintNumber(f, (usage + 5000) / 10000, 5);
+ PrintRating(f, rpu);
+ PrintRating(f, rating);
+}
+
+
+static void PrintResults(FILE *f, const CBenchInfo &info, UInt64 rating, CTotalBenchRes &res)
+{
+ UInt64 speed = MyMultDiv64(info.UnpackSize, info.GlobalTime, info.GlobalFreq);
+ PrintNumber(f, speed / 1024, 7);
+ UInt64 usage = GetUsage(info);
+ UInt64 rpu = GetRatingPerUsage(info, rating);
+ PrintResults(f, usage, rpu, rating);
+ res.NumIterations++;
+ res.RPU += rpu;
+ res.Rating += rating;
+ res.Usage += usage;
+}
+
+static void PrintTotals(FILE *f, const CTotalBenchRes &res)
+{
+ fprintf(f, " ");
+ PrintResults(f, res.Usage, res.RPU, res.Rating);
+}
+
+
+HRESULT CBenchCallback::SetEncodeResult(const CBenchInfo &info, bool final)
+{
+ if (NConsoleClose::TestBreakSignal())
+ return E_ABORT;
+ if (final)
+ {
+ UInt64 rating = GetCompressRating(dictionarySize, info.GlobalTime, info.GlobalFreq, info.UnpackSize);
+ PrintResults(f, info, rating, EncodeRes);
+ }
+ return S_OK;
+}
+
+static const char *kSep = " | ";
+
+
+HRESULT CBenchCallback::SetDecodeResult(const CBenchInfo &info, bool final)
+{
+ if (NConsoleClose::TestBreakSignal())
+ return E_ABORT;
+ if (final)
+ {
+ UInt64 rating = GetDecompressRating(info.GlobalTime, info.GlobalFreq, info.UnpackSize, info.PackSize, info.NumIterations);
+ fputs(kSep, f);
+ CBenchInfo info2 = info;
+ info2.UnpackSize *= info2.NumIterations;
+ info2.PackSize *= info2.NumIterations;
+ info2.NumIterations = 1;
+ PrintResults(f, info2, rating, DecodeRes);
+ }
+ return S_OK;
+}
+
+static void PrintRequirements(FILE *f, const char *sizeString, UInt64 size, const char *threadsString, UInt32 numThreads)
+{
+ fprintf(f, "\nRAM %s ", sizeString);
+ PrintNumber(f, (size >> 20), 5);
+ fprintf(f, " MB, # %s %3d", threadsString, (unsigned int)numThreads);
+}
+
+HRESULT LzmaBenchCon(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ FILE *f, UInt32 numIterations, UInt32 numThreads, UInt32 dictionary)
+{
+ if (!CrcInternalTest())
+ return S_FALSE;
+ #ifndef _7ZIP_ST
+ UInt64 ramSize = NWindows::NSystem::GetRamSize(); //
+ UInt32 numCPUs = NWindows::NSystem::GetNumberOfProcessors();
+ PrintRequirements(f, "size: ", ramSize, "CPU hardware threads:", numCPUs);
+ if (numThreads == (UInt32)-1)
+ numThreads = numCPUs;
+ if (numThreads > 1)
+ numThreads &= ~1;
+ if (dictionary == (UInt32)-1)
+ {
+ int dicSizeLog;
+ for (dicSizeLog = 25; dicSizeLog > kBenchMinDicLogSize; dicSizeLog--)
+ if (GetBenchMemoryUsage(numThreads, ((UInt32)1 << dicSizeLog)) + (8 << 20) <= ramSize)
+ break;
+ dictionary = (1 << dicSizeLog);
+ }
+ #else
+ if (dictionary == (UInt32)-1)
+ dictionary = (1 << 22);
+ numThreads = 1;
+ #endif
+
+ PrintRequirements(f, "usage:", GetBenchMemoryUsage(numThreads, dictionary), "Benchmark threads: ", numThreads);
+
+ CBenchCallback callback;
+ callback.Init();
+ callback.f = f;
+
+ fprintf(f, "\n\nDict Compressing | Decompressing\n ");
+ int j;
+ for (j = 0; j < 2; j++)
+ {
+ fprintf(f, " Speed Usage R/U Rating");
+ if (j == 0)
+ fputs(kSep, f);
+ }
+ fprintf(f, "\n ");
+ for (j = 0; j < 2; j++)
+ {
+ fprintf(f, " KB/s %% MIPS MIPS");
+ if (j == 0)
+ fputs(kSep, f);
+ }
+ fprintf(f, "\n\n");
+ for (UInt32 i = 0; i < numIterations; i++)
+ {
+ const int kStartDicLog = 22;
+ int pow = (dictionary < ((UInt32)1 << kStartDicLog)) ? kBenchMinDicLogSize : kStartDicLog;
+ while (((UInt32)1 << pow) > dictionary)
+ pow--;
+ for (; ((UInt32)1 << pow) <= dictionary; pow++)
+ {
+ fprintf(f, "%2d:", pow);
+ callback.dictionarySize = (UInt32)1 << pow;
+ HRESULT res = LzmaBench(
+ EXTERNAL_CODECS_LOC_VARS
+ numThreads, callback.dictionarySize, &callback);
+ fprintf(f, "\n");
+ RINOK(res);
+ }
+ }
+ callback.Normalize();
+ fprintf(f, "----------------------------------------------------------------\nAvr:");
+ PrintTotals(f, callback.EncodeRes);
+ fprintf(f, " ");
+ PrintTotals(f, callback.DecodeRes);
+ fprintf(f, "\nTot:");
+ CTotalBenchRes midRes;
+ midRes.SetMid(callback.EncodeRes, callback.DecodeRes);
+ PrintTotals(f, midRes);
+ fprintf(f, "\n");
+ return S_OK;
+}
+
+struct CTempValues
+{
+ UInt64 *Values;
+ CTempValues(UInt32 num) { Values = new UInt64[num]; }
+ ~CTempValues() { delete []Values; }
+};
+
+HRESULT CrcBenchCon(FILE *f, UInt32 numIterations, UInt32 numThreads, UInt32 dictionary)
+{
+ if (!CrcInternalTest())
+ return S_FALSE;
+
+ #ifndef _7ZIP_ST
+ UInt64 ramSize = NWindows::NSystem::GetRamSize();
+ UInt32 numCPUs = NWindows::NSystem::GetNumberOfProcessors();
+ PrintRequirements(f, "size: ", ramSize, "CPU hardware threads:", numCPUs);
+ if (numThreads == (UInt32)-1)
+ numThreads = numCPUs;
+ #else
+ numThreads = 1;
+ #endif
+ if (dictionary == (UInt32)-1)
+ dictionary = (1 << 24);
+
+ CTempValues speedTotals(numThreads);
+ fprintf(f, "\n\nSize");
+ for (UInt32 ti = 0; ti < numThreads; ti++)
+ {
+ fprintf(f, " %5d", ti + 1);
+ speedTotals.Values[ti] = 0;
+ }
+ fprintf(f, "\n\n");
+
+ UInt64 numSteps = 0;
+ for (UInt32 i = 0; i < numIterations; i++)
+ {
+ for (int pow = 10; pow < 32; pow++)
+ {
+ UInt32 bufSize = (UInt32)1 << pow;
+ if (bufSize > dictionary)
+ break;
+ fprintf(f, "%2d: ", pow);
+ UInt64 speed;
+ for (UInt32 ti = 0; ti < numThreads; ti++)
+ {
+ if (NConsoleClose::TestBreakSignal())
+ return E_ABORT;
+ RINOK(CrcBench(ti + 1, bufSize, speed));
+ PrintNumber(f, (speed >> 20), 5);
+ speedTotals.Values[ti] += speed;
+ }
+ fprintf(f, "\n");
+ numSteps++;
+ }
+ }
+ if (numSteps != 0)
+ {
+ fprintf(f, "\nAvg:");
+ for (UInt32 ti = 0; ti < numThreads; ti++)
+ PrintNumber(f, ((speedTotals.Values[ti] / numSteps) >> 20), 5);
+ fprintf(f, "\n");
+ }
+ return S_OK;
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/BenchCon.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/BenchCon.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/BenchCon.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/BenchCon.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,16 @@
+// BenchCon.h
+
+#ifndef __BENCH_CON_H
+#define __BENCH_CON_H
+
+#include <stdio.h>
+
+#include "../../Common/CreateCoder.h"
+
+HRESULT LzmaBenchCon(
+ DECL_EXTERNAL_CODECS_LOC_VARS
+ FILE *f, UInt32 numIterations, UInt32 numThreads, UInt32 dictionary);
+
+HRESULT CrcBenchCon(FILE *f, UInt32 numIterations, UInt32 numThreads, UInt32 dictionary);
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/ConsoleClose.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/ConsoleClose.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/ConsoleClose.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/ConsoleClose.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,49 @@
+// ConsoleClose.cpp
+
+#include "StdAfx.h"
+
+#include "ConsoleClose.h"
+
+#include <signal.h>
+
+static int g_BreakCounter = 0;
+static const int kBreakAbortThreshold = 2;
+
+namespace NConsoleClose {
+
+static void HandlerRoutine(int)
+{
+ g_BreakCounter++;
+ if (g_BreakCounter < kBreakAbortThreshold)
+ return ;
+ exit(EXIT_FAILURE);
+}
+
+bool TestBreakSignal()
+{
+ return (g_BreakCounter > 0);
+}
+
+void CheckCtrlBreak()
+{
+ if (TestBreakSignal())
+ throw CCtrlBreakException();
+}
+
+CCtrlHandlerSetter::CCtrlHandlerSetter()
+{
+ memo_sig_int = signal(SIGINT,HandlerRoutine); // CTRL-C
+ if (memo_sig_int == SIG_ERR)
+ throw "SetConsoleCtrlHandler fails (SIGINT)";
+ memo_sig_term = signal(SIGTERM,HandlerRoutine); // for kill -15 (before "kill -9")
+ if (memo_sig_term == SIG_ERR)
+ throw "SetConsoleCtrlHandler fails (SIGTERM)";
+}
+
+CCtrlHandlerSetter::~CCtrlHandlerSetter()
+{
+ signal(SIGINT,memo_sig_int); // CTRL-C
+ signal(SIGTERM,memo_sig_term); // kill {pid}
+}
+
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/ConsoleClose.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/ConsoleClose.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/ConsoleClose.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/ConsoleClose.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,26 @@
+// ConsoleCloseUtils.h
+
+#ifndef __CONSOLECLOSEUTILS_H
+#define __CONSOLECLOSEUTILS_H
+
+namespace NConsoleClose {
+
+bool TestBreakSignal();
+
+class CCtrlHandlerSetter
+{
+ void (*memo_sig_int)(int);
+ void (*memo_sig_term)(int);
+public:
+ CCtrlHandlerSetter();
+ virtual ~CCtrlHandlerSetter();
+};
+
+class CCtrlBreakException
+{};
+
+void CheckCtrlBreak();
+
+}
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/ExtractCallbackConsole.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/ExtractCallbackConsole.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/ExtractCallbackConsole.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/ExtractCallbackConsole.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,228 @@
+// ExtractCallbackConsole.h
+
+#include "StdAfx.h"
+
+#include "ExtractCallbackConsole.h"
+#include "UserInputUtils.h"
+#include "ConsoleClose.h"
+
+#include "Common/Wildcard.h"
+
+#include "Windows/FileDir.h"
+#include "Windows/FileFind.h"
+#include "Windows/Time.h"
+#include "Windows/Defs.h"
+#include "Windows/PropVariant.h"
+#include "Windows/Error.h"
+#include "Windows/PropVariantConversions.h"
+
+#include "../../Common/FilePathAutoRename.h"
+
+#include "../Common/ExtractingFilePath.h"
+
+using namespace NWindows;
+using namespace NFile;
+using namespace NDirectory;
+
+static const char *kTestString = "Testing ";
+static const char *kExtractString = "Extracting ";
+static const char *kSkipString = "Skipping ";
+
+// 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 *kError = "ERROR: ";
+static const char *kMemoryExceptionMessage = "Can't allocate required memory!";
+
+static const char *kProcessing = "Processing archive: ";
+static const char *kEverythingIsOk = "Everything is Ok";
+static const char *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 *kUnknownError = "Unknown Error";
+
+STDMETHODIMP CExtractCallbackConsole::SetTotal(UInt64)
+{
+ if (NConsoleClose::TestBreakSignal())
+ return E_ABORT;
+ return S_OK;
+}
+
+STDMETHODIMP CExtractCallbackConsole::SetCompleted(const UInt64 *)
+{
+ if (NConsoleClose::TestBreakSignal())
+ return E_ABORT;
+ return S_OK;
+}
+
+STDMETHODIMP CExtractCallbackConsole::AskOverwrite(
+ const wchar_t *existName, const FILETIME *, const UInt64 *,
+ const wchar_t *newName, const FILETIME *, const UInt64 *,
+ Int32 *answer)
+{
+ (*OutStream) << "file " << existName <<
+ "\nalready exists. Overwrite with " << endl;
+ (*OutStream) << newName;
+
+ NUserAnswerMode::EEnum overwriteAnswer = ScanUserYesNoAllQuit(OutStream);
+
+ switch(overwriteAnswer)
+ {
+ case NUserAnswerMode::kQuit: return E_ABORT;
+ case NUserAnswerMode::kNo: *answer = NOverwriteAnswer::kNo; break;
+ case NUserAnswerMode::kNoAll: *answer = NOverwriteAnswer::kNoToAll; break;
+ case NUserAnswerMode::kYesAll: *answer = NOverwriteAnswer::kYesToAll; break;
+ case NUserAnswerMode::kYes: *answer = NOverwriteAnswer::kYes; break;
+ case NUserAnswerMode::kAutoRenameAll: *answer = NOverwriteAnswer::kAutoRename; break;
+ default: return E_FAIL;
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CExtractCallbackConsole::PrepareOperation(const wchar_t *name, bool /* isFolder */, Int32 askExtractMode, const UInt64 *position)
+{
+ switch (askExtractMode)
+ {
+ case NArchive::NExtract::NAskMode::kExtract: (*OutStream) << kExtractString; break;
+ case NArchive::NExtract::NAskMode::kTest: (*OutStream) << kTestString; break;
+ case NArchive::NExtract::NAskMode::kSkip: (*OutStream) << kSkipString; break;
+ };
+ (*OutStream) << name;
+ if (position != 0)
+ (*OutStream) << " <" << *position << ">";
+ return S_OK;
+}
+
+STDMETHODIMP CExtractCallbackConsole::MessageError(const wchar_t *message)
+{
+ (*OutStream) << message << endl;
+ NumFileErrorsInCurrentArchive++;
+ NumFileErrors++;
+ return S_OK;
+}
+
+STDMETHODIMP CExtractCallbackConsole::SetOperationResult(Int32 operationResult, bool encrypted)
+{
+ switch(operationResult)
+ {
+ case NArchive::NExtract::NOperationResult::kOK:
+ break;
+ default:
+ {
+ NumFileErrorsInCurrentArchive++;
+ NumFileErrors++;
+ (*OutStream) << " ";
+ switch(operationResult)
+ {
+ case NArchive::NExtract::NOperationResult::kUnSupportedMethod:
+ (*OutStream) << kUnsupportedMethod;
+ break;
+ case NArchive::NExtract::NOperationResult::kCRCError:
+ (*OutStream) << (encrypted ? kCrcFailedEncrypted: kCrcFailed);
+ break;
+ case NArchive::NExtract::NOperationResult::kDataError:
+ (*OutStream) << (encrypted ? kDataErrorEncrypted : kDataError);
+ break;
+ default:
+ (*OutStream) << kUnknownError;
+ }
+ }
+ }
+ (*OutStream) << endl;
+ return S_OK;
+}
+
+#ifndef _NO_CRYPTO
+
+HRESULT CExtractCallbackConsole::SetPassword(const UString &password)
+{
+ PasswordIsDefined = true;
+ Password = password;
+ return S_OK;
+}
+
+STDMETHODIMP CExtractCallbackConsole::CryptoGetTextPassword(BSTR *password)
+{
+ if (!PasswordIsDefined)
+ {
+ Password = GetPassword(OutStream);
+ PasswordIsDefined = true;
+ }
+ return StringToBstr(Password, password);
+}
+
+#endif
+
+HRESULT CExtractCallbackConsole::BeforeOpen(const wchar_t *name)
+{
+ NumArchives++;
+ NumFileErrorsInCurrentArchive = 0;
+ (*OutStream) << endl << kProcessing << name << endl;
+ return S_OK;
+}
+
+HRESULT CExtractCallbackConsole::OpenResult(const wchar_t * /* name */, HRESULT result, bool encrypted)
+{
+ (*OutStream) << endl;
+ if (result != S_OK)
+ {
+ (*OutStream) << "Error: ";
+ if (result == S_FALSE)
+ {
+ (*OutStream) << (encrypted ?
+ "Can not open encrypted archive. Wrong password?" :
+ "Can not open file as archive");
+ }
+ else
+ {
+ if (result == E_OUTOFMEMORY)
+ (*OutStream) << "Can't allocate required memory";
+ else
+ (*OutStream) << NError::MyFormatMessage(result);
+ }
+ (*OutStream) << endl;
+ NumArchiveErrors++;
+ }
+ return S_OK;
+}
+
+HRESULT CExtractCallbackConsole::ThereAreNoFiles()
+{
+ (*OutStream) << endl << kNoFiles << endl;
+ return S_OK;
+}
+
+HRESULT CExtractCallbackConsole::ExtractResult(HRESULT result)
+{
+ if (result == S_OK)
+ {
+ (*OutStream) << endl;
+ if (NumFileErrorsInCurrentArchive == 0)
+ (*OutStream) << kEverythingIsOk << endl;
+ else
+ {
+ NumArchiveErrors++;
+ (*OutStream) << "Sub items Errors: " << NumFileErrorsInCurrentArchive << endl;
+ }
+ }
+ if (result == S_OK)
+ return result;
+ NumArchiveErrors++;
+ if (result == E_ABORT || result == ERROR_DISK_FULL)
+ return result;
+ (*OutStream) << endl << kError;
+ if (result == E_OUTOFMEMORY)
+ (*OutStream) << kMemoryExceptionMessage;
+ else
+ {
+ UString message;
+ NError::MyFormatMessage(result, message);
+ (*OutStream) << message;
+ }
+ (*OutStream) << endl;
+ return S_OK;
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/ExtractCallbackConsole.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/ExtractCallbackConsole.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/ExtractCallbackConsole.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/ExtractCallbackConsole.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,73 @@
+// ExtractCallbackConsole.h
+
+#ifndef __EXTRACTCALLBACKCONSOLE_H
+#define __EXTRACTCALLBACKCONSOLE_H
+
+#include "Common/MyString.h"
+#include "Common/StdOutStream.h"
+#include "../../Common/FileStreams.h"
+#include "../../IPassword.h"
+#include "../../Archive/IArchive.h"
+#include "../Common/ArchiveExtractCallback.h"
+
+class CExtractCallbackConsole:
+ public IExtractCallbackUI,
+ #ifndef _NO_CRYPTO
+ public ICryptoGetTextPassword,
+ #endif
+ public CMyUnknownImp
+{
+public:
+ MY_QUERYINTERFACE_BEGIN2(IFolderArchiveExtractCallback)
+ #ifndef _NO_CRYPTO
+ MY_QUERYINTERFACE_ENTRY(ICryptoGetTextPassword)
+ #endif
+ MY_QUERYINTERFACE_END
+ MY_ADDREF_RELEASE
+
+ STDMETHOD(SetTotal)(UInt64 total);
+ STDMETHOD(SetCompleted)(const UInt64 *completeValue);
+
+ // IFolderArchiveExtractCallback
+ STDMETHOD(AskOverwrite)(
+ const wchar_t *existName, const FILETIME *existTime, const UInt64 *existSize,
+ const wchar_t *newName, const FILETIME *newTime, const UInt64 *newSize,
+ Int32 *answer);
+ STDMETHOD (PrepareOperation)(const wchar_t *name, bool isFolder, Int32 askExtractMode, const UInt64 *position);
+
+ STDMETHOD(MessageError)(const wchar_t *message);
+ STDMETHOD(SetOperationResult)(Int32 operationResult, bool encrypted);
+
+ HRESULT BeforeOpen(const wchar_t *name);
+ HRESULT OpenResult(const wchar_t *name, HRESULT result, bool encrypted);
+ HRESULT ThereAreNoFiles();
+ HRESULT ExtractResult(HRESULT result);
+
+
+ #ifndef _NO_CRYPTO
+ HRESULT SetPassword(const UString &password);
+ STDMETHOD(CryptoGetTextPassword)(BSTR *password);
+
+ bool PasswordIsDefined;
+ UString Password;
+
+ #endif
+
+ UInt64 NumArchives;
+ UInt64 NumArchiveErrors;
+ UInt64 NumFileErrors;
+ UInt64 NumFileErrorsInCurrentArchive;
+
+ CStdOutStream *OutStream;
+
+ void Init()
+ {
+ NumArchives = 0;
+ NumArchiveErrors = 0;
+ NumFileErrors = 0;
+ NumFileErrorsInCurrentArchive = 0;
+ }
+
+};
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/List.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/List.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/List.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/List.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,654 @@
+// List.cpp
+
+#include "StdAfx.h"
+
+#include "Common/IntToString.h"
+#include "Common/MyCom.h"
+#include "Common/StdOutStream.h"
+#include "Common/StringConvert.h"
+
+#include "Windows/Error.h"
+#include "Windows/FileDir.h"
+#include "Windows/PropVariant.h"
+#include "Windows/PropVariantConversions.h"
+
+#include "../../Archive/IArchive.h"
+
+#include "../Common/OpenArchive.h"
+#include "../Common/PropIDUtils.h"
+
+#include "ConsoleClose.h"
+#include "List.h"
+#include "OpenCallbackConsole.h"
+
+using namespace NWindows;
+
+struct CPropIdToName
+{
+ PROPID PropID;
+ const wchar_t *Name;
+};
+
+static const CPropIdToName kPropIdToName[] =
+{
+ { kpidPath, L"Path" },
+ { kpidName, L"Name" },
+ { kpidIsDir, L"Folder" },
+ { kpidSize, L"Size" },
+ { kpidPackSize, L"Packed Size" },
+ { kpidAttrib, L"Attributes" },
+ { kpidCTime, L"Created" },
+ { kpidATime, L"Accessed" },
+ { kpidMTime, L"Modified" },
+ { kpidSolid, L"Solid" },
+ { kpidCommented, L"Commented" },
+ { kpidEncrypted, L"Encrypted" },
+ { kpidSplitBefore, L"Split Before" },
+ { kpidSplitAfter, L"Split After" },
+ { kpidDictionarySize, L"Dictionary Size" },
+ { kpidCRC, L"CRC" },
+ { kpidType, L"Type" },
+ { kpidIsAnti, L"Anti" },
+ { kpidMethod, L"Method" },
+ { kpidHostOS, L"Host OS" },
+ { kpidFileSystem, L"File System" },
+ { kpidUser, L"User" },
+ { kpidGroup, L"Group" },
+ { kpidBlock, L"Block" },
+ { kpidComment, L"Comment" },
+ { kpidPosition, L"Position" },
+ { kpidPrefix, L"Prefix" },
+ { kpidNumSubDirs, L"Folders" },
+ { kpidNumSubFiles, L"Files" },
+ { kpidUnpackVer, L"Version" },
+ { kpidVolume, L"Volume" },
+ { kpidIsVolume, L"Multivolume" },
+ { kpidOffset, L"Offset" },
+ { kpidLinks, L"Links" },
+ { kpidNumBlocks, L"Blocks" },
+ { kpidNumVolumes, L"Volumes" },
+
+ { kpidBit64, L"64-bit" },
+ { kpidBigEndian, L"Big-endian" },
+ { kpidCpu, L"CPU" },
+ { kpidPhySize, L"Physical Size" },
+ { kpidHeadersSize, L"Headers Size" },
+ { kpidChecksum, L"Checksum" },
+ { kpidCharacts, L"Characteristics" },
+ { kpidVa, L"Virtual Address" },
+ { kpidId, L"ID" },
+ { kpidShortName, L"Short Name" },
+ { kpidCreatorApp, L"Creator Application"},
+ { kpidSectorSize, L"Sector Size" },
+ { kpidPosixAttrib, L"Mode" },
+ { kpidLink, L"Link" },
+ { kpidError, L"Error" },
+
+ { kpidTotalSize, L"Total Size" },
+ { kpidFreeSpace, L"Free Space" },
+ { kpidClusterSize, L"Cluster Size" },
+ { kpidVolumeName, L"Label" }
+};
+
+static const char kEmptyAttribChar = '.';
+
+static const char *kListing = "Listing archive: ";
+static const wchar_t *kFilesMessage = L"files";
+static const wchar_t *kDirsMessage = L"folders";
+
+static void GetAttribString(DWORD wa, bool isDir, char *s)
+{
+ s[0] = ((wa & FILE_ATTRIBUTE_DIRECTORY) != 0 || isDir) ? 'D' : kEmptyAttribChar;
+ s[1] = ((wa & FILE_ATTRIBUTE_READONLY) != 0) ? 'R': kEmptyAttribChar;
+ s[2] = ((wa & FILE_ATTRIBUTE_HIDDEN) != 0) ? 'H': kEmptyAttribChar;
+ s[3] = ((wa & FILE_ATTRIBUTE_SYSTEM) != 0) ? 'S': kEmptyAttribChar;
+ s[4] = ((wa & FILE_ATTRIBUTE_ARCHIVE) != 0) ? 'A': kEmptyAttribChar;
+ s[5] = '\0';
+}
+
+enum EAdjustment
+{
+ kLeft,
+ kCenter,
+ kRight
+};
+
+struct CFieldInfo
+{
+ PROPID PropID;
+ UString Name;
+ EAdjustment TitleAdjustment;
+ EAdjustment TextAdjustment;
+ int PrefixSpacesWidth;
+ int Width;
+};
+
+struct CFieldInfoInit
+{
+ PROPID PropID;
+ const wchar_t *Name;
+ EAdjustment TitleAdjustment;
+ EAdjustment TextAdjustment;
+ int PrefixSpacesWidth;
+ int Width;
+};
+
+static CFieldInfoInit kStandardFieldTable[] =
+{
+ { kpidMTime, L" Date Time", kLeft, kLeft, 0, 19 },
+ { kpidAttrib, L"Attr", kRight, kCenter, 1, 5 },
+ { kpidSize, L"Size", kRight, kRight, 1, 12 },
+ { kpidPackSize, L"Compressed", kRight, kRight, 1, 12 },
+ { kpidPath, L"Name", kLeft, kLeft, 2, 24 }
+};
+
+static void PrintSpaces(int numSpaces)
+{
+ for (int i = 0; i < numSpaces; i++)
+ g_StdOut << ' ';
+}
+
+static void PrintString(EAdjustment adjustment, int width, const UString &textString)
+{
+ const int numSpaces = width - textString.Length();
+ int numLeftSpaces = 0;
+ switch (adjustment)
+ {
+ case kLeft:
+ numLeftSpaces = 0;
+ break;
+ case kCenter:
+ numLeftSpaces = numSpaces / 2;
+ break;
+ case kRight:
+ numLeftSpaces = numSpaces;
+ break;
+ }
+ PrintSpaces(numLeftSpaces);
+ g_StdOut << textString;
+ PrintSpaces(numSpaces - numLeftSpaces);
+}
+
+class CFieldPrinter
+{
+ CObjectVector<CFieldInfo> _fields;
+public:
+ void Clear() { _fields.Clear(); }
+ void Init(const CFieldInfoInit *standardFieldTable, int numItems);
+ HRESULT Init(IInArchive *archive);
+ void PrintTitle();
+ void PrintTitleLines();
+ HRESULT PrintItemInfo(const CArc &arc, UInt32 index, bool techMode);
+ HRESULT PrintSummaryInfo(UInt64 numFiles, UInt64 numDirs,
+ const UInt64 *size, const UInt64 *compressedSize);
+};
+
+void CFieldPrinter::Init(const CFieldInfoInit *standardFieldTable, int numItems)
+{
+ Clear();
+ for (int i = 0; i < numItems; i++)
+ {
+ CFieldInfo fieldInfo;
+ const CFieldInfoInit &fieldInfoInit = standardFieldTable[i];
+ fieldInfo.PropID = fieldInfoInit.PropID;
+ fieldInfo.Name = fieldInfoInit.Name;
+ fieldInfo.TitleAdjustment = fieldInfoInit.TitleAdjustment;
+ fieldInfo.TextAdjustment = fieldInfoInit.TextAdjustment;
+ fieldInfo.PrefixSpacesWidth = fieldInfoInit.PrefixSpacesWidth;
+ fieldInfo.Width = fieldInfoInit.Width;
+ _fields.Add(fieldInfo);
+ }
+}
+
+static UString GetPropName(PROPID propID, BSTR name)
+{
+ for (int i = 0; i < sizeof(kPropIdToName) / sizeof(kPropIdToName[0]); i++)
+ {
+ const CPropIdToName &propIdToName = kPropIdToName[i];
+ if (propIdToName.PropID == propID)
+ return propIdToName.Name;
+ }
+ if (name)
+ return name;
+ wchar_t s[16];
+ ConvertUInt32ToString(propID, s);
+ return s;
+}
+
+HRESULT CFieldPrinter::Init(IInArchive *archive)
+{
+ Clear();
+ UInt32 numProps;
+ RINOK(archive->GetNumberOfProperties(&numProps));
+ for (UInt32 i = 0; i < numProps; i++)
+ {
+ CMyComBSTR name;
+ PROPID propID;
+ VARTYPE vt;
+ RINOK(archive->GetPropertyInfo(i, &name, &propID, &vt));
+ CFieldInfo fieldInfo;
+ fieldInfo.PropID = propID;
+ fieldInfo.Name = GetPropName(propID, name);
+ _fields.Add(fieldInfo);
+ }
+ return S_OK;
+}
+
+void CFieldPrinter::PrintTitle()
+{
+ for (int i = 0; i < _fields.Size(); i++)
+ {
+ const CFieldInfo &fieldInfo = _fields[i];
+ PrintSpaces(fieldInfo.PrefixSpacesWidth);
+ PrintString(fieldInfo.TitleAdjustment,
+ ((fieldInfo.PropID == kpidPath) ? 0: fieldInfo.Width), fieldInfo.Name);
+ }
+}
+
+void CFieldPrinter::PrintTitleLines()
+{
+ for (int i = 0; i < _fields.Size(); i++)
+ {
+ const CFieldInfo &fieldInfo = _fields[i];
+ PrintSpaces(fieldInfo.PrefixSpacesWidth);
+ for (int i = 0; i < fieldInfo.Width; i++)
+ g_StdOut << '-';
+ }
+}
+
+
+static BOOL IsFileTimeZero(CONST FILETIME *lpFileTime)
+{
+ return (lpFileTime->dwLowDateTime == 0) && (lpFileTime->dwHighDateTime == 0);
+}
+
+static const char *kEmptyTimeString = " ";
+static void PrintTime(const NCOM::CPropVariant &prop)
+{
+ if (prop.vt != VT_FILETIME)
+ throw "incorrect item";
+ if (IsFileTimeZero(&prop.filetime))
+ g_StdOut << kEmptyTimeString;
+ else
+ {
+ FILETIME localFileTime;
+ if (!FileTimeToLocalFileTime(&prop.filetime, &localFileTime))
+ throw "FileTimeToLocalFileTime error";
+ char s[32];
+ if (ConvertFileTimeToString(localFileTime, s, true, true))
+ g_StdOut << s;
+ else
+ g_StdOut << kEmptyTimeString;
+ }
+}
+
+HRESULT CFieldPrinter::PrintItemInfo(const CArc &arc, UInt32 index, bool techMode)
+{
+ /*
+ if (techMode)
+ {
+ g_StdOut << "Index = ";
+ g_StdOut << (UInt64)index;
+ g_StdOut << endl;
+ }
+ */
+ for (int i = 0; i < _fields.Size(); i++)
+ {
+ const CFieldInfo &fieldInfo = _fields[i];
+ if (!techMode)
+ PrintSpaces(fieldInfo.PrefixSpacesWidth);
+
+ NCOM::CPropVariant prop;
+ if (fieldInfo.PropID == kpidPath)
+ {
+ UString s;
+ RINOK(arc.GetItemPath(index, s));
+ prop = s;
+ }
+ else
+ {
+ RINOK(arc.Archive->GetProperty(index, fieldInfo.PropID, &prop));
+ }
+ if (techMode)
+ {
+ g_StdOut << fieldInfo.Name << " = ";
+ }
+ int width = (fieldInfo.PropID == kpidPath) ? 0: fieldInfo.Width;
+ if (fieldInfo.PropID == kpidAttrib && (prop.vt == VT_EMPTY || prop.vt == VT_UI4))
+ {
+ UInt32 attrib = (prop.vt == VT_EMPTY) ? 0 : prop.ulVal;
+ bool isFolder;
+ RINOK(IsArchiveItemFolder(arc.Archive, index, isFolder));
+ char s[8];
+ GetAttribString(attrib, isFolder, s);
+ g_StdOut << s;
+ }
+ else if (prop.vt == VT_EMPTY)
+ {
+ if (!techMode)
+ PrintSpaces(width);
+ }
+ else if (fieldInfo.PropID == kpidMTime)
+ {
+ PrintTime(prop);
+ }
+ else if (prop.vt == VT_BSTR)
+ {
+ if (techMode)
+ g_StdOut << prop.bstrVal;
+ else
+ PrintString(fieldInfo.TextAdjustment, width, prop.bstrVal);
+ }
+ else
+ {
+ UString s = ConvertPropertyToString(prop, fieldInfo.PropID);
+ s.Replace(wchar_t(0xA), L' ');
+ s.Replace(wchar_t(0xD), L' ');
+
+ if (techMode)
+ g_StdOut << s;
+ else
+ PrintString(fieldInfo.TextAdjustment, width, s);
+ }
+ if (techMode)
+ g_StdOut << endl;
+ }
+ return S_OK;
+}
+
+static void PrintNumberString(EAdjustment adjustment, int width, const UInt64 *value)
+{
+ wchar_t textString[32] = { 0 };
+ if (value != NULL)
+ ConvertUInt64ToString(*value, textString);
+ PrintString(adjustment, width, textString);
+}
+
+
+HRESULT CFieldPrinter::PrintSummaryInfo(UInt64 numFiles, UInt64 numDirs,
+ const UInt64 *size, const UInt64 *compressedSize)
+{
+ for (int i = 0; i < _fields.Size(); i++)
+ {
+ const CFieldInfo &fieldInfo = _fields[i];
+ PrintSpaces(fieldInfo.PrefixSpacesWidth);
+ NCOM::CPropVariant prop;
+ if (fieldInfo.PropID == kpidSize)
+ PrintNumberString(fieldInfo.TextAdjustment, fieldInfo.Width, size);
+ else if (fieldInfo.PropID == kpidPackSize)
+ PrintNumberString(fieldInfo.TextAdjustment, fieldInfo.Width, compressedSize);
+ else if (fieldInfo.PropID == kpidPath)
+ {
+ wchar_t textString[32];
+ ConvertUInt64ToString(numFiles, textString);
+ UString temp = textString;
+ temp += L" ";
+ temp += kFilesMessage;
+ temp += L", ";
+ ConvertUInt64ToString(numDirs, textString);
+ temp += textString;
+ temp += L" ";
+ temp += kDirsMessage;
+ PrintString(fieldInfo.TextAdjustment, 0, temp);
+ }
+ else
+ PrintString(fieldInfo.TextAdjustment, fieldInfo.Width, L"");
+ }
+ return S_OK;
+}
+
+bool GetUInt64Value(IInArchive *archive, UInt32 index, PROPID propID, UInt64 &value)
+{
+ NCOM::CPropVariant prop;
+ if (archive->GetProperty(index, propID, &prop) != S_OK)
+ throw "GetPropertyValue error";
+ if (prop.vt == VT_EMPTY)
+ return false;
+ value = ConvertPropVariantToUInt64(prop);
+ return true;
+}
+
+static void PrintPropPair(const wchar_t *name, const wchar_t *value)
+{
+ g_StdOut << name << " = " << value << endl;
+}
+
+HRESULT ListArchives(CCodecs *codecs, const CIntVector &formatIndices,
+ bool stdInMode,
+ UStringVector &arcPaths, UStringVector &arcPathsFull,
+ const NWildcard::CCensorNode &wildcardCensor,
+ bool enableHeaders, bool techMode,
+ #ifndef _NO_CRYPTO
+ bool &passwordEnabled, UString &password,
+ #endif
+ UInt64 &numErrors)
+{
+ numErrors = 0;
+ CFieldPrinter fieldPrinter;
+ if (!techMode)
+ fieldPrinter.Init(kStandardFieldTable, sizeof(kStandardFieldTable) / sizeof(kStandardFieldTable[0]));
+
+ UInt64 numFiles2 = 0, numDirs2 = 0, totalPackSize2 = 0, totalUnPackSize2 = 0;
+ UInt64 *totalPackSizePointer2 = 0, *totalUnPackSizePointer2 = 0;
+ int numArcs = /* stdInMode ? 1 : */ arcPaths.Size();
+ for (int i = 0; i < numArcs; i++)
+ {
+ const UString &archiveName = arcPaths[i];
+ UInt64 arcPackSize = 0;
+ if (!stdInMode)
+ {
+ NFile::NFind::CFileInfoW fi;
+ if (!fi.Find(archiveName) || fi.IsDir())
+ {
+ g_StdOut << endl << "Error: " << archiveName << " is not file" << endl;
+ numErrors++;
+ continue;
+ }
+ arcPackSize = fi.Size;
+ }
+
+ CArchiveLink archiveLink;
+
+ COpenCallbackConsole openCallback;
+ openCallback.OutStream = &g_StdOut;
+
+ #ifndef _NO_CRYPTO
+
+ openCallback.PasswordIsDefined = passwordEnabled;
+ openCallback.Password = password;
+
+ #endif
+
+ HRESULT result = archiveLink.Open2(codecs, formatIndices, stdInMode, NULL, archiveName, &openCallback);
+ if (result != S_OK)
+ {
+ if (result == E_ABORT)
+ return result;
+ g_StdOut << endl << "Error: " << archiveName << ": ";
+ if (result == S_FALSE)
+ {
+ #ifndef _NO_CRYPTO
+ if (openCallback.Open_WasPasswordAsked())
+ g_StdOut << "Can not open encrypted archive. Wrong password?";
+ else
+ #endif
+ g_StdOut << "Can not open file as archive";
+ }
+ else if (result == E_OUTOFMEMORY)
+ g_StdOut << "Can't allocate required memory";
+ else
+ g_StdOut << NError::MyFormatMessage(result);
+ g_StdOut << endl;
+ numErrors++;
+ continue;
+ }
+
+ if (!stdInMode)
+ for (int v = 0; v < archiveLink.VolumePaths.Size(); v++)
+ {
+ int index = arcPathsFull.FindInSorted(archiveLink.VolumePaths[v]);
+ if (index >= 0 && index > i)
+ {
+ arcPaths.Delete(index);
+ arcPathsFull.Delete(index);
+ numArcs = arcPaths.Size();
+ }
+ }
+
+ if (enableHeaders)
+ {
+ g_StdOut << endl << kListing << archiveName << endl << endl;
+
+ for (int i = 0; i < archiveLink.Arcs.Size(); i++)
+ {
+ const CArc &arc = archiveLink.Arcs[i];
+
+ g_StdOut << "--\n";
+ PrintPropPair(L"Path", arc.Path);
+ PrintPropPair(L"Type", codecs->Formats[arc.FormatIndex].Name);
+ if (!arc.ErrorMessage.IsEmpty())
+ PrintPropPair(L"Error", arc.ErrorMessage);
+ UInt32 numProps;
+ IInArchive *archive = arc.Archive;
+ if (archive->GetNumberOfArchiveProperties(&numProps) == S_OK)
+ {
+ for (UInt32 j = 0; j < numProps; j++)
+ {
+ CMyComBSTR name;
+ PROPID propID;
+ VARTYPE vt;
+ RINOK(archive->GetArchivePropertyInfo(j, &name, &propID, &vt));
+ NCOM::CPropVariant prop;
+ RINOK(archive->GetArchiveProperty(propID, &prop));
+ UString s = ConvertPropertyToString(prop, propID);
+ if (!s.IsEmpty())
+ PrintPropPair(GetPropName(propID, name), s);
+ }
+ }
+ if (i != archiveLink.Arcs.Size() - 1)
+ {
+ UInt32 numProps;
+ g_StdOut << "----\n";
+ if (archive->GetNumberOfProperties(&numProps) == S_OK)
+ {
+ UInt32 mainIndex = archiveLink.Arcs[i + 1].SubfileIndex;
+ for (UInt32 j = 0; j < numProps; j++)
+ {
+ CMyComBSTR name;
+ PROPID propID;
+ VARTYPE vt;
+ RINOK(archive->GetPropertyInfo(j, &name, &propID, &vt));
+ NCOM::CPropVariant prop;
+ RINOK(archive->GetProperty(mainIndex, propID, &prop));
+ UString s = ConvertPropertyToString(prop, propID);
+ if (!s.IsEmpty())
+ PrintPropPair(GetPropName(propID, name), s);
+ }
+ }
+ }
+
+ }
+ g_StdOut << endl;
+ if (techMode)
+ g_StdOut << "----------\n";
+ }
+
+ if (enableHeaders && !techMode)
+ {
+ fieldPrinter.PrintTitle();
+ g_StdOut << endl;
+ fieldPrinter.PrintTitleLines();
+ g_StdOut << endl;
+ }
+
+ const CArc &arc = archiveLink.Arcs.Back();
+ IInArchive *archive = arc.Archive;
+ if (techMode)
+ {
+ RINOK(fieldPrinter.Init(archive));
+ }
+ UInt64 numFiles = 0, numDirs = 0, totalPackSize = 0, totalUnPackSize = 0;
+ UInt64 *totalPackSizePointer = 0, *totalUnPackSizePointer = 0;
+ UInt32 numItems;
+ RINOK(archive->GetNumberOfItems(&numItems));
+ for (UInt32 i = 0; i < numItems; i++)
+ {
+ if (NConsoleClose::TestBreakSignal())
+ return E_ABORT;
+
+ UString filePath;
+ HRESULT res = arc.GetItemPath(i, filePath);
+ if (stdInMode && res == E_INVALIDARG)
+ break;
+ RINOK(res);
+
+ bool isFolder;
+ RINOK(IsArchiveItemFolder(archive, i, isFolder));
+ if (!wildcardCensor.CheckPath(filePath, !isFolder))
+ continue;
+
+ fieldPrinter.PrintItemInfo(arc, i, techMode);
+
+ UInt64 packSize, unpackSize;
+ if (!GetUInt64Value(archive, i, kpidSize, unpackSize))
+ unpackSize = 0;
+ else
+ totalUnPackSizePointer = &totalUnPackSize;
+ if (!GetUInt64Value(archive, i, kpidPackSize, packSize))
+ packSize = 0;
+ else
+ totalPackSizePointer = &totalPackSize;
+
+ g_StdOut << endl;
+
+ if (isFolder)
+ numDirs++;
+ else
+ numFiles++;
+ totalPackSize += packSize;
+ totalUnPackSize += unpackSize;
+ }
+
+ if (!stdInMode && totalPackSizePointer == 0)
+ {
+ if (archiveLink.VolumePaths.Size() != 0)
+ arcPackSize += archiveLink.VolumesSize;
+ totalPackSize = (numFiles == 0) ? 0 : arcPackSize;
+ totalPackSizePointer = &totalPackSize;
+ }
+ if (totalUnPackSizePointer == 0 && numFiles == 0)
+ {
+ totalUnPackSize = 0;
+ totalUnPackSizePointer = &totalUnPackSize;
+ }
+ if (enableHeaders && !techMode)
+ {
+ fieldPrinter.PrintTitleLines();
+ g_StdOut << endl;
+ fieldPrinter.PrintSummaryInfo(numFiles, numDirs, totalUnPackSizePointer, totalPackSizePointer);
+ g_StdOut << endl;
+ }
+ if (totalPackSizePointer != 0)
+ {
+ totalPackSizePointer2 = &totalPackSize2;
+ totalPackSize2 += totalPackSize;
+ }
+ if (totalUnPackSizePointer != 0)
+ {
+ totalUnPackSizePointer2 = &totalUnPackSize2;
+ totalUnPackSize2 += totalUnPackSize;
+ }
+ numFiles2 += numFiles;
+ numDirs2 += numDirs;
+ }
+ if (enableHeaders && !techMode && numArcs > 1)
+ {
+ g_StdOut << endl;
+ fieldPrinter.PrintTitleLines();
+ g_StdOut << endl;
+ fieldPrinter.PrintSummaryInfo(numFiles2, numDirs2, totalUnPackSizePointer2, totalPackSizePointer2);
+ g_StdOut << endl;
+ g_StdOut << "Archives: " << numArcs << endl;
+ }
+ return S_OK;
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/List.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/List.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/List.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/List.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,20 @@
+// List.h
+
+#ifndef __LIST_H
+#define __LIST_H
+
+#include "Common/Wildcard.h"
+#include "../Common/LoadCodecs.h"
+
+HRESULT ListArchives(CCodecs *codecs, const CIntVector &formatIndices,
+ bool stdInMode,
+ UStringVector &archivePaths, UStringVector &archivePathsFull,
+ const NWildcard::CCensorNode &wildcardCensor,
+ bool enableHeaders, bool techMode,
+ #ifndef _NO_CRYPTO
+ bool &passwordEnabled, UString &password,
+ #endif
+ UInt64 &errors);
+
+#endif
+
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/Main.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/Main.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/Main.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/Main.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,628 @@
+// Main.cpp
+
+#include "StdAfx.h"
+
+#if defined( _7ZIP_LARGE_PAGES)
+#include "../../../../C/Alloc.h"
+#endif
+
+#include "Common/MyInitGuid.h"
+
+#include "Common/CommandLineParser.h"
+#include "Common/IntToString.h"
+#include "Common/MyException.h"
+#include "Common/StdOutStream.h"
+#include "Common/StringConvert.h"
+#include "Common/StringToInt.h"
+
+#include "Windows/Error.h"
+#ifdef _WIN32
+#include "Windows/MemoryLock.h"
+#endif
+
+#include "../Common/ArchiveCommandLine.h"
+#include "../Common/ExitCode.h"
+#include "../Common/Extract.h"
+#ifdef EXTERNAL_CODECS
+#include "../Common/LoadCodecs.h"
+#endif
+
+#include "BenchCon.h"
+#include "ExtractCallbackConsole.h"
+#include "List.h"
+#include "OpenCallbackConsole.h"
+#include "UpdateCallbackConsole.h"
+
+#include "../../MyVersion.h"
+
+#include "myPrivate.h"
+#include "Windows/System.h"
+
+using namespace NWindows;
+using namespace NFile;
+using namespace NCommandLineParser;
+
+// HINSTANCE g_hInstance = 0;
+extern CStdOutStream *g_StdStream;
+
+static const char *kCopyrightString = "\n7-Zip"
+#ifndef EXTERNAL_CODECS
+" (A)"
+#endif
+
+#ifdef _WIN64
+" [64]"
+#endif
+
+" " MY_VERSION_COPYRIGHT_DATE "\n"
+"p7zip Version " P7ZIP_VERSION ;
+
+static const char *kHelpString =
+ "\nUsage: 7z"
+#ifdef _NO_CRYPTO
+ "r"
+#else
+#ifndef EXTERNAL_CODECS
+ "a"
+#endif
+#endif
+ " <command> [<switches>...] <archive_name> [<file_names>...]\n"
+ " [<@listfiles...>]\n"
+ "\n"
+ "<Commands>\n"
+ " a: Add files to archive\n"
+ " b: Benchmark\n"
+ " d: Delete files from archive\n"
+ " e: Extract files from archive (without using directory names)\n"
+ " l: List contents of archive\n"
+// " l[a|t][f]: List contents of archive\n"
+// " a - with Additional fields\n"
+// " t - with all fields\n"
+// " f - with Full pathnames\n"
+ " t: Test integrity of archive\n"
+ " u: Update files to archive\n"
+ " x: eXtract files with full paths\n"
+ "<Switches>\n"
+ " -ai[r[-|0]]{@listfile|!wildcard}: Include archives\n"
+ " -ax[r[-|0]]{@listfile|!wildcard}: eXclude archives\n"
+ " -bd: Disable percentage indicator\n"
+ " -i[r[-|0]]{@listfile|!wildcard}: Include filenames\n"
+ " -m{Parameters}: set compression Method\n"
+ " -o{Directory}: set Output directory\n"
+ #ifndef _NO_CRYPTO
+ " -p{Password}: set Password\n"
+ #endif
+ " -r[-|0]: Recurse subdirectories\n"
+ " -scs{UTF-8 | WIN | DOS}: set charset for list files\n"
+ " -sfx[{name}]: Create SFX archive\n"
+ " -si[{name}]: read data from stdin\n"
+ " -slt: show technical information for l (List) command\n"
+ " -so: write data to stdout\n"
+ " -ssc[-]: set sensitive case mode\n"
+ " -t{Type}: Set type of archive\n"
+ " -u[-][p#][q#][r#][x#][y#][z#][!newArchiveName]: Update options\n"
+ " -v{Size}[b|k|m|g]: Create volumes\n"
+ " -w[{path}]: assign Work directory. Empty path means a temporary directory\n"
+ " -x[r[-|0]]]{@listfile|!wildcard}: eXclude filenames\n"
+ " -y: assume Yes on all queries\n";
+
+// ---------------------------
+// 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 wchar_t *kDefaultSfxModule = L"7zCon.sfx";
+
+static void ShowMessageAndThrowException(CStdOutStream &s, LPCSTR message, NExitCode::EEnum code)
+{
+ s << message << endl;
+ throw code;
+}
+
+static void PrintHelpAndExit(CStdOutStream &s)
+{
+ s << kHelpString;
+ ShowMessageAndThrowException(s, kUserErrorMessage, NExitCode::kUserError);
+}
+
+#ifndef _WIN32
+static void GetArguments(int numArgs, const char *args[], UStringVector &parts)
+{
+ parts.Clear();
+ for (int i = 0; i < numArgs; i++)
+ {
+ UString s = MultiByteToUnicodeString(args[i]);
+ parts.Add(s);
+ }
+}
+#endif
+
+static void ShowCopyrightAndHelp(CStdOutStream &s, bool needHelp)
+{
+ s << kCopyrightString << " (locale=" << my_getlocale() <<",Utf16=";
+ if (global_use_utf16_conversion) s << "on";
+ else s << "off";
+ s << ",HugeFiles=";
+ if (sizeof(off_t) >= 8) s << "on,";
+ else s << "off,";
+ int nbcpu = NWindows::NSystem::GetNumberOfProcessors();
+ if (nbcpu > 1) s << nbcpu << " CPUs)\n";
+ else s << nbcpu << " CPU)\n";
+
+ if (needHelp)
+ s << kHelpString;
+}
+
+#ifdef EXTERNAL_CODECS
+static void PrintString(CStdOutStream &stdStream, const AString &s, int size)
+{
+ int len = s.Length();
+ stdStream << s;
+ for (int i = len; i < size; i++)
+ stdStream << ' ';
+}
+#endif
+
+static void PrintString(CStdOutStream &stdStream, const UString &s, int size)
+{
+ int len = s.Length();
+ stdStream << s;
+ for (int i = len; i < size; i++)
+ stdStream << ' ';
+}
+
+static inline char GetHex(Byte value)
+{
+ return (char)((value < 10) ? ('0' + value) : ('A' + (value - 10)));
+}
+
+int Main2(
+ #ifndef _WIN32
+ int numArgs, const char *args[]
+ #endif
+)
+{
+ #if defined(_WIN32) && !defined(UNDER_CE)
+ SetFileApisToOEM();
+ #endif
+
+ UStringVector commandStrings;
+ #ifdef _WIN32
+ NCommandLineParser::SplitCommandLine(GetCommandLineW(), commandStrings);
+ #else
+ // GetArguments(numArgs, args, commandStrings);
+ extern void mySplitCommandLine(int numArgs,const char *args[],UStringVector &parts);
+ mySplitCommandLine(numArgs,args,commandStrings);
+ #endif
+
+ if (commandStrings.Size() == 1)
+ {
+ ShowCopyrightAndHelp(g_StdOut, true);
+ return 0;
+ }
+ commandStrings.Delete(0);
+
+ CArchiveCommandLineOptions options;
+
+ CArchiveCommandLineParser parser;
+
+ parser.Parse1(commandStrings, options);
+
+ if (options.HelpMode)
+ {
+ ShowCopyrightAndHelp(g_StdOut, true);
+ return 0;
+ }
+
+ #if defined(_7ZIP_LARGE_PAGES)
+ if (options.LargePages)
+ {
+ SetLargePageSize();
+#ifdef _WIN32
+ NSecurity::EnableLockMemoryPrivilege();
+#endif
+ }
+ #endif
+
+ CStdOutStream &stdStream = options.StdOutMode ? g_StdErr : g_StdOut;
+ g_StdStream = &stdStream;
+
+ if (options.EnableHeaders)
+ ShowCopyrightAndHelp(stdStream, false);
+
+ parser.Parse2(options);
+
+ CCodecs *codecs = new CCodecs;
+ CMyComPtr<
+ #ifdef EXTERNAL_CODECS
+ ICompressCodecsInfo
+ #else
+ IUnknown
+ #endif
+ > compressCodecsInfo = codecs;
+ HRESULT result = codecs->Load();
+ if (result != S_OK)
+ throw CSystemException(result);
+
+ bool isExtractGroupCommand = options.Command.IsFromExtractGroup();
+
+ if (codecs->Formats.Size() == 0 &&
+ (isExtractGroupCommand ||
+ options.Command.CommandType == NCommandType::kList ||
+ options.Command.IsFromUpdateGroup()))
+ throw kNoFormats;
+
+ CIntVector formatIndices;
+ if (!codecs->FindFormatForArchiveType(options.ArcType, formatIndices))
+ throw kUnsupportedArcTypeMessage;
+
+ if (options.Command.CommandType == NCommandType::kInfo)
+ {
+ stdStream << endl << "Formats:" << endl;
+ int i;
+ for (i = 0; i < codecs->Formats.Size(); i++)
+ {
+ const CArcInfoEx &arc = codecs->Formats[i];
+ #ifdef EXTERNAL_CODECS
+ if (arc.LibIndex >= 0)
+ {
+ char s[16];
+ ConvertUInt32ToString(arc.LibIndex, s);
+ PrintString(stdStream, s, 2);
+ }
+ else
+ #endif
+ stdStream << " ";
+ stdStream << ' ';
+ stdStream << (char)(arc.UpdateEnabled ? 'C' : ' ');
+ stdStream << (char)(arc.KeepName ? 'K' : ' ');
+ stdStream << " ";
+ PrintString(stdStream, arc.Name, 6);
+ stdStream << " ";
+ UString s;
+ for (int t = 0; t < arc.Exts.Size(); t++)
+ {
+ const CArcExtInfo &ext = arc.Exts[t];
+ s += ext.Ext;
+ if (!ext.AddExt.IsEmpty())
+ {
+ s += L" (";
+ s += ext.AddExt;
+ s += L')';
+ }
+ s += L' ';
+ }
+ PrintString(stdStream, s, 14);
+ stdStream << " ";
+ const CByteBuffer &sig = arc.StartSignature;
+ for (size_t j = 0; j < sig.GetCapacity(); j++)
+ {
+ Byte b = sig[j];
+ if (b > 0x20 && b < 0x80)
+ {
+ stdStream << (char)b;
+ }
+ else
+ {
+ stdStream << GetHex((Byte)((b >> 4) & 0xF));
+ stdStream << GetHex((Byte)(b & 0xF));
+ }
+ stdStream << ' ';
+ }
+ stdStream << endl;
+ }
+ stdStream << endl << "Codecs:" << endl;
+
+ #ifdef EXTERNAL_CODECS
+ UInt32 numMethods;
+ if (codecs->GetNumberOfMethods(&numMethods) == S_OK)
+ for (UInt32 j = 0; j < numMethods; j++)
+ {
+ int libIndex = codecs->GetCodecLibIndex(j);
+ if (libIndex >= 0)
+ {
+ char s[16];
+ ConvertUInt32ToString(libIndex, s);
+ PrintString(stdStream, s, 2);
+ }
+ else
+ stdStream << " ";
+ stdStream << ' ';
+ stdStream << (char)(codecs->GetCodecEncoderIsAssigned(j) ? 'C' : ' ');
+ UInt64 id;
+ stdStream << " ";
+ HRESULT res = codecs->GetCodecId(j, id);
+ if (res != S_OK)
+ id = (UInt64)(Int64)-1;
+ char s[32];
+ ConvertUInt64ToString(id, s, 16);
+ PrintString(stdStream, s, 8);
+ stdStream << " ";
+ PrintString(stdStream, codecs->GetCodecName(j), 11);
+ stdStream << endl;
+ /*
+ if (res != S_OK)
+ throw "incorrect Codec ID";
+ */
+ }
+ #endif
+ return S_OK;
+ }
+ else if (options.Command.CommandType == NCommandType::kBenchmark)
+ {
+ if (options.Method.CompareNoCase(L"CRC") == 0)
+ {
+ HRESULT res = CrcBenchCon((FILE *)stdStream, options.NumIterations, options.NumThreads, options.DictionarySize);
+ if (res != S_OK)
+ {
+ if (res == S_FALSE)
+ {
+ stdStream << "\nCRC Error\n";
+ return NExitCode::kFatalError;
+ }
+ throw CSystemException(res);
+ }
+ }
+ else
+ {
+ HRESULT res;
+ #ifdef EXTERNAL_CODECS
+ CObjectVector<CCodecInfoEx> externalCodecs;
+ res = LoadExternalCodecs(compressCodecsInfo, externalCodecs);
+ if (res != S_OK)
+ throw CSystemException(res);
+ #endif
+ res = LzmaBenchCon(
+ #ifdef EXTERNAL_CODECS
+ compressCodecsInfo, &externalCodecs,
+ #endif
+ (FILE *)stdStream, options.NumIterations, options.NumThreads, options.DictionarySize);
+ if (res != S_OK)
+ {
+ if (res == S_FALSE)
+ {
+ stdStream << "\nDecoding Error\n";
+ return NExitCode::kFatalError;
+ }
+ throw CSystemException(res);
+ }
+ }
+ }
+ else if (isExtractGroupCommand || options.Command.CommandType == NCommandType::kList)
+ {
+ if (isExtractGroupCommand)
+ {
+ CExtractCallbackConsole *ecs = new CExtractCallbackConsole;
+ CMyComPtr<IFolderArchiveExtractCallback> extractCallback = ecs;
+
+ ecs->OutStream = &stdStream;
+
+ #ifndef _NO_CRYPTO
+ ecs->PasswordIsDefined = options.PasswordEnabled;
+ ecs->Password = options.Password;
+ #endif
+
+ ecs->Init();
+
+ COpenCallbackConsole openCallback;
+ openCallback.OutStream = &stdStream;
+
+ #ifndef _NO_CRYPTO
+ openCallback.PasswordIsDefined = options.PasswordEnabled;
+ openCallback.Password = options.Password;
+ #endif
+
+ CExtractOptions eo;
+ eo.StdInMode = options.StdInMode;
+ eo.StdOutMode = options.StdOutMode;
+ eo.PathMode = options.Command.GetPathMode();
+ eo.TestMode = options.Command.IsTestMode();
+ eo.OverwriteMode = options.OverwriteMode;
+ eo.OutputDir = options.OutputDir;
+ eo.YesToAll = options.YesToAll;
+ eo.CalcCrc = options.CalcCrc;
+ #if !defined(_7ZIP_ST) && !defined(_SFX)
+ eo.Properties = options.ExtractProperties;
+ #endif
+ UString errorMessage;
+ CDecompressStat stat;
+ HRESULT result = DecompressArchives(
+ codecs,
+ formatIndices,
+ options.ArchivePathsSorted,
+ options.ArchivePathsFullSorted,
+ options.WildcardCensor.Pairs.Front().Head,
+ eo, &openCallback, ecs, errorMessage, stat);
+ if (!errorMessage.IsEmpty())
+ {
+ stdStream << endl << "Error: " << errorMessage;
+ if (result == S_OK)
+ result = E_FAIL;
+ }
+
+ stdStream << endl;
+ if (ecs->NumArchives > 1)
+ stdStream << "Archives: " << ecs->NumArchives << endl;
+ if (ecs->NumArchiveErrors != 0 || ecs->NumFileErrors != 0)
+ {
+ if (ecs->NumArchives > 1)
+ {
+ stdStream << endl;
+ if (ecs->NumArchiveErrors != 0)
+ stdStream << "Archive Errors: " << ecs->NumArchiveErrors << endl;
+ if (ecs->NumFileErrors != 0)
+ stdStream << "Sub items Errors: " << ecs->NumFileErrors << endl;
+ }
+ if (result != S_OK)
+ throw CSystemException(result);
+ return NExitCode::kFatalError;
+ }
+ if (result != S_OK)
+ throw CSystemException(result);
+ if (stat.NumFolders != 0)
+ stdStream << "Folders: " << stat.NumFolders << endl;
+ if (stat.NumFiles != 1 || stat.NumFolders != 0)
+ stdStream << "Files: " << stat.NumFiles << endl;
+ stdStream
+ << "Size: " << stat.UnpackSize << endl
+ << "Compressed: " << stat.PackSize << endl;
+ if (options.CalcCrc)
+ {
+ char s[16];
+ ConvertUInt32ToHexWithZeros(stat.CrcSum, s);
+ stdStream << "CRC: " << s << endl;
+ }
+ }
+ else
+ {
+ UInt64 numErrors = 0;
+ HRESULT result = ListArchives(
+ codecs,
+ formatIndices,
+ options.StdInMode,
+ options.ArchivePathsSorted,
+ options.ArchivePathsFullSorted,
+ options.WildcardCensor.Pairs.Front().Head,
+ options.EnableHeaders,
+ options.TechMode,
+ #ifndef _NO_CRYPTO
+ options.PasswordEnabled,
+ options.Password,
+ #endif
+ numErrors);
+ if (numErrors > 0)
+ {
+ g_StdOut << endl << "Errors: " << numErrors;
+ return NExitCode::kFatalError;
+ }
+ if (result != S_OK)
+ throw CSystemException(result);
+ }
+ }
+ else if (options.Command.IsFromUpdateGroup())
+ {
+ CUpdateOptions &uo = options.UpdateOptions;
+ if (uo.SfxMode && uo.SfxModule.IsEmpty())
+ uo.SfxModule = kDefaultSfxModule;
+
+ COpenCallbackConsole openCallback;
+ openCallback.OutStream = &stdStream;
+
+ #ifndef _NO_CRYPTO
+ bool passwordIsDefined =
+ options.PasswordEnabled && !options.Password.IsEmpty();
+ openCallback.PasswordIsDefined = passwordIsDefined;
+ openCallback.Password = options.Password;
+ #endif
+
+ CUpdateCallbackConsole callback;
+ callback.EnablePercents = options.EnablePercents;
+
+ #ifndef _NO_CRYPTO
+ callback.PasswordIsDefined = passwordIsDefined;
+ callback.AskPassword = options.PasswordEnabled && options.Password.IsEmpty();
+ callback.Password = options.Password;
+ #endif
+ callback.StdOutMode = uo.StdOutMode;
+ callback.Init(&stdStream);
+
+ CUpdateErrorInfo errorInfo;
+
+ if (!uo.Init(codecs, formatIndices, options.ArchiveName))
+ throw kUnsupportedArcTypeMessage;
+ HRESULT result = UpdateArchive(codecs,
+ options.WildcardCensor, uo,
+ errorInfo, &openCallback, &callback);
+
+#ifdef ENV_UNIX
+ if (uo.SfxMode)
+ {
+ void myAddExeFlag(const UString &name);
+ for(int i = 0; i < uo.Commands.Size(); i++)
+ {
+ CUpdateArchiveCommand &command = uo.Commands[i];
+ if (!uo.StdOutMode)
+ {
+ myAddExeFlag(command.ArchivePath.GetFinalPath());
+ }
+ }
+ }
+#endif
+
+ int exitCode = NExitCode::kSuccess;
+ if (callback.CantFindFiles.Size() > 0)
+ {
+ stdStream << endl;
+ stdStream << "WARNINGS for files:" << endl << endl;
+ int numErrors = callback.CantFindFiles.Size();
+ for (int i = 0; i < numErrors; i++)
+ {
+ stdStream << callback.CantFindFiles[i] << " : ";
+ stdStream << NError::MyFormatMessageW(callback.CantFindCodes[i]) << endl;
+ }
+ stdStream << "----------------" << endl;
+ stdStream << "WARNING: Cannot find " << numErrors << " file";
+ if (numErrors > 1)
+ stdStream << "s";
+ stdStream << endl;
+ exitCode = NExitCode::kWarning;
+ }
+
+ if (result != S_OK)
+ {
+ UString message;
+ if (!errorInfo.Message.IsEmpty())
+ {
+ message += errorInfo.Message;
+ message += L"\n";
+ }
+ if (!errorInfo.FileName.IsEmpty())
+ {
+ message += errorInfo.FileName;
+ message += L"\n";
+ }
+ if (!errorInfo.FileName2.IsEmpty())
+ {
+ message += errorInfo.FileName2;
+ message += L"\n";
+ }
+ if (errorInfo.SystemError != 0)
+ {
+ message += NError::MyFormatMessageW(errorInfo.SystemError);
+ message += L"\n";
+ }
+ if (!message.IsEmpty())
+ stdStream << L"\nError:\n" << message;
+ throw CSystemException(result);
+ }
+ int numErrors = callback.FailedFiles.Size();
+ if (numErrors == 0)
+ {
+ if (callback.CantFindFiles.Size() == 0)
+ stdStream << kEverythingIsOk << endl;
+ }
+ else
+ {
+ stdStream << endl;
+ stdStream << "WARNINGS for files:" << endl << endl;
+ for (int i = 0; i < numErrors; i++)
+ {
+ stdStream << callback.FailedFiles[i] << " : ";
+ stdStream << NError::MyFormatMessageW(callback.FailedCodes[i]) << endl;
+ }
+ stdStream << "----------------" << endl;
+ stdStream << "WARNING: Cannot open " << numErrors << " file";
+ if (numErrors > 1)
+ stdStream << "s";
+ stdStream << endl;
+ exitCode = NExitCode::kWarning;
+ }
+ return exitCode;
+ }
+ else
+ PrintHelpAndExit(stdStream);
+ return 0;
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/MainAr.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/MainAr.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/MainAr.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/MainAr.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,127 @@
+// MainAr.cpp
+
+#include "StdAfx.h"
+
+#include "Common/NewHandler.h" // FIXME
+
+#include "Common/MyException.h"
+#include "Common/StdOutStream.h"
+
+#include "Windows/Error.h"
+#include "Windows/NtCheck.h"
+
+#include "../Common/ArchiveCommandLine.h"
+#include "../Common/ExitCode.h"
+
+#include "ConsoleClose.h"
+
+using namespace NWindows;
+
+CStdOutStream *g_StdStream = 0;
+
+extern int Main2(
+ #ifndef _WIN32
+ int numArgs, const char *args[]
+ #endif
+);
+
+static const char *kExceptionErrorMessage = "\n\nError:\n";
+static const char *kUserBreak = "\nBreak signaled\n";
+static const char *kMemoryExceptionMessage = "\n\nERROR: Can't allocate required memory!\n";
+static const char *kUnknownExceptionMessage = "\n\nUnknown Error\n";
+static const char *kInternalExceptionMessage = "\n\nInternal Error #";
+
+#define NT_CHECK_FAIL_ACTION (*g_StdStream) << "Unsupported Windows version"; return NExitCode::kFatalError;
+
+int MY_CDECL main
+(
+ #ifndef _WIN32
+ int numArgs, const char *args[]
+ #endif
+)
+{
+ g_StdStream = &g_StdOut;
+
+ NT_CHECK
+
+ NConsoleClose::CCtrlHandlerSetter ctrlHandlerSetter;
+ int res = 0;
+ try
+ {
+ res = Main2(
+ #ifndef _WIN32
+ numArgs, args
+ #endif
+ );
+ }
+ catch(const CNewException &)
+ {
+ (*g_StdStream) << kMemoryExceptionMessage;
+ return (NExitCode::kMemoryError);
+ }
+ catch(const NConsoleClose::CCtrlBreakException &)
+ {
+ (*g_StdStream) << endl << kUserBreak;
+ return (NExitCode::kUserBreak);
+ }
+ catch(const CArchiveCommandLineException &e)
+ {
+ (*g_StdStream) << kExceptionErrorMessage << e << endl;
+ return (NExitCode::kUserError);
+ }
+ catch(const CSystemException &systemError)
+ {
+ if (systemError.ErrorCode == E_OUTOFMEMORY)
+ {
+ (*g_StdStream) << kMemoryExceptionMessage;
+ return (NExitCode::kMemoryError);
+ }
+ if (systemError.ErrorCode == E_ABORT)
+ {
+ (*g_StdStream) << endl << kUserBreak;
+ return (NExitCode::kUserBreak);
+ }
+ UString message;
+ NError::MyFormatMessage(systemError.ErrorCode, message);
+ (*g_StdStream) << endl << endl << "System error:" << endl << message << endl;
+ return (NExitCode::kFatalError);
+ }
+ catch(NExitCode::EEnum &exitCode)
+ {
+ (*g_StdStream) << kInternalExceptionMessage << exitCode << endl;
+ return (exitCode);
+ }
+ /*
+ catch(const NExitCode::CMultipleErrors &multipleErrors)
+ {
+ (*g_StdStream) << endl << multipleErrors.NumErrors << " errors" << endl;
+ return (NExitCode::kFatalError);
+ }
+ */
+ catch(const UString &s)
+ {
+ (*g_StdStream) << kExceptionErrorMessage << s << endl;
+ return (NExitCode::kFatalError);
+ }
+ catch(const AString &s)
+ {
+ (*g_StdStream) << kExceptionErrorMessage << s << endl;
+ return (NExitCode::kFatalError);
+ }
+ catch(const char *s)
+ {
+ (*g_StdStream) << kExceptionErrorMessage << s << endl;
+ return (NExitCode::kFatalError);
+ }
+ catch(int t)
+ {
+ (*g_StdStream) << kInternalExceptionMessage << t << endl;
+ return (NExitCode::kFatalError);
+ }
+ catch(...)
+ {
+ (*g_StdStream) << kUnknownExceptionMessage;
+ return (NExitCode::kFatalError);
+ }
+ return res;
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/OpenCallbackConsole.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/OpenCallbackConsole.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/OpenCallbackConsole.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/OpenCallbackConsole.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,58 @@
+// OpenCallbackConsole.cpp
+
+#include "StdAfx.h"
+
+#include "OpenCallbackConsole.h"
+
+#include "ConsoleClose.h"
+#include "UserInputUtils.h"
+
+HRESULT COpenCallbackConsole::Open_CheckBreak()
+{
+ if (NConsoleClose::TestBreakSignal())
+ return E_ABORT;
+ return S_OK;
+}
+
+HRESULT COpenCallbackConsole::Open_SetTotal(const UInt64 *, const UInt64 *)
+{
+ return Open_CheckBreak();
+}
+
+HRESULT COpenCallbackConsole::Open_SetCompleted(const UInt64 *, const UInt64 *)
+{
+ return Open_CheckBreak();
+}
+
+#ifndef _NO_CRYPTO
+
+HRESULT COpenCallbackConsole::Open_CryptoGetTextPassword(BSTR *password)
+{
+ PasswordWasAsked = true;
+ RINOK(Open_CheckBreak());
+ if (!PasswordIsDefined)
+ {
+ Password = GetPassword(OutStream);
+ PasswordIsDefined = true;
+ }
+ return StringToBstr(Password, password);
+}
+
+HRESULT COpenCallbackConsole::Open_GetPasswordIfAny(UString &password)
+{
+ if (PasswordIsDefined)
+ password = Password;
+ return S_OK;
+}
+
+bool COpenCallbackConsole::Open_WasPasswordAsked()
+{
+ return PasswordWasAsked;
+}
+
+void COpenCallbackConsole::Open_ClearPasswordWasAskedFlag()
+{
+ PasswordWasAsked = false;
+}
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/OpenCallbackConsole.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/OpenCallbackConsole.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/OpenCallbackConsole.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/OpenCallbackConsole.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,24 @@
+// OpenCallbackConsole.h
+
+#ifndef __OPENCALLBACKCONSOLE_H
+#define __OPENCALLBACKCONSOLE_H
+
+#include "Common/StdOutStream.h"
+#include "../Common/ArchiveOpenCallback.h"
+
+class COpenCallbackConsole: public IOpenCallbackUI
+{
+public:
+ INTERFACE_IOpenCallbackUI(;)
+
+ CStdOutStream *OutStream;
+
+ #ifndef _NO_CRYPTO
+ bool PasswordIsDefined;
+ bool PasswordWasAsked;
+ UString Password;
+ COpenCallbackConsole(): PasswordIsDefined(false), PasswordWasAsked(false) {}
+ #endif
+};
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/PercentPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/PercentPrinter.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/PercentPrinter.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/PercentPrinter.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,90 @@
+// PercentPrinter.cpp
+
+#include "StdAfx.h"
+
+#include "Common/IntToString.h"
+#include "Common/MyString.h"
+
+#include "PercentPrinter.h"
+
+const int kPaddingSize = 2;
+const int kPercentsSize = 4;
+const int kMaxExtraSize = kPaddingSize + 32 + kPercentsSize;
+
+static void ClearPrev(char *p, int num)
+{
+ int i;
+ for (i = 0; i < num; i++) *p++ = '\b';
+ for (i = 0; i < num; i++) *p++ = ' ';
+ for (i = 0; i < num; i++) *p++ = '\b';
+ *p = '\0';
+}
+
+void CPercentPrinter::ClosePrint()
+{
+ if (m_NumExtraChars == 0)
+ return;
+ char s[kMaxExtraSize * 3 + 1];
+ ClearPrev(s, m_NumExtraChars);
+ (*OutStream) << s;
+ m_NumExtraChars = 0;
+}
+
+void CPercentPrinter::PrintString(const char *s)
+{
+ ClosePrint();
+ (*OutStream) << s;
+}
+
+void CPercentPrinter::PrintString(const wchar_t *s)
+{
+ ClosePrint();
+ (*OutStream) << s;
+}
+
+void CPercentPrinter::PrintNewLine()
+{
+ ClosePrint();
+ (*OutStream) << "\n";
+}
+
+void CPercentPrinter::RePrintRatio()
+{
+ char s[32];
+ ConvertUInt64ToString(((m_Total == 0) ? 0 : (m_CurValue * 100 / m_Total)), s);
+ int size = (int)strlen(s);
+ s[size++] = '%';
+ s[size] = '\0';
+
+ int extraSize = kPaddingSize + MyMax(size, kPercentsSize);
+ if (extraSize < m_NumExtraChars)
+ extraSize = m_NumExtraChars;
+
+ char fullString[kMaxExtraSize * 3];
+ char *p = fullString;
+ int i;
+ if (m_NumExtraChars == 0)
+ {
+ for (i = 0; i < extraSize; i++)
+ *p++ = ' ';
+ m_NumExtraChars = extraSize;
+ }
+
+ for (i = 0; i < m_NumExtraChars; i++)
+ *p++ = '\b';
+ m_NumExtraChars = extraSize;
+ for (; size < m_NumExtraChars; size++)
+ *p++ = ' ';
+ MyStringCopy(p, s);
+ (*OutStream) << fullString;
+ OutStream->Flush();
+ m_PrevValue = m_CurValue;
+}
+
+void CPercentPrinter::PrintRatio()
+{
+ if (m_CurValue < m_PrevValue + m_MinStepSize &&
+ m_CurValue + m_MinStepSize > m_PrevValue && m_NumExtraChars != 0)
+ return;
+ RePrintRatio();
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/PercentPrinter.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/PercentPrinter.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/PercentPrinter.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/PercentPrinter.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,31 @@
+// PercentPrinter.h
+
+#ifndef __PERCENTPRINTER_H
+#define __PERCENTPRINTER_H
+
+#include "Common/Types.h"
+#include "Common/StdOutStream.h"
+
+class CPercentPrinter
+{
+ UInt64 m_MinStepSize;
+ UInt64 m_PrevValue;
+ UInt64 m_CurValue;
+ UInt64 m_Total;
+ int m_NumExtraChars;
+public:
+ CStdOutStream *OutStream;
+
+ CPercentPrinter(UInt64 minStepSize = 1): m_MinStepSize(minStepSize),
+ m_PrevValue(0), m_CurValue(0), m_Total(1), m_NumExtraChars(0) {}
+ void SetTotal(UInt64 total) { m_Total = total; m_PrevValue = 0; }
+ void SetRatio(UInt64 doneValue) { m_CurValue = doneValue; }
+ void PrintString(const char *s);
+ void PrintString(const wchar_t *s);
+ void PrintNewLine();
+ void ClosePrint();
+ void RePrintRatio();
+ void PrintRatio();
+};
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/UpdateCallbackConsole.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/UpdateCallbackConsole.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/UpdateCallbackConsole.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/UpdateCallbackConsole.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,261 @@
+// UpdateCallbackConsole.cpp
+
+#include "StdAfx.h"
+
+#include "UpdateCallbackConsole.h"
+
+#include "Windows/Error.h"
+#ifndef _7ZIP_ST
+#include "Windows/Synchronization.h"
+#endif
+
+#include "ConsoleClose.h"
+#include "UserInputUtils.h"
+
+using namespace NWindows;
+
+#ifndef _7ZIP_ST
+static NSynchronization::CCriticalSection g_CriticalSection;
+#define MT_LOCK NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
+#else
+#define MT_LOCK
+#endif
+
+static const wchar_t *kEmptyFileAlias = L"[Content]";
+
+static const char *kCreatingArchiveMessage = "Creating archive ";
+static const char *kUpdatingArchiveMessage = "Updating archive ";
+static const char *kScanningMessage = "Scanning";
+
+
+HRESULT CUpdateCallbackConsole::OpenResult(const wchar_t *name, HRESULT result)
+{
+ (*OutStream) << endl;
+ if (result != S_OK)
+ (*OutStream) << "Error: " << name << " is not supported archive" << endl;
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackConsole::StartScanning()
+{
+ (*OutStream) << kScanningMessage;
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackConsole::ScanProgress(UInt64 /* numFolders */, UInt64 /* numFiles */, const wchar_t * /* path */)
+{
+ return CheckBreak();
+}
+
+HRESULT CUpdateCallbackConsole::CanNotFindError(const wchar_t *name, DWORD systemError)
+{
+ CantFindFiles.Add(name);
+ CantFindCodes.Add(systemError);
+ // m_PercentPrinter.ClosePrint();
+ if (!m_WarningsMode)
+ {
+ (*OutStream) << endl << endl;
+ m_PercentPrinter.PrintNewLine();
+ m_WarningsMode = true;
+ }
+ m_PercentPrinter.PrintString(name);
+ m_PercentPrinter.PrintString(": WARNING: ");
+ m_PercentPrinter.PrintString(NError::MyFormatMessageW(systemError));
+ m_PercentPrinter.PrintNewLine();
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackConsole::FinishScanning()
+{
+ (*OutStream) << endl << endl;
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackConsole::StartArchive(const wchar_t *name, bool updating)
+{
+ if(updating)
+ (*OutStream) << kUpdatingArchiveMessage;
+ else
+ (*OutStream) << kCreatingArchiveMessage;
+ if (name != 0)
+ (*OutStream) << name;
+ else
+ (*OutStream) << "StdOut";
+ (*OutStream) << endl << endl;
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackConsole::FinishArchive()
+{
+ (*OutStream) << endl;
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackConsole::CheckBreak()
+{
+ if (NConsoleClose::TestBreakSignal())
+ return E_ABORT;
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackConsole::Finilize()
+{
+ MT_LOCK
+ if (m_NeedBeClosed)
+ {
+ if (EnablePercents)
+ {
+ m_PercentPrinter.ClosePrint();
+ }
+ if (!StdOutMode && m_NeedNewLine)
+ {
+ m_PercentPrinter.PrintNewLine();
+ m_NeedNewLine = false;
+ }
+ m_NeedBeClosed = false;
+ }
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackConsole::SetNumFiles(UInt64 /* numFiles */)
+{
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackConsole::SetTotal(UInt64 size)
+{
+ MT_LOCK
+ if (EnablePercents)
+ m_PercentPrinter.SetTotal(size);
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackConsole::SetCompleted(const UInt64 *completeValue)
+{
+ MT_LOCK
+ if (completeValue != NULL)
+ {
+ if (EnablePercents)
+ {
+ m_PercentPrinter.SetRatio(*completeValue);
+ m_PercentPrinter.PrintRatio();
+ m_NeedBeClosed = true;
+ }
+ }
+ if (NConsoleClose::TestBreakSignal())
+ return E_ABORT;
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackConsole::SetRatioInfo(const UInt64 * /* inSize */, const UInt64 * /* outSize */)
+{
+ if (NConsoleClose::TestBreakSignal())
+ return E_ABORT;
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackConsole::GetStream(const wchar_t *name, bool isAnti)
+{
+ MT_LOCK
+ if (StdOutMode)
+ return S_OK;
+ if(isAnti)
+ m_PercentPrinter.PrintString("Anti item ");
+ else
+ m_PercentPrinter.PrintString("Compressing ");
+ if (name[0] == 0)
+ name = kEmptyFileAlias;
+ m_PercentPrinter.PrintString(name);
+ if (EnablePercents)
+ m_PercentPrinter.RePrintRatio();
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackConsole::OpenFileError(const wchar_t *name, DWORD systemError)
+{
+ MT_LOCK
+ FailedCodes.Add(systemError);
+ FailedFiles.Add(name);
+ // if (systemError == ERROR_SHARING_VIOLATION)
+ {
+ m_PercentPrinter.ClosePrint();
+ m_PercentPrinter.PrintNewLine();
+ m_PercentPrinter.PrintString("WARNING: ");
+ m_PercentPrinter.PrintString(NError::MyFormatMessageW(systemError));
+ return S_FALSE;
+ }
+ // return systemError;
+}
+
+HRESULT CUpdateCallbackConsole::SetOperationResult(Int32 )
+{
+ m_NeedBeClosed = true;
+ m_NeedNewLine = true;
+ return S_OK;
+}
+
+HRESULT CUpdateCallbackConsole::CryptoGetTextPassword2(Int32 *passwordIsDefined, BSTR *password)
+{
+ *password = NULL;
+
+ #ifdef _NO_CRYPTO
+
+ *passwordIsDefined = false;
+ return S_OK;
+
+ #else
+
+ if (!PasswordIsDefined)
+ {
+ if (AskPassword)
+ {
+ Password = GetPassword(OutStream,true);
+ PasswordIsDefined = true;
+ }
+ }
+ *passwordIsDefined = BoolToInt(PasswordIsDefined);
+ return StringToBstr(Password, password);
+
+ #endif
+}
+
+HRESULT CUpdateCallbackConsole::CryptoGetTextPassword(BSTR *password)
+{
+ *password = NULL;
+
+ #ifdef _NO_CRYPTO
+
+ return E_NOTIMPL;
+
+ #else
+
+ if (!PasswordIsDefined)
+ {
+ {
+ Password = GetPassword(OutStream);
+ PasswordIsDefined = true;
+ }
+ }
+ return StringToBstr(Password, password);
+
+ #endif
+}
+
+/*
+HRESULT CUpdateCallbackConsole::ShowDeleteFile(const wchar_t *name)
+{
+ // MT_LOCK
+ if (StdOutMode)
+ return S_OK;
+ RINOK(Finilize());
+ m_PercentPrinter.PrintString("Deleting ");
+ if (name[0] == 0)
+ name = kEmptyFileAlias;
+ m_PercentPrinter.PrintString(name);
+ if (EnablePercents)
+ m_PercentPrinter.RePrintRatio();
+ m_NeedBeClosed = true;
+ m_NeedNewLine = true;
+ return S_OK;
+}
+*/
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/UpdateCallbackConsole.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/UpdateCallbackConsole.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/UpdateCallbackConsole.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/UpdateCallbackConsole.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,62 @@
+// UpdateCallbackConsole.h
+
+#ifndef __UPDATE_CALLBACK_CONSOLE_H
+#define __UPDATE_CALLBACK_CONSOLE_H
+
+#include "Common/StdOutStream.h"
+
+#include "../Common/Update.h"
+
+#include "PercentPrinter.h"
+
+class CUpdateCallbackConsole: public IUpdateCallbackUI2
+{
+ CPercentPrinter m_PercentPrinter;
+ bool m_NeedBeClosed;
+ bool m_NeedNewLine;
+
+ bool m_WarningsMode;
+
+ CStdOutStream *OutStream;
+public:
+ bool EnablePercents;
+ bool StdOutMode;
+
+ #ifndef _NO_CRYPTO
+ bool PasswordIsDefined;
+ UString Password;
+ bool AskPassword;
+ #endif
+
+ CUpdateCallbackConsole():
+ m_PercentPrinter(1 << 16),
+ #ifndef _NO_CRYPTO
+ PasswordIsDefined(false),
+ AskPassword(false),
+ #endif
+ StdOutMode(false),
+ EnablePercents(true),
+ m_WarningsMode(false)
+ {}
+
+ ~CUpdateCallbackConsole() { Finilize(); }
+ void Init(CStdOutStream *outStream)
+ {
+ m_NeedBeClosed = false;
+ m_NeedNewLine = false;
+ FailedFiles.Clear();
+ FailedCodes.Clear();
+ OutStream = outStream;
+ m_PercentPrinter.OutStream = outStream;
+ }
+
+ INTERFACE_IUpdateCallbackUI2(;)
+
+ UStringVector FailedFiles;
+ CRecordVector<HRESULT> FailedCodes;
+
+ UStringVector CantFindFiles;
+ CRecordVector<HRESULT> CantFindCodes;
+};
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/UserInputUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/UserInputUtils.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/UserInputUtils.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/UserInputUtils.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,96 @@
+// UserInputUtils.cpp
+
+#include "StdAfx.h"
+
+#include "Common/StdInStream.h"
+#include "Common/StringConvert.h"
+
+#include "UserInputUtils.h"
+
+#ifdef USE_FLTK
+// the programs like file-roller or xarchiver do not support archives with password
+// these programs freeze because p7zip is waiting for a password
+// defining USE_FLTK allows p7zip to use a popup in order to ask the password.
+#include <FL/Fl.H>
+#include <FL/Fl_Window.H>
+#include <FL/fl_ask.H>
+#else
+#ifdef ENV_HAVE_GETPASS
+#include <pwd.h>
+#include <unistd.h>
+#include "Common/MyException.h"
+#endif
+#endif
+
+static const char kYes = 'Y';
+static const char kNo = 'N';
+static const char kYesAll = 'A';
+static const char kNoAll = 'S';
+static const char kAutoRenameAll = 'U';
+static const char kQuit = 'Q';
+
+static const char *kFirstQuestionMessage = "?\n";
+static const char *kHelpQuestionMessage =
+ "(Y)es / (N)o / (A)lways / (S)kip all / A(u)to rename all / (Q)uit? ";
+
+// return true if pressed Quite;
+
+NUserAnswerMode::EEnum ScanUserYesNoAllQuit(CStdOutStream *outStream)
+{
+ (*outStream) << kFirstQuestionMessage;
+ for (;;)
+ {
+ (*outStream) << kHelpQuestionMessage;
+ outStream->Flush();
+ AString scannedString = g_StdIn.ScanStringUntilNewLine();
+ scannedString.Trim();
+ if (!scannedString.IsEmpty())
+ switch(
+ ::MyCharUpper(
+ #ifdef UNDER_CE
+ (wchar_t)
+ #endif
+ scannedString[0]))
+ {
+ case kYes:
+ return NUserAnswerMode::kYes;
+ case kNo:
+ return NUserAnswerMode::kNo;
+ case kYesAll:
+ return NUserAnswerMode::kYesAll;
+ case kNoAll:
+ return NUserAnswerMode::kNoAll;
+ case kAutoRenameAll:
+ return NUserAnswerMode::kAutoRenameAll;
+ case kQuit:
+ return NUserAnswerMode::kQuit;
+ }
+ }
+}
+
+UString GetPassword(CStdOutStream *outStream,bool verify)
+{
+#ifdef USE_FLTK
+ const char *r = fl_password("Enter password", 0);
+ AString oemPassword = "";
+ if (r) oemPassword = r;
+#else /* USE_FLTK */
+#ifdef ENV_HAVE_GETPASS
+ (*outStream) << "\nEnter password (will not be echoed) :";
+ outStream->Flush();
+ AString oemPassword = getpass("");
+ if (verify)
+ {
+ (*outStream) << "Verify password (will not be echoed) :";
+ outStream->Flush();
+ AString oemPassword2 = getpass("");
+ if (oemPassword != oemPassword2) throw "password verification failed";
+ }
+#else
+ (*outStream) << "\nEnter password:";
+ outStream->Flush();
+ AString oemPassword = g_StdIn.ScanStringUntilNewLine();
+#endif
+#endif /* USE_FLTK */
+ return MultiByteToUnicodeString(oemPassword, CP_OEMCP);
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/UserInputUtils.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/UserInputUtils.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/UserInputUtils.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/UserInputUtils.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,24 @@
+// UserInputUtils.h
+
+#ifndef __USERINPUTUTILS_H
+#define __USERINPUTUTILS_H
+
+#include "Common/StdOutStream.h"
+
+namespace NUserAnswerMode {
+
+enum EEnum
+{
+ kYes,
+ kNo,
+ kYesAll,
+ kNoAll,
+ kAutoRenameAll,
+ kQuit
+};
+}
+
+NUserAnswerMode::EEnum ScanUserYesNoAllQuit(CStdOutStream *outStream);
+UString GetPassword(CStdOutStream *outStream,bool verify = false);
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/makefile
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/makefile?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/makefile (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/makefile Sun Dec 16 23:23:25 2012
@@ -0,0 +1,109 @@
+PROG=../../../../bin/7z$(BINSUFFIX)
+
+LOCAL_FLAGS=\
+ -DEXTERNAL_LZMA \
+ -DEXTERNAL_CODECS \
+ -DBREAK_HANDLER \
+ -DUNICODE -D_UNICODE
+
+include ../../../../makefile.crc32
+include ../../../../makefile.machine
+
+PCH_NAME=$(PRE_COMPILED_HEADER)
+
+LIBS=$(LOCAL_LIBS_DLL)
+
+CONSOLE_OBJS = \
+ ConsoleClose.o \
+ ExtractCallbackConsole.o \
+ BenchCon.o \
+ List.o \
+ Main.o \
+ MainAr.o \
+ OpenCallbackConsole.o \
+ PercentPrinter.o \
+ UpdateCallbackConsole.o \
+ UserInputUtils.o \
+
+# NewHandler.o
+COMMON_OBJS = \
+ CommandLineParser.o \
+ CRC.o \
+ IntToString.o \
+ ListFileUtils.o \
+ StdInStream.o \
+ StdOutStream.o \
+ MyString.o \
+ MyWindows.o \
+ StringConvert.o \
+ StringToInt.o \
+ UTFConvert.o \
+ MyVector.o \
+ Wildcard.o \
+
+# MemoryLock.o Registry.o
+WIN_OBJS = \
+ DLL.o \
+ Error.o \
+ FileDir.o \
+ FileFind.o \
+ FileIO.o \
+ FileName.o \
+ PropVariant.o \
+ PropVariantConversions.o \
+ System.o \
+ Time.o \
+
+7ZIP_COMMON_OBJS = \
+ CreateCoder.o \
+ FilePathAutoRename.o \
+ FileStreams.o \
+ FilterCoder.o \
+ ProgressUtils.o \
+ StreamUtils.o \
+
+# WorkDir.o
+UI_COMMON_OBJS = \
+ ArchiveCommandLine.o \
+ ArchiveExtractCallback.o \
+ ArchiveOpenCallback.o \
+ DefaultName.o \
+ EnumDirItems.o \
+ Extract.o \
+ Bench.o \
+ ExtractingFilePath.o \
+ LoadCodecs.o \
+ OpenArchive.o \
+ PropIDUtils.o \
+ SetProperties.o \
+ SortUtils.o \
+ TempFiles.o \
+ Update.o \
+ UpdateAction.o \
+ UpdateCallback.o \
+ UpdatePair.o \
+ UpdateProduce.o \
+
+AR_COMMON_OBJS = \
+ OutStreamWithCRC.o \
+
+C_OBJS = \
+ Alloc.o \
+ Threads.o \
+
+OBJS = \
+ mySplitCommandLine.o \
+ myAddExeFlag.o \
+ wine_date_and_time.o \
+ $(CONSOLE_OBJS) \
+ $(COMMON_OBJS) \
+ $(WIN_OBJS) \
+ $(7ZIP_COMMON_OBJS) \
+ $(UI_COMMON_OBJS) \
+ $(AR_COMMON_OBJS) \
+ CopyCoder.o \
+ $(C_OBJS) \
+ $(OBJ_CRC32)
+
+include ../../../../makefile.glb
+
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/makefile.depend
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/makefile.depend?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/makefile.depend (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/makefile.depend Sun Dec 16 23:23:25 2012
@@ -0,0 +1,1252 @@
+myAddExeFlag.o: ../../../myWindows/myAddExeFlag.cpp \
+ ../../../myWindows/StdAfx.h ../../../myWindows/config.h \
+ ../../../Common/MyWindows.h ../../../Common/MyGuidDef.h \
+ ../../../Common/Types.h ../../../Common/../../C/Types.h \
+ ../../../Common/Types.h ../../../include_windows/windows.h \
+ ../../../include_windows/basetyps.h ../../../include_windows/tchar.h \
+ ../../../myWindows/myPrivate.h ../../../Common/StringConvert.h \
+ ../../../Common/MyWindows.h ../../../Common/MyString.h \
+ ../../../Common/MyVector.h ../../../Common/Defs.h
+mySplitCommandLine.o: ../../../myWindows/mySplitCommandLine.cpp \
+ ../../../myWindows/StdAfx.h ../../../myWindows/config.h \
+ ../../../Common/MyWindows.h ../../../Common/MyGuidDef.h \
+ ../../../Common/Types.h ../../../Common/../../C/Types.h \
+ ../../../Common/Types.h ../../../include_windows/windows.h \
+ ../../../include_windows/basetyps.h ../../../include_windows/tchar.h \
+ ../../../myWindows/../Common/StringConvert.h \
+ ../../../myWindows/../Common/MyWindows.h \
+ ../../../myWindows/../Common/MyString.h \
+ ../../../myWindows/../Common/MyVector.h \
+ ../../../myWindows/../Common/Defs.h ../../../myWindows/../Common/Types.h \
+ ../../../myWindows/myPrivate.h
+wine_date_and_time.o: ../../../myWindows/wine_date_and_time.cpp \
+ ../../../myWindows/config.h ../../../include_windows/windows.h \
+ ../../../Common/MyWindows.h ../../../Common/MyGuidDef.h \
+ ../../../Common/Types.h ../../../Common/../../C/Types.h \
+ ../../../include_windows/basetyps.h
+ConsoleClose.o: ../../UI/Console/ConsoleClose.cpp \
+ ../../../myWindows/StdAfx.h ../../../myWindows/config.h \
+ ../../../Common/MyWindows.h ../../../Common/MyGuidDef.h \
+ ../../../Common/Types.h ../../../Common/../../C/Types.h \
+ ../../../Common/Types.h ../../../include_windows/windows.h \
+ ../../../include_windows/basetyps.h ../../../include_windows/tchar.h \
+ ../../UI/Console/ConsoleClose.h
+ExtractCallbackConsole.o: ../../UI/Console/ExtractCallbackConsole.cpp \
+ ../../../myWindows/StdAfx.h ../../../myWindows/config.h \
+ ../../../Common/MyWindows.h ../../../Common/MyGuidDef.h \
+ ../../../Common/Types.h ../../../Common/../../C/Types.h \
+ ../../../Common/Types.h ../../../include_windows/windows.h \
+ ../../../include_windows/basetyps.h ../../../include_windows/tchar.h \
+ ../../UI/Console/ExtractCallbackConsole.h ../../../Common/MyString.h \
+ ../../../Common/MyVector.h ../../../Common/Defs.h \
+ ../../../Common/StdOutStream.h \
+ ../../UI/Console/../../Common/FileStreams.h \
+ ../../UI/Console/../../Common/../../Windows/FileIO.h \
+ ../../UI/Console/../../Common/../../Common/MyCom.h \
+ ../../UI/Console/../../Common/../../Common/MyWindows.h \
+ ../../UI/Console/../../Common/../IStream.h \
+ ../../UI/Console/../../Common/../../Common/MyUnknown.h \
+ ../../UI/Console/../../Common/../../Common/Types.h \
+ ../../UI/Console/../../Common/../IDecl.h \
+ ../../UI/Console/../../IPassword.h \
+ ../../UI/Console/../../../Common/MyUnknown.h \
+ ../../UI/Console/../../../Common/Types.h ../../UI/Console/../../IDecl.h \
+ ../../UI/Console/../../Archive/IArchive.h \
+ ../../UI/Console/../../Archive/../IProgress.h \
+ ../../UI/Console/../../Archive/../../Common/MyUnknown.h \
+ ../../UI/Console/../../Archive/../../Common/Types.h \
+ ../../UI/Console/../../Archive/../IDecl.h \
+ ../../UI/Console/../../Archive/../IStream.h \
+ ../../UI/Console/../../Archive/../PropID.h \
+ ../../UI/Console/../Common/ArchiveExtractCallback.h \
+ ../../../Common/MyCom.h ../../../Common/Wildcard.h \
+ ../../../Common/MyString.h ../../UI/Console/../Common/../../IPassword.h \
+ ../../UI/Console/../Common/../../Common/FileStreams.h \
+ ../../UI/Console/../Common/../../Common/ProgressUtils.h \
+ ../../UI/Console/../Common/../../Common/../../Common/MyCom.h \
+ ../../UI/Console/../Common/../../Common/../ICoder.h \
+ ../../UI/Console/../Common/../../Common/../IStream.h \
+ ../../UI/Console/../Common/../../Common/../IProgress.h \
+ ../../UI/Console/../Common/../../Archive/IArchive.h \
+ ../../UI/Console/../Common/../../Archive/Common/OutStreamWithCRC.h \
+ ../../UI/Console/../Common/../../Archive/Common/../../../../C/7zCrc.h \
+ ../../UI/Console/../Common/../../Archive/Common/../../../../C/Types.h \
+ ../../UI/Console/../Common/../../Archive/Common/../../../Common/MyCom.h \
+ ../../UI/Console/../Common/../../Archive/Common/../../IStream.h \
+ ../../UI/Console/../Common/ExtractMode.h \
+ ../../UI/Console/../Common/IFileExtractCallback.h \
+ ../../UI/Console/../Common/../../IDecl.h \
+ ../../UI/Console/../Common/OpenArchive.h ../../../Windows/FileFind.h \
+ ../../../Windows/../Common/MyString.h ../../../Windows/FileName.h \
+ ../../../Windows/../../C/Types.h ../../../Windows/Defs.h \
+ ../../../Windows/../Common/MyWindows.h \
+ ../../UI/Console/../Common/ArchiveOpenCallback.h \
+ ../../UI/Console/../Common/LoadCodecs.h \
+ ../../UI/Console/../Common/../../../Common/Types.h \
+ ../../UI/Console/../Common/../../../Common/MyCom.h \
+ ../../UI/Console/../Common/../../../Common/MyString.h \
+ ../../UI/Console/../Common/../../../Common/Buffer.h \
+ ../../UI/Console/../Common/../../../Common/Defs.h \
+ ../../UI/Console/../Common/../../ICoder.h \
+ ../../UI/Console/../Common/../../../Windows/DLL.h \
+ ../../UI/Console/../Common/../../../Windows/../Common/MyString.h \
+ ../../UI/Console/UserInputUtils.h ../../UI/Console/ConsoleClose.h \
+ ../../../Windows/FileDir.h ../../../Windows/Time.h \
+ ../../../Windows/Defs.h ../../../Windows/PropVariant.h \
+ ../../../Windows/../Common/Types.h ../../../Windows/Error.h \
+ ../../../Windows/PropVariantConversions.h \
+ ../../UI/Console/../../Common/FilePathAutoRename.h \
+ ../../UI/Console/../Common/ExtractingFilePath.h
+BenchCon.o: ../../UI/Console/BenchCon.cpp ../../../myWindows/StdAfx.h \
+ ../../../myWindows/config.h ../../../Common/MyWindows.h \
+ ../../../Common/MyGuidDef.h ../../../Common/Types.h \
+ ../../../Common/../../C/Types.h ../../../Common/Types.h \
+ ../../../include_windows/windows.h ../../../include_windows/basetyps.h \
+ ../../../include_windows/tchar.h \
+ ../../UI/Console/../../../Common/IntToString.h \
+ ../../UI/Console/../../../Common/Types.h \
+ ../../UI/Console/../../../Common/MyCom.h \
+ ../../UI/Console/../../../Common/MyWindows.h \
+ ../../UI/Console/../../../Windows/System.h \
+ ../../UI/Console/../../../Windows/../Common/Types.h \
+ ../../UI/Console/../Common/Bench.h \
+ ../../UI/Console/../Common/../../Common/CreateCoder.h \
+ ../../UI/Console/../Common/../../Common/../../Common/MyCom.h \
+ ../../UI/Console/../Common/../../Common/../../Common/MyString.h \
+ ../../UI/Console/../Common/../../Common/../../Common/MyVector.h \
+ ../../UI/Console/../Common/../../Common/../../Common/Defs.h \
+ ../../UI/Console/../Common/../../Common/../ICoder.h \
+ ../../UI/Console/../Common/../../Common/../IStream.h \
+ ../../UI/Console/../Common/../../Common/../../Common/MyUnknown.h \
+ ../../UI/Console/../Common/../../Common/../../Common/MyWindows.h \
+ ../../UI/Console/../Common/../../Common/../../Common/Types.h \
+ ../../UI/Console/../Common/../../Common/../IDecl.h \
+ ../../UI/Console/../Common/../../Common/MethodId.h \
+ ../../UI/Console/../Common/../../Common/../../Common/Types.h \
+ ../../UI/Console/BenchCon.h ../../UI/Console/../../Common/CreateCoder.h \
+ ../../UI/Console/ConsoleClose.h
+List.o: ../../UI/Console/List.cpp ../../../myWindows/StdAfx.h \
+ ../../../myWindows/config.h ../../../Common/MyWindows.h \
+ ../../../Common/MyGuidDef.h ../../../Common/Types.h \
+ ../../../Common/../../C/Types.h ../../../Common/Types.h \
+ ../../../include_windows/windows.h ../../../include_windows/basetyps.h \
+ ../../../include_windows/tchar.h ../../../Common/IntToString.h \
+ ../../../Common/MyCom.h ../../../Common/MyWindows.h \
+ ../../../Common/StdOutStream.h ../../../Common/StringConvert.h \
+ ../../../Common/MyString.h ../../../Common/MyVector.h \
+ ../../../Common/Defs.h ../../../Windows/Error.h \
+ ../../../Common/MyString.h ../../../Windows/FileDir.h \
+ ../../../Windows/../Common/MyString.h ../../../Windows/Defs.h \
+ ../../../Windows/../Common/MyWindows.h ../../../Windows/PropVariant.h \
+ ../../../Windows/../Common/Types.h \
+ ../../../Windows/PropVariantConversions.h \
+ ../../UI/Console/../../Archive/IArchive.h \
+ ../../UI/Console/../../Archive/../IProgress.h \
+ ../../UI/Console/../../Archive/../../Common/MyUnknown.h \
+ ../../UI/Console/../../Archive/../../Common/MyWindows.h \
+ ../../UI/Console/../../Archive/../../Common/Types.h \
+ ../../UI/Console/../../Archive/../IDecl.h \
+ ../../UI/Console/../../Archive/../IStream.h \
+ ../../UI/Console/../../Archive/../PropID.h \
+ ../../UI/Console/../Common/OpenArchive.h ../../../Windows/FileFind.h \
+ ../../../Windows/FileName.h ../../../Windows/../../C/Types.h \
+ ../../UI/Console/../Common/../../Archive/IArchive.h \
+ ../../UI/Console/../Common/ArchiveOpenCallback.h \
+ ../../UI/Console/../Common/../../IPassword.h \
+ ../../UI/Console/../Common/../../../Common/MyUnknown.h \
+ ../../UI/Console/../Common/../../../Common/Types.h \
+ ../../UI/Console/../Common/../../IDecl.h \
+ ../../UI/Console/../Common/LoadCodecs.h \
+ ../../UI/Console/../Common/../../../Common/Types.h \
+ ../../UI/Console/../Common/../../../Common/MyCom.h \
+ ../../UI/Console/../Common/../../../Common/MyString.h \
+ ../../UI/Console/../Common/../../../Common/Buffer.h \
+ ../../UI/Console/../Common/../../../Common/Defs.h \
+ ../../UI/Console/../Common/../../ICoder.h \
+ ../../UI/Console/../Common/../../IStream.h \
+ ../../UI/Console/../Common/../../../Windows/DLL.h \
+ ../../UI/Console/../Common/../../../Windows/../Common/MyString.h \
+ ../../UI/Console/../Common/PropIDUtils.h ../../UI/Console/ConsoleClose.h \
+ ../../UI/Console/List.h ../../../Common/Wildcard.h \
+ ../../UI/Console/../Common/LoadCodecs.h \
+ ../../UI/Console/OpenCallbackConsole.h \
+ ../../UI/Console/../Common/ArchiveOpenCallback.h
+Main.o: ../../UI/Console/Main.cpp ../../../myWindows/StdAfx.h \
+ ../../../myWindows/config.h ../../../Common/MyWindows.h \
+ ../../../Common/MyGuidDef.h ../../../Common/Types.h \
+ ../../../Common/../../C/Types.h ../../../Common/Types.h \
+ ../../../include_windows/windows.h ../../../include_windows/basetyps.h \
+ ../../../include_windows/tchar.h ../../UI/Console/../../../../C/Alloc.h \
+ ../../../Common/MyInitGuid.h ../../../Common/CommandLineParser.h \
+ ../../../Common/MyString.h ../../../Common/MyVector.h \
+ ../../../Common/Defs.h ../../../Common/IntToString.h \
+ ../../../Common/MyException.h ../../../Common/MyWindows.h \
+ ../../../Common/StdOutStream.h ../../../Common/StringConvert.h \
+ ../../../Common/StringToInt.h ../../../Windows/Error.h \
+ ../../../Common/MyString.h \
+ ../../UI/Console/../Common/ArchiveCommandLine.h \
+ ../../../Common/Wildcard.h ../../UI/Console/../Common/Extract.h \
+ ../../../Windows/FileFind.h ../../../Windows/../Common/MyString.h \
+ ../../../Windows/FileName.h ../../../Windows/../../C/Types.h \
+ ../../../Windows/Defs.h ../../../Windows/../Common/MyWindows.h \
+ ../../UI/Console/../Common/../../Archive/IArchive.h \
+ ../../UI/Console/../Common/../../Archive/../IProgress.h \
+ ../../UI/Console/../Common/../../Archive/../../Common/MyUnknown.h \
+ ../../UI/Console/../Common/../../Archive/../../Common/MyWindows.h \
+ ../../UI/Console/../Common/../../Archive/../../Common/Types.h \
+ ../../UI/Console/../Common/../../Archive/../IDecl.h \
+ ../../UI/Console/../Common/../../Archive/../IStream.h \
+ ../../UI/Console/../Common/../../Archive/../PropID.h \
+ ../../UI/Console/../Common/ArchiveExtractCallback.h \
+ ../../../Common/MyCom.h ../../UI/Console/../Common/../../IPassword.h \
+ ../../UI/Console/../Common/../../../Common/MyUnknown.h \
+ ../../UI/Console/../Common/../../../Common/Types.h \
+ ../../UI/Console/../Common/../../IDecl.h \
+ ../../UI/Console/../Common/../../Common/FileStreams.h \
+ ../../UI/Console/../Common/../../Common/../../Windows/FileIO.h \
+ ../../UI/Console/../Common/../../Common/../../Common/MyCom.h \
+ ../../UI/Console/../Common/../../Common/../IStream.h \
+ ../../UI/Console/../Common/../../Common/ProgressUtils.h \
+ ../../UI/Console/../Common/../../Common/../ICoder.h \
+ ../../UI/Console/../Common/../../Common/../IStream.h \
+ ../../UI/Console/../Common/../../Common/../IProgress.h \
+ ../../UI/Console/../Common/../../Archive/Common/OutStreamWithCRC.h \
+ ../../UI/Console/../Common/../../Archive/Common/../../../../C/7zCrc.h \
+ ../../UI/Console/../Common/../../Archive/Common/../../../../C/Types.h \
+ ../../UI/Console/../Common/../../Archive/Common/../../../Common/MyCom.h \
+ ../../UI/Console/../Common/../../Archive/Common/../../IStream.h \
+ ../../UI/Console/../Common/ExtractMode.h \
+ ../../UI/Console/../Common/IFileExtractCallback.h \
+ ../../UI/Console/../Common/../../IDecl.h \
+ ../../UI/Console/../Common/OpenArchive.h \
+ ../../UI/Console/../Common/ArchiveOpenCallback.h \
+ ../../UI/Console/../Common/LoadCodecs.h \
+ ../../UI/Console/../Common/../../../Common/Types.h \
+ ../../UI/Console/../Common/../../../Common/MyCom.h \
+ ../../UI/Console/../Common/../../../Common/MyString.h \
+ ../../UI/Console/../Common/../../../Common/Buffer.h \
+ ../../UI/Console/../Common/../../../Common/Defs.h \
+ ../../UI/Console/../Common/../../ICoder.h \
+ ../../UI/Console/../Common/../../../Windows/DLL.h \
+ ../../UI/Console/../Common/../../../Windows/../Common/MyString.h \
+ ../../UI/Console/../Common/Property.h \
+ ../../UI/Console/../Common/../Common/LoadCodecs.h \
+ ../../UI/Console/../Common/Update.h \
+ ../../UI/Console/../Common/UpdateAction.h \
+ ../../UI/Console/../Common/UpdateCallback.h \
+ ../../UI/Console/../Common/../Common/UpdatePair.h \
+ ../../UI/Console/../Common/../Common/DirItem.h \
+ ../../UI/Console/../Common/../Common/../../Archive/IArchive.h \
+ ../../UI/Console/../Common/../Common/UpdateAction.h \
+ ../../UI/Console/../Common/../Common/UpdateProduce.h \
+ ../../UI/Console/../Common/../Common/UpdatePair.h \
+ ../../UI/Console/../Common/ExitCode.h \
+ ../../UI/Console/../Common/Extract.h \
+ ../../UI/Console/../Common/LoadCodecs.h ../../UI/Console/BenchCon.h \
+ ../../UI/Console/../../Common/CreateCoder.h \
+ ../../UI/Console/../../Common/../../Common/MyCom.h \
+ ../../UI/Console/../../Common/../../Common/MyString.h \
+ ../../UI/Console/../../Common/../ICoder.h \
+ ../../UI/Console/../../Common/MethodId.h \
+ ../../UI/Console/../../Common/../../Common/Types.h \
+ ../../UI/Console/ExtractCallbackConsole.h \
+ ../../UI/Console/../../Common/FileStreams.h \
+ ../../UI/Console/../../IPassword.h \
+ ../../UI/Console/../../Archive/IArchive.h \
+ ../../UI/Console/../Common/ArchiveExtractCallback.h \
+ ../../UI/Console/List.h ../../UI/Console/OpenCallbackConsole.h \
+ ../../UI/Console/../Common/ArchiveOpenCallback.h \
+ ../../UI/Console/UpdateCallbackConsole.h \
+ ../../UI/Console/../Common/Update.h ../../UI/Console/PercentPrinter.h \
+ ../../UI/Console/../../MyVersion.h ../../../myWindows/myPrivate.h \
+ ../../../Windows/System.h ../../../Windows/../Common/Types.h
+MainAr.o: ../../UI/Console/MainAr.cpp ../../../myWindows/StdAfx.h \
+ ../../../myWindows/config.h ../../../Common/MyWindows.h \
+ ../../../Common/MyGuidDef.h ../../../Common/Types.h \
+ ../../../Common/../../C/Types.h ../../../Common/Types.h \
+ ../../../include_windows/windows.h ../../../include_windows/basetyps.h \
+ ../../../include_windows/tchar.h ../../../Common/NewHandler.h \
+ ../../../Common/MyException.h ../../../Common/MyWindows.h \
+ ../../../Common/StdOutStream.h ../../../Windows/Error.h \
+ ../../../Common/MyString.h ../../../Common/MyVector.h \
+ ../../../Common/Defs.h ../../../Windows/NtCheck.h \
+ ../../UI/Console/../Common/ArchiveCommandLine.h \
+ ../../../Common/CommandLineParser.h ../../../Common/MyString.h \
+ ../../../Common/Wildcard.h ../../UI/Console/../Common/Extract.h \
+ ../../../Windows/FileFind.h ../../../Windows/../Common/MyString.h \
+ ../../../Windows/FileName.h ../../../Windows/../../C/Types.h \
+ ../../../Windows/Defs.h ../../../Windows/../Common/MyWindows.h \
+ ../../UI/Console/../Common/../../Archive/IArchive.h \
+ ../../UI/Console/../Common/../../Archive/../IProgress.h \
+ ../../UI/Console/../Common/../../Archive/../../Common/MyUnknown.h \
+ ../../UI/Console/../Common/../../Archive/../../Common/MyWindows.h \
+ ../../UI/Console/../Common/../../Archive/../../Common/Types.h \
+ ../../UI/Console/../Common/../../Archive/../IDecl.h \
+ ../../UI/Console/../Common/../../Archive/../IStream.h \
+ ../../UI/Console/../Common/../../Archive/../PropID.h \
+ ../../UI/Console/../Common/ArchiveExtractCallback.h \
+ ../../../Common/MyCom.h ../../UI/Console/../Common/../../IPassword.h \
+ ../../UI/Console/../Common/../../../Common/MyUnknown.h \
+ ../../UI/Console/../Common/../../../Common/Types.h \
+ ../../UI/Console/../Common/../../IDecl.h \
+ ../../UI/Console/../Common/../../Common/FileStreams.h \
+ ../../UI/Console/../Common/../../Common/../../Windows/FileIO.h \
+ ../../UI/Console/../Common/../../Common/../../Common/MyCom.h \
+ ../../UI/Console/../Common/../../Common/../IStream.h \
+ ../../UI/Console/../Common/../../Common/ProgressUtils.h \
+ ../../UI/Console/../Common/../../Common/../ICoder.h \
+ ../../UI/Console/../Common/../../Common/../IStream.h \
+ ../../UI/Console/../Common/../../Common/../IProgress.h \
+ ../../UI/Console/../Common/../../Archive/Common/OutStreamWithCRC.h \
+ ../../UI/Console/../Common/../../Archive/Common/../../../../C/7zCrc.h \
+ ../../UI/Console/../Common/../../Archive/Common/../../../../C/Types.h \
+ ../../UI/Console/../Common/../../Archive/Common/../../../Common/MyCom.h \
+ ../../UI/Console/../Common/../../Archive/Common/../../IStream.h \
+ ../../UI/Console/../Common/ExtractMode.h \
+ ../../UI/Console/../Common/IFileExtractCallback.h \
+ ../../UI/Console/../Common/../../IDecl.h \
+ ../../UI/Console/../Common/OpenArchive.h \
+ ../../UI/Console/../Common/ArchiveOpenCallback.h \
+ ../../UI/Console/../Common/LoadCodecs.h \
+ ../../UI/Console/../Common/../../../Common/Types.h \
+ ../../UI/Console/../Common/../../../Common/MyCom.h \
+ ../../UI/Console/../Common/../../../Common/MyString.h \
+ ../../UI/Console/../Common/../../../Common/Buffer.h \
+ ../../UI/Console/../Common/../../../Common/Defs.h \
+ ../../UI/Console/../Common/../../ICoder.h \
+ ../../UI/Console/../Common/../../../Windows/DLL.h \
+ ../../UI/Console/../Common/../../../Windows/../Common/MyString.h \
+ ../../UI/Console/../Common/Property.h \
+ ../../UI/Console/../Common/../Common/LoadCodecs.h \
+ ../../UI/Console/../Common/Update.h \
+ ../../UI/Console/../Common/UpdateAction.h \
+ ../../UI/Console/../Common/UpdateCallback.h \
+ ../../UI/Console/../Common/../Common/UpdatePair.h \
+ ../../UI/Console/../Common/../Common/DirItem.h \
+ ../../UI/Console/../Common/../Common/../../Archive/IArchive.h \
+ ../../UI/Console/../Common/../Common/UpdateAction.h \
+ ../../UI/Console/../Common/../Common/UpdateProduce.h \
+ ../../UI/Console/../Common/../Common/UpdatePair.h \
+ ../../UI/Console/../Common/ExitCode.h ../../UI/Console/ConsoleClose.h
+OpenCallbackConsole.o: ../../UI/Console/OpenCallbackConsole.cpp \
+ ../../../myWindows/StdAfx.h ../../../myWindows/config.h \
+ ../../../Common/MyWindows.h ../../../Common/MyGuidDef.h \
+ ../../../Common/Types.h ../../../Common/../../C/Types.h \
+ ../../../Common/Types.h ../../../include_windows/windows.h \
+ ../../../include_windows/basetyps.h ../../../include_windows/tchar.h \
+ ../../UI/Console/OpenCallbackConsole.h ../../../Common/StdOutStream.h \
+ ../../UI/Console/../Common/ArchiveOpenCallback.h ../../../Common/MyCom.h \
+ ../../../Common/MyWindows.h ../../../Common/MyString.h \
+ ../../../Common/MyVector.h ../../../Common/Defs.h \
+ ../../../Windows/FileFind.h ../../../Windows/../Common/MyString.h \
+ ../../../Windows/FileName.h ../../../Windows/../../C/Types.h \
+ ../../../Windows/Defs.h ../../../Windows/../Common/MyWindows.h \
+ ../../UI/Console/../Common/../../IPassword.h \
+ ../../UI/Console/../Common/../../../Common/MyUnknown.h \
+ ../../UI/Console/../Common/../../../Common/MyWindows.h \
+ ../../UI/Console/../Common/../../../Common/Types.h \
+ ../../UI/Console/../Common/../../IDecl.h \
+ ../../UI/Console/../Common/../../Archive/IArchive.h \
+ ../../UI/Console/../Common/../../Archive/../IProgress.h \
+ ../../UI/Console/../Common/../../Archive/../../Common/MyUnknown.h \
+ ../../UI/Console/../Common/../../Archive/../../Common/Types.h \
+ ../../UI/Console/../Common/../../Archive/../IDecl.h \
+ ../../UI/Console/../Common/../../Archive/../IStream.h \
+ ../../UI/Console/../Common/../../Archive/../PropID.h \
+ ../../UI/Console/ConsoleClose.h ../../UI/Console/UserInputUtils.h
+PercentPrinter.o: ../../UI/Console/PercentPrinter.cpp \
+ ../../../myWindows/StdAfx.h ../../../myWindows/config.h \
+ ../../../Common/MyWindows.h ../../../Common/MyGuidDef.h \
+ ../../../Common/Types.h ../../../Common/../../C/Types.h \
+ ../../../Common/Types.h ../../../include_windows/windows.h \
+ ../../../include_windows/basetyps.h ../../../include_windows/tchar.h \
+ ../../../Common/IntToString.h ../../../Common/MyString.h \
+ ../../../Common/MyVector.h ../../../Common/Defs.h \
+ ../../UI/Console/PercentPrinter.h ../../../Common/StdOutStream.h
+UpdateCallbackConsole.o: ../../UI/Console/UpdateCallbackConsole.cpp \
+ ../../../myWindows/StdAfx.h ../../../myWindows/config.h \
+ ../../../Common/MyWindows.h ../../../Common/MyGuidDef.h \
+ ../../../Common/Types.h ../../../Common/../../C/Types.h \
+ ../../../Common/Types.h ../../../include_windows/windows.h \
+ ../../../include_windows/basetyps.h ../../../include_windows/tchar.h \
+ ../../UI/Console/UpdateCallbackConsole.h ../../../Common/StdOutStream.h \
+ ../../UI/Console/../Common/Update.h ../../../Common/Wildcard.h \
+ ../../../Common/MyString.h ../../../Common/MyVector.h \
+ ../../../Common/Defs.h ../../UI/Console/../Common/ArchiveOpenCallback.h \
+ ../../../Common/MyCom.h ../../../Common/MyWindows.h \
+ ../../../Common/MyString.h ../../../Windows/FileFind.h \
+ ../../../Windows/../Common/MyString.h ../../../Windows/FileName.h \
+ ../../../Windows/../../C/Types.h ../../../Windows/Defs.h \
+ ../../../Windows/../Common/MyWindows.h \
+ ../../UI/Console/../Common/../../IPassword.h \
+ ../../UI/Console/../Common/../../../Common/MyUnknown.h \
+ ../../UI/Console/../Common/../../../Common/MyWindows.h \
+ ../../UI/Console/../Common/../../../Common/Types.h \
+ ../../UI/Console/../Common/../../IDecl.h \
+ ../../UI/Console/../Common/../../Archive/IArchive.h \
+ ../../UI/Console/../Common/../../Archive/../IProgress.h \
+ ../../UI/Console/../Common/../../Archive/../../Common/MyUnknown.h \
+ ../../UI/Console/../Common/../../Archive/../../Common/Types.h \
+ ../../UI/Console/../Common/../../Archive/../IDecl.h \
+ ../../UI/Console/../Common/../../Archive/../IStream.h \
+ ../../UI/Console/../Common/../../Archive/../PropID.h \
+ ../../UI/Console/../Common/LoadCodecs.h \
+ ../../UI/Console/../Common/../../../Common/Types.h \
+ ../../UI/Console/../Common/../../../Common/MyCom.h \
+ ../../UI/Console/../Common/../../../Common/MyString.h \
+ ../../UI/Console/../Common/../../../Common/Buffer.h \
+ ../../UI/Console/../Common/../../../Common/Defs.h \
+ ../../UI/Console/../Common/../../ICoder.h \
+ ../../UI/Console/../Common/../../IStream.h \
+ ../../UI/Console/../Common/../../../Windows/DLL.h \
+ ../../UI/Console/../Common/../../../Windows/../Common/MyString.h \
+ ../../UI/Console/../Common/Property.h \
+ ../../UI/Console/../Common/UpdateAction.h \
+ ../../UI/Console/../Common/UpdateCallback.h \
+ ../../UI/Console/../Common/../Common/UpdatePair.h \
+ ../../UI/Console/../Common/../Common/DirItem.h \
+ ../../UI/Console/../Common/../Common/../../Archive/IArchive.h \
+ ../../UI/Console/../Common/../Common/UpdateAction.h \
+ ../../UI/Console/../Common/../Common/UpdateProduce.h \
+ ../../UI/Console/../Common/../Common/UpdatePair.h \
+ ../../UI/Console/PercentPrinter.h ../../../Windows/Error.h \
+ ../../../Windows/Synchronization.h ../../../Windows/../../C/Threads.h \
+ ../../../Windows/../../C/Types.h ../../../Windows/Synchronization2.h \
+ ../../UI/Console/ConsoleClose.h ../../UI/Console/UserInputUtils.h
+UserInputUtils.o: ../../UI/Console/UserInputUtils.cpp \
+ ../../../myWindows/StdAfx.h ../../../myWindows/config.h \
+ ../../../Common/MyWindows.h ../../../Common/MyGuidDef.h \
+ ../../../Common/Types.h ../../../Common/../../C/Types.h \
+ ../../../Common/Types.h ../../../include_windows/windows.h \
+ ../../../include_windows/basetyps.h ../../../include_windows/tchar.h \
+ ../../../Common/StdInStream.h ../../../Common/MyString.h \
+ ../../../Common/MyVector.h ../../../Common/Defs.h \
+ ../../../Common/StringConvert.h ../../../Common/MyWindows.h \
+ ../../UI/Console/UserInputUtils.h ../../../Common/StdOutStream.h \
+ ../../../Common/MyException.h
+CommandLineParser.o: ../../../Common/CommandLineParser.cpp \
+ ../../../myWindows/StdAfx.h ../../../myWindows/config.h \
+ ../../../Common/MyWindows.h ../../../Common/MyGuidDef.h \
+ ../../../Common/Types.h ../../../Common/../../C/Types.h \
+ ../../../Common/Types.h ../../../include_windows/windows.h \
+ ../../../include_windows/basetyps.h ../../../include_windows/tchar.h \
+ ../../../Common/CommandLineParser.h ../../../Common/MyString.h \
+ ../../../Common/MyVector.h ../../../Common/Defs.h
+CRC.o: ../../../Common/CRC.cpp ../../../myWindows/StdAfx.h \
+ ../../../myWindows/config.h ../../../Common/MyWindows.h \
+ ../../../Common/MyGuidDef.h ../../../Common/Types.h \
+ ../../../Common/../../C/Types.h ../../../Common/Types.h \
+ ../../../include_windows/windows.h ../../../include_windows/basetyps.h \
+ ../../../include_windows/tchar.h ../../../Common/../../C/7zCrc.h \
+ ../../../Common/../../C/Types.h
+IntToString.o: ../../../Common/IntToString.cpp \
+ ../../../myWindows/StdAfx.h ../../../myWindows/config.h \
+ ../../../Common/MyWindows.h ../../../Common/MyGuidDef.h \
+ ../../../Common/Types.h ../../../Common/../../C/Types.h \
+ ../../../Common/Types.h ../../../include_windows/windows.h \
+ ../../../include_windows/basetyps.h ../../../include_windows/tchar.h \
+ ../../../Common/IntToString.h
+ListFileUtils.o: ../../../Common/ListFileUtils.cpp \
+ ../../../myWindows/StdAfx.h ../../../myWindows/config.h \
+ ../../../Common/MyWindows.h ../../../Common/MyGuidDef.h \
+ ../../../Common/Types.h ../../../Common/../../C/Types.h \
+ ../../../Common/Types.h ../../../include_windows/windows.h \
+ ../../../include_windows/basetyps.h ../../../include_windows/tchar.h \
+ ../../../Common/MyWindows.h ../../../Common/../Windows/FileIO.h \
+ ../../../Common/MyString.h ../../../Common/MyVector.h \
+ ../../../Common/Defs.h ../../../Common/ListFileUtils.h \
+ ../../../Common/MyString.h ../../../Common/StringConvert.h \
+ ../../../Common/UTFConvert.h
+StdInStream.o: ../../../Common/StdInStream.cpp \
+ ../../../myWindows/StdAfx.h ../../../myWindows/config.h \
+ ../../../Common/MyWindows.h ../../../Common/MyGuidDef.h \
+ ../../../Common/Types.h ../../../Common/../../C/Types.h \
+ ../../../Common/Types.h ../../../include_windows/windows.h \
+ ../../../include_windows/basetyps.h ../../../include_windows/tchar.h \
+ ../../../Common/StdInStream.h ../../../Common/MyString.h \
+ ../../../Common/MyVector.h ../../../Common/Defs.h \
+ ../../../Common/StringConvert.h ../../../Common/MyWindows.h \
+ ../../../myWindows/myPrivate.h
+StdOutStream.o: ../../../Common/StdOutStream.cpp \
+ ../../../myWindows/StdAfx.h ../../../myWindows/config.h \
+ ../../../Common/MyWindows.h ../../../Common/MyGuidDef.h \
+ ../../../Common/Types.h ../../../Common/../../C/Types.h \
+ ../../../Common/Types.h ../../../include_windows/windows.h \
+ ../../../include_windows/basetyps.h ../../../include_windows/tchar.h \
+ ../../../Common/StdOutStream.h ../../../Common/IntToString.h \
+ ../../../Common/StringConvert.h ../../../Common/MyWindows.h \
+ ../../../Common/MyString.h ../../../Common/MyVector.h \
+ ../../../Common/Defs.h
+MyString.o: ../../../Common/MyString.cpp ../../../myWindows/StdAfx.h \
+ ../../../myWindows/config.h ../../../Common/MyWindows.h \
+ ../../../Common/MyGuidDef.h ../../../Common/Types.h \
+ ../../../Common/../../C/Types.h ../../../Common/Types.h \
+ ../../../include_windows/windows.h ../../../include_windows/basetyps.h \
+ ../../../include_windows/tchar.h ../../../Common/StringConvert.h \
+ ../../../Common/MyWindows.h ../../../Common/MyString.h \
+ ../../../Common/MyVector.h ../../../Common/Defs.h \
+ ../../../myWindows/myPrivate.h
+MyWindows.o: ../../../Common/MyWindows.cpp ../../../myWindows/StdAfx.h \
+ ../../../myWindows/config.h ../../../Common/MyWindows.h \
+ ../../../Common/MyGuidDef.h ../../../Common/Types.h \
+ ../../../Common/../../C/Types.h ../../../Common/Types.h \
+ ../../../include_windows/windows.h ../../../include_windows/basetyps.h \
+ ../../../include_windows/tchar.h ../../../Common/MyWindows.h
+StringConvert.o: ../../../Common/StringConvert.cpp \
+ ../../../myWindows/StdAfx.h ../../../myWindows/config.h \
+ ../../../Common/MyWindows.h ../../../Common/MyGuidDef.h \
+ ../../../Common/Types.h ../../../Common/../../C/Types.h \
+ ../../../Common/Types.h ../../../include_windows/windows.h \
+ ../../../include_windows/basetyps.h ../../../include_windows/tchar.h \
+ ../../../Common/StringConvert.h ../../../Common/MyWindows.h \
+ ../../../Common/MyString.h ../../../Common/MyVector.h \
+ ../../../Common/Defs.h
+StringToInt.o: ../../../Common/StringToInt.cpp \
+ ../../../myWindows/StdAfx.h ../../../myWindows/config.h \
+ ../../../Common/MyWindows.h ../../../Common/MyGuidDef.h \
+ ../../../Common/Types.h ../../../Common/../../C/Types.h \
+ ../../../Common/Types.h ../../../include_windows/windows.h \
+ ../../../include_windows/basetyps.h ../../../include_windows/tchar.h \
+ ../../../Common/StringToInt.h
+UTFConvert.o: ../../../Common/UTFConvert.cpp ../../../myWindows/StdAfx.h \
+ ../../../myWindows/config.h ../../../Common/MyWindows.h \
+ ../../../Common/MyGuidDef.h ../../../Common/Types.h \
+ ../../../Common/../../C/Types.h ../../../Common/Types.h \
+ ../../../include_windows/windows.h ../../../include_windows/basetyps.h \
+ ../../../include_windows/tchar.h ../../../Common/UTFConvert.h \
+ ../../../Common/MyString.h ../../../Common/MyVector.h \
+ ../../../Common/Defs.h
+MyVector.o: ../../../Common/MyVector.cpp ../../../myWindows/StdAfx.h \
+ ../../../myWindows/config.h ../../../Common/MyWindows.h \
+ ../../../Common/MyGuidDef.h ../../../Common/Types.h \
+ ../../../Common/../../C/Types.h ../../../Common/Types.h \
+ ../../../include_windows/windows.h ../../../include_windows/basetyps.h \
+ ../../../include_windows/tchar.h ../../../Common/MyVector.h \
+ ../../../Common/Defs.h
+Wildcard.o: ../../../Common/Wildcard.cpp ../../../myWindows/StdAfx.h \
+ ../../../myWindows/config.h ../../../Common/MyWindows.h \
+ ../../../Common/MyGuidDef.h ../../../Common/Types.h \
+ ../../../Common/../../C/Types.h ../../../Common/Types.h \
+ ../../../include_windows/windows.h ../../../include_windows/basetyps.h \
+ ../../../include_windows/tchar.h ../../../Common/Wildcard.h \
+ ../../../Common/MyString.h ../../../Common/MyVector.h \
+ ../../../Common/Defs.h
+DLL.o: ../../../Windows/DLL.cpp ../../../myWindows/StdAfx.h \
+ ../../../myWindows/config.h ../../../Common/MyWindows.h \
+ ../../../Common/MyGuidDef.h ../../../Common/Types.h \
+ ../../../Common/../../C/Types.h ../../../Common/Types.h \
+ ../../../include_windows/windows.h ../../../include_windows/basetyps.h \
+ ../../../include_windows/tchar.h ../../../Windows/DLL.h \
+ ../../../Windows/../Common/MyString.h \
+ ../../../Windows/../Common/MyVector.h ../../../Windows/../Common/Defs.h \
+ ../../../Windows/Defs.h ../../../Windows/../Common/MyWindows.h \
+ ../../../Windows/../Common/StringConvert.h \
+ ../../../Windows/../Common/MyWindows.h \
+ ../../../Windows/../Common/MyString.h ../../../Windows/../Common/Types.h \
+ ../../../myWindows/myPrivate.h
+Error.o: ../../../Windows/Error.cpp ../../../myWindows/StdAfx.h \
+ ../../../myWindows/config.h ../../../Common/MyWindows.h \
+ ../../../Common/MyGuidDef.h ../../../Common/Types.h \
+ ../../../Common/../../C/Types.h ../../../Common/Types.h \
+ ../../../include_windows/windows.h ../../../include_windows/basetyps.h \
+ ../../../include_windows/tchar.h ../../../Windows/Error.h \
+ ../../../Common/MyString.h ../../../Common/MyVector.h \
+ ../../../Common/Defs.h ../../../Common/StringConvert.h \
+ ../../../Common/MyWindows.h ../../../Common/MyString.h
+FileDir.o: ../../../Windows/FileDir.cpp ../../../myWindows/StdAfx.h \
+ ../../../myWindows/config.h ../../../Common/MyWindows.h \
+ ../../../Common/MyGuidDef.h ../../../Common/Types.h \
+ ../../../Common/../../C/Types.h ../../../Common/Types.h \
+ ../../../include_windows/windows.h ../../../include_windows/basetyps.h \
+ ../../../include_windows/tchar.h ../../../Windows/FileDir.h \
+ ../../../Windows/../Common/MyString.h \
+ ../../../Windows/../Common/MyVector.h ../../../Windows/../Common/Defs.h \
+ ../../../Windows/Defs.h ../../../Windows/../Common/MyWindows.h \
+ ../../../Windows/FileName.h ../../../Windows/../../C/Types.h \
+ ../../../Windows/FileFind.h ../../../Windows/../Common/StringConvert.h \
+ ../../../Windows/../Common/MyWindows.h \
+ ../../../Windows/../Common/MyString.h ../../../Windows/../Common/Types.h \
+ ../../../Windows/../Common/IntToString.h ../../../myWindows/myPrivate.h \
+ ../../../Windows/Synchronization.h ../../../Windows/../../C/Threads.h \
+ ../../../Windows/../../C/Types.h ../../../Windows/Synchronization2.h
+FileFind.o: ../../../Windows/FileFind.cpp ../../../myWindows/StdAfx.h \
+ ../../../myWindows/config.h ../../../Common/MyWindows.h \
+ ../../../Common/MyGuidDef.h ../../../Common/Types.h \
+ ../../../Common/../../C/Types.h ../../../Common/Types.h \
+ ../../../include_windows/windows.h ../../../include_windows/basetyps.h \
+ ../../../include_windows/tchar.h ../../../Windows/FileFind.h \
+ ../../../Windows/../Common/MyString.h \
+ ../../../Windows/../Common/MyVector.h ../../../Windows/../Common/Defs.h \
+ ../../../Windows/FileName.h ../../../Windows/../../C/Types.h \
+ ../../../Windows/Defs.h ../../../Windows/../Common/MyWindows.h \
+ ../../../Windows/../Common/StringConvert.h \
+ ../../../Windows/../Common/MyWindows.h \
+ ../../../Windows/../Common/MyString.h ../../../Windows/../Common/Types.h \
+ ../../../myWindows/myPrivate.h
+FileIO.o: ../../../Windows/FileIO.cpp ../../../myWindows/StdAfx.h \
+ ../../../myWindows/config.h ../../../Common/MyWindows.h \
+ ../../../Common/MyGuidDef.h ../../../Common/Types.h \
+ ../../../Common/../../C/Types.h ../../../Common/Types.h \
+ ../../../include_windows/windows.h ../../../include_windows/basetyps.h \
+ ../../../include_windows/tchar.h ../../../Windows/FileIO.h \
+ ../../../Common/MyString.h ../../../Common/MyVector.h \
+ ../../../Common/Defs.h ../../../Windows/Defs.h \
+ ../../../Windows/../Common/MyWindows.h \
+ ../../../Windows/../Common/StringConvert.h \
+ ../../../Windows/../Common/MyWindows.h \
+ ../../../Windows/../Common/MyString.h ../../../Windows/../Common/Types.h \
+ ../../../myWindows/myPrivate.h
+FileName.o: ../../../Windows/FileName.cpp ../../../myWindows/StdAfx.h \
+ ../../../myWindows/config.h ../../../Common/MyWindows.h \
+ ../../../Common/MyGuidDef.h ../../../Common/Types.h \
+ ../../../Common/../../C/Types.h ../../../Common/Types.h \
+ ../../../include_windows/windows.h ../../../include_windows/basetyps.h \
+ ../../../include_windows/tchar.h ../../../Windows/FileName.h \
+ ../../../Windows/../../C/Types.h ../../../Windows/../Common/MyString.h \
+ ../../../Windows/../Common/MyVector.h ../../../Windows/../Common/Defs.h \
+ ../../../Common/Wildcard.h ../../../Common/MyString.h
+PropVariant.o: ../../../Windows/PropVariant.cpp \
+ ../../../myWindows/StdAfx.h ../../../myWindows/config.h \
+ ../../../Common/MyWindows.h ../../../Common/MyGuidDef.h \
+ ../../../Common/Types.h ../../../Common/../../C/Types.h \
+ ../../../Common/Types.h ../../../include_windows/windows.h \
+ ../../../include_windows/basetyps.h ../../../include_windows/tchar.h \
+ ../../../Windows/PropVariant.h ../../../Windows/../Common/MyWindows.h \
+ ../../../Windows/../Common/Types.h ../../../Windows/../Common/Defs.h
+PropVariantConversions.o: ../../../Windows/PropVariantConversions.cpp \
+ ../../../myWindows/StdAfx.h ../../../myWindows/config.h \
+ ../../../Common/MyWindows.h ../../../Common/MyGuidDef.h \
+ ../../../Common/Types.h ../../../Common/../../C/Types.h \
+ ../../../Common/Types.h ../../../include_windows/windows.h \
+ ../../../include_windows/basetyps.h ../../../include_windows/tchar.h \
+ ../../../Common/IntToString.h ../../../Common/StringConvert.h \
+ ../../../Common/MyWindows.h ../../../Common/MyString.h \
+ ../../../Common/MyVector.h ../../../Common/Defs.h \
+ ../../../Windows/Defs.h ../../../Windows/../Common/MyWindows.h \
+ ../../../Windows/PropVariantConversions.h ../../../Common/MyString.h
+System.o: ../../../Windows/System.cpp ../../../Common/Types.h \
+ ../../../Common/../../C/Types.h
+Time.o: ../../../Windows/Time.cpp ../../../myWindows/StdAfx.h \
+ ../../../myWindows/config.h ../../../Common/MyWindows.h \
+ ../../../Common/MyGuidDef.h ../../../Common/Types.h \
+ ../../../Common/../../C/Types.h ../../../Common/Types.h \
+ ../../../include_windows/windows.h ../../../include_windows/basetyps.h \
+ ../../../include_windows/tchar.h ../../../Windows/Time.h \
+ ../../../Windows/Defs.h ../../../Windows/../Common/MyWindows.h
+CreateCoder.o: ../../Common/CreateCoder.cpp ../../../myWindows/StdAfx.h \
+ ../../../myWindows/config.h ../../../Common/MyWindows.h \
+ ../../../Common/MyGuidDef.h ../../../Common/Types.h \
+ ../../../Common/../../C/Types.h ../../../Common/Types.h \
+ ../../../include_windows/windows.h ../../../include_windows/basetyps.h \
+ ../../../include_windows/tchar.h ../../Common/../../Windows/Defs.h \
+ ../../Common/../../Windows/../Common/MyWindows.h \
+ ../../Common/../../Windows/PropVariant.h \
+ ../../Common/../../Windows/../Common/Types.h ../../Common/CreateCoder.h \
+ ../../Common/../../Common/MyCom.h ../../Common/../../Common/MyWindows.h \
+ ../../Common/../../Common/MyString.h \
+ ../../Common/../../Common/MyVector.h ../../Common/../../Common/Defs.h \
+ ../../Common/../ICoder.h ../../Common/../IStream.h \
+ ../../Common/../../Common/MyUnknown.h ../../Common/../../Common/Types.h \
+ ../../Common/../IDecl.h ../../Common/MethodId.h \
+ ../../Common/../../Common/Types.h ../../Common/FilterCoder.h \
+ ../../Common/../IPassword.h ../../Common/RegisterCodec.h \
+ ../../Common/../Common/MethodId.h
+FilePathAutoRename.o: ../../Common/FilePathAutoRename.cpp \
+ ../../../myWindows/StdAfx.h ../../../myWindows/config.h \
+ ../../../Common/MyWindows.h ../../../Common/MyGuidDef.h \
+ ../../../Common/Types.h ../../../Common/../../C/Types.h \
+ ../../../Common/Types.h ../../../include_windows/windows.h \
+ ../../../include_windows/basetyps.h ../../../include_windows/tchar.h \
+ ../../../Common/Defs.h ../../../Common/IntToString.h \
+ ../../../Windows/FileFind.h ../../../Windows/../Common/MyString.h \
+ ../../../Windows/../Common/MyVector.h ../../../Windows/../Common/Defs.h \
+ ../../../Windows/FileName.h ../../../Windows/../../C/Types.h \
+ ../../../Windows/Defs.h ../../../Windows/../Common/MyWindows.h \
+ ../../Common/FilePathAutoRename.h ../../../Common/MyString.h
+FileStreams.o: ../../Common/FileStreams.cpp ../../../myWindows/StdAfx.h \
+ ../../../myWindows/config.h ../../../Common/MyWindows.h \
+ ../../../Common/MyGuidDef.h ../../../Common/Types.h \
+ ../../../Common/../../C/Types.h ../../../Common/Types.h \
+ ../../../include_windows/windows.h ../../../include_windows/basetyps.h \
+ ../../../include_windows/tchar.h ../../Common/FileStreams.h \
+ ../../Common/../../Windows/FileIO.h ../../../Common/MyString.h \
+ ../../../Common/MyVector.h ../../../Common/Defs.h \
+ ../../Common/../../Common/MyCom.h ../../Common/../../Common/MyWindows.h \
+ ../../Common/../IStream.h ../../Common/../../Common/MyUnknown.h \
+ ../../Common/../../Common/Types.h ../../Common/../IDecl.h
+FilterCoder.o: ../../Common/FilterCoder.cpp ../../../myWindows/StdAfx.h \
+ ../../../myWindows/config.h ../../../Common/MyWindows.h \
+ ../../../Common/MyGuidDef.h ../../../Common/Types.h \
+ ../../../Common/../../C/Types.h ../../../Common/Types.h \
+ ../../../include_windows/windows.h ../../../include_windows/basetyps.h \
+ ../../../include_windows/tchar.h ../../Common/../../../C/Alloc.h \
+ ../../Common/../../Common/Defs.h ../../Common/FilterCoder.h \
+ ../../Common/../../Common/MyCom.h ../../Common/../../Common/MyWindows.h \
+ ../../Common/../ICoder.h ../../Common/../IStream.h \
+ ../../Common/../../Common/MyUnknown.h ../../Common/../../Common/Types.h \
+ ../../Common/../IDecl.h ../../Common/../IPassword.h \
+ ../../Common/StreamUtils.h ../../Common/../IStream.h
+ProgressUtils.o: ../../Common/ProgressUtils.cpp \
+ ../../../myWindows/StdAfx.h ../../../myWindows/config.h \
+ ../../../Common/MyWindows.h ../../../Common/MyGuidDef.h \
+ ../../../Common/Types.h ../../../Common/../../C/Types.h \
+ ../../../Common/Types.h ../../../include_windows/windows.h \
+ ../../../include_windows/basetyps.h ../../../include_windows/tchar.h \
+ ../../Common/ProgressUtils.h ../../Common/../../Common/MyCom.h \
+ ../../Common/../../Common/MyWindows.h ../../Common/../ICoder.h \
+ ../../Common/../IStream.h ../../Common/../../Common/MyUnknown.h \
+ ../../Common/../../Common/Types.h ../../Common/../IDecl.h \
+ ../../Common/../IProgress.h
+StreamUtils.o: ../../Common/StreamUtils.cpp ../../../myWindows/StdAfx.h \
+ ../../../myWindows/config.h ../../../Common/MyWindows.h \
+ ../../../Common/MyGuidDef.h ../../../Common/Types.h \
+ ../../../Common/../../C/Types.h ../../../Common/Types.h \
+ ../../../include_windows/windows.h ../../../include_windows/basetyps.h \
+ ../../../include_windows/tchar.h ../../Common/StreamUtils.h \
+ ../../Common/../IStream.h ../../Common/../../Common/MyUnknown.h \
+ ../../Common/../../Common/MyWindows.h ../../Common/../../Common/Types.h \
+ ../../Common/../IDecl.h
+ArchiveCommandLine.o: ../../UI/Common/ArchiveCommandLine.cpp \
+ ../../../myWindows/StdAfx.h ../../../myWindows/config.h \
+ ../../../Common/MyWindows.h ../../../Common/MyGuidDef.h \
+ ../../../Common/Types.h ../../../Common/../../C/Types.h \
+ ../../../Common/Types.h ../../../include_windows/windows.h \
+ ../../../include_windows/basetyps.h ../../../include_windows/tchar.h \
+ ../../../Common/ListFileUtils.h ../../../Common/MyString.h \
+ ../../../Common/MyVector.h ../../../Common/Defs.h \
+ ../../../Common/StringConvert.h ../../../Common/MyWindows.h \
+ ../../../Common/StringToInt.h ../../../Windows/FileDir.h \
+ ../../../Windows/../Common/MyString.h ../../../Windows/Defs.h \
+ ../../../Windows/../Common/MyWindows.h ../../../Windows/FileName.h \
+ ../../../Windows/../../C/Types.h ../../../myWindows/myPrivate.h \
+ ../../UI/Common/ArchiveCommandLine.h ../../../Common/CommandLineParser.h \
+ ../../../Common/Wildcard.h ../../UI/Common/Extract.h \
+ ../../../Windows/FileFind.h ../../../Windows/FileName.h \
+ ../../UI/Common/../../Archive/IArchive.h \
+ ../../UI/Common/../../Archive/../IProgress.h \
+ ../../UI/Common/../../Archive/../../Common/MyUnknown.h \
+ ../../UI/Common/../../Archive/../../Common/MyWindows.h \
+ ../../UI/Common/../../Archive/../../Common/Types.h \
+ ../../UI/Common/../../Archive/../IDecl.h \
+ ../../UI/Common/../../Archive/../IStream.h \
+ ../../UI/Common/../../Archive/../PropID.h \
+ ../../UI/Common/ArchiveExtractCallback.h ../../../Common/MyCom.h \
+ ../../UI/Common/../../IPassword.h \
+ ../../UI/Common/../../../Common/MyUnknown.h \
+ ../../UI/Common/../../../Common/Types.h ../../UI/Common/../../IDecl.h \
+ ../../UI/Common/../../Common/FileStreams.h \
+ ../../UI/Common/../../Common/../../Windows/FileIO.h \
+ ../../../Common/MyString.h \
+ ../../UI/Common/../../Common/../../Common/MyCom.h \
+ ../../UI/Common/../../Common/../IStream.h \
+ ../../UI/Common/../../Common/ProgressUtils.h \
+ ../../UI/Common/../../Common/../ICoder.h \
+ ../../UI/Common/../../Common/../IStream.h \
+ ../../UI/Common/../../Common/../IProgress.h \
+ ../../UI/Common/../../Archive/Common/OutStreamWithCRC.h \
+ ../../UI/Common/../../Archive/Common/../../../../C/7zCrc.h \
+ ../../UI/Common/../../Archive/Common/../../../../C/Types.h \
+ ../../UI/Common/../../Archive/Common/../../../Common/MyCom.h \
+ ../../UI/Common/../../Archive/Common/../../IStream.h \
+ ../../UI/Common/ExtractMode.h ../../UI/Common/IFileExtractCallback.h \
+ ../../UI/Common/../../IDecl.h ../../UI/Common/OpenArchive.h \
+ ../../UI/Common/ArchiveOpenCallback.h ../../UI/Common/LoadCodecs.h \
+ ../../UI/Common/../../../Common/Types.h \
+ ../../UI/Common/../../../Common/MyCom.h \
+ ../../UI/Common/../../../Common/MyString.h \
+ ../../UI/Common/../../../Common/Buffer.h \
+ ../../UI/Common/../../../Common/Defs.h ../../UI/Common/../../ICoder.h \
+ ../../UI/Common/../../../Windows/DLL.h \
+ ../../UI/Common/../../../Windows/../Common/MyString.h \
+ ../../UI/Common/Property.h ../../UI/Common/../Common/LoadCodecs.h \
+ ../../UI/Common/Update.h ../../UI/Common/UpdateAction.h \
+ ../../UI/Common/UpdateCallback.h ../../UI/Common/../Common/UpdatePair.h \
+ ../../UI/Common/../Common/DirItem.h \
+ ../../UI/Common/../Common/../../Archive/IArchive.h \
+ ../../UI/Common/../Common/UpdateAction.h \
+ ../../UI/Common/../Common/UpdateProduce.h \
+ ../../UI/Common/../Common/UpdatePair.h ../../UI/Common/EnumDirItems.h \
+ ../../UI/Common/DirItem.h ../../UI/Common/SortUtils.h
+ArchiveExtractCallback.o: ../../UI/Common/ArchiveExtractCallback.cpp \
+ ../../../myWindows/StdAfx.h ../../../myWindows/config.h \
+ ../../../Common/MyWindows.h ../../../Common/MyGuidDef.h \
+ ../../../Common/Types.h ../../../Common/../../C/Types.h \
+ ../../../Common/Types.h ../../../include_windows/windows.h \
+ ../../../include_windows/basetyps.h ../../../include_windows/tchar.h \
+ ../../../Common/ComTry.h ../../../Common/MyWindows.h \
+ ../../../Common/Wildcard.h ../../../Common/MyString.h \
+ ../../../Common/MyVector.h ../../../Common/Defs.h \
+ ../../../Windows/FileDir.h ../../../Windows/../Common/MyString.h \
+ ../../../Windows/Defs.h ../../../Windows/../Common/MyWindows.h \
+ ../../../Windows/FileFind.h ../../../Windows/FileName.h \
+ ../../../Windows/../../C/Types.h ../../../Windows/PropVariant.h \
+ ../../../Windows/../Common/Types.h \
+ ../../../Windows/PropVariantConversions.h ../../../Common/MyString.h \
+ ../../UI/Common/../../Common/FilePathAutoRename.h \
+ ../../UI/Common/../Common/ExtractingFilePath.h \
+ ../../UI/Common/ArchiveExtractCallback.h ../../../Common/MyCom.h \
+ ../../UI/Common/../../IPassword.h \
+ ../../UI/Common/../../../Common/MyUnknown.h \
+ ../../UI/Common/../../../Common/MyWindows.h \
+ ../../UI/Common/../../../Common/Types.h ../../UI/Common/../../IDecl.h \
+ ../../UI/Common/../../Common/FileStreams.h \
+ ../../UI/Common/../../Common/../../Windows/FileIO.h \
+ ../../UI/Common/../../Common/../../Common/MyCom.h \
+ ../../UI/Common/../../Common/../IStream.h \
+ ../../UI/Common/../../Common/../../Common/MyUnknown.h \
+ ../../UI/Common/../../Common/../../Common/Types.h \
+ ../../UI/Common/../../Common/../IDecl.h \
+ ../../UI/Common/../../Common/ProgressUtils.h \
+ ../../UI/Common/../../Common/../ICoder.h \
+ ../../UI/Common/../../Common/../IStream.h \
+ ../../UI/Common/../../Common/../IProgress.h \
+ ../../UI/Common/../../Archive/IArchive.h \
+ ../../UI/Common/../../Archive/../IProgress.h \
+ ../../UI/Common/../../Archive/../IStream.h \
+ ../../UI/Common/../../Archive/../PropID.h \
+ ../../UI/Common/../../Archive/Common/OutStreamWithCRC.h \
+ ../../UI/Common/../../Archive/Common/../../../../C/7zCrc.h \
+ ../../UI/Common/../../Archive/Common/../../../../C/Types.h \
+ ../../UI/Common/../../Archive/Common/../../../Common/MyCom.h \
+ ../../UI/Common/../../Archive/Common/../../IStream.h \
+ ../../UI/Common/ExtractMode.h ../../UI/Common/IFileExtractCallback.h \
+ ../../UI/Common/../../IDecl.h ../../UI/Common/OpenArchive.h \
+ ../../UI/Common/ArchiveOpenCallback.h ../../UI/Common/LoadCodecs.h \
+ ../../UI/Common/../../../Common/Types.h \
+ ../../UI/Common/../../../Common/MyCom.h \
+ ../../UI/Common/../../../Common/MyString.h \
+ ../../UI/Common/../../../Common/Buffer.h \
+ ../../UI/Common/../../../Common/Defs.h ../../UI/Common/../../ICoder.h \
+ ../../UI/Common/../../../Windows/DLL.h \
+ ../../UI/Common/../../../Windows/../Common/MyString.h
+ArchiveOpenCallback.o: ../../UI/Common/ArchiveOpenCallback.cpp \
+ ../../../myWindows/StdAfx.h ../../../myWindows/config.h \
+ ../../../Common/MyWindows.h ../../../Common/MyGuidDef.h \
+ ../../../Common/Types.h ../../../Common/../../C/Types.h \
+ ../../../Common/Types.h ../../../include_windows/windows.h \
+ ../../../include_windows/basetyps.h ../../../include_windows/tchar.h \
+ ../../../Common/StringConvert.h ../../../Common/MyWindows.h \
+ ../../../Common/MyString.h ../../../Common/MyVector.h \
+ ../../../Common/Defs.h ../../../Common/ComTry.h \
+ ../../../Windows/PropVariant.h ../../../Windows/../Common/MyWindows.h \
+ ../../../Windows/../Common/Types.h \
+ ../../UI/Common/../../Common/FileStreams.h \
+ ../../UI/Common/../../Common/../../Windows/FileIO.h \
+ ../../../Common/MyString.h \
+ ../../UI/Common/../../Common/../../Common/MyCom.h \
+ ../../UI/Common/../../Common/../../Common/MyWindows.h \
+ ../../UI/Common/../../Common/../IStream.h \
+ ../../UI/Common/../../Common/../../Common/MyUnknown.h \
+ ../../UI/Common/../../Common/../../Common/Types.h \
+ ../../UI/Common/../../Common/../IDecl.h \
+ ../../UI/Common/ArchiveOpenCallback.h ../../../Common/MyCom.h \
+ ../../../Windows/FileFind.h ../../../Windows/../Common/MyString.h \
+ ../../../Windows/FileName.h ../../../Windows/../../C/Types.h \
+ ../../../Windows/Defs.h ../../UI/Common/../../IPassword.h \
+ ../../UI/Common/../../../Common/MyUnknown.h \
+ ../../UI/Common/../../../Common/Types.h ../../UI/Common/../../IDecl.h \
+ ../../UI/Common/../../Archive/IArchive.h \
+ ../../UI/Common/../../Archive/../IProgress.h \
+ ../../UI/Common/../../Archive/../../Common/MyUnknown.h \
+ ../../UI/Common/../../Archive/../../Common/Types.h \
+ ../../UI/Common/../../Archive/../IDecl.h \
+ ../../UI/Common/../../Archive/../IStream.h \
+ ../../UI/Common/../../Archive/../PropID.h
+DefaultName.o: ../../UI/Common/DefaultName.cpp \
+ ../../../myWindows/StdAfx.h ../../../myWindows/config.h \
+ ../../../Common/MyWindows.h ../../../Common/MyGuidDef.h \
+ ../../../Common/Types.h ../../../Common/../../C/Types.h \
+ ../../../Common/Types.h ../../../include_windows/windows.h \
+ ../../../include_windows/basetyps.h ../../../include_windows/tchar.h \
+ ../../UI/Common/DefaultName.h ../../../Common/MyString.h \
+ ../../../Common/MyVector.h ../../../Common/Defs.h
+EnumDirItems.o: ../../UI/Common/EnumDirItems.cpp \
+ ../../../myWindows/StdAfx.h ../../../myWindows/config.h \
+ ../../../Common/MyWindows.h ../../../Common/MyGuidDef.h \
+ ../../../Common/Types.h ../../../Common/../../C/Types.h \
+ ../../../Common/Types.h ../../../include_windows/windows.h \
+ ../../../include_windows/basetyps.h ../../../include_windows/tchar.h \
+ ../../UI/Common/EnumDirItems.h ../../../Common/Wildcard.h \
+ ../../../Common/MyString.h ../../../Common/MyVector.h \
+ ../../../Common/Defs.h ../../../Windows/FileFind.h \
+ ../../../Windows/../Common/MyString.h ../../../Windows/FileName.h \
+ ../../../Windows/../../C/Types.h ../../../Windows/Defs.h \
+ ../../../Windows/../Common/MyWindows.h ../../UI/Common/DirItem.h \
+ ../../../Common/MyString.h ../../UI/Common/../../Archive/IArchive.h \
+ ../../UI/Common/../../Archive/../IProgress.h \
+ ../../UI/Common/../../Archive/../../Common/MyUnknown.h \
+ ../../UI/Common/../../Archive/../../Common/MyWindows.h \
+ ../../UI/Common/../../Archive/../../Common/Types.h \
+ ../../UI/Common/../../Archive/../IDecl.h \
+ ../../UI/Common/../../Archive/../IStream.h \
+ ../../UI/Common/../../Archive/../PropID.h
+Extract.o: ../../UI/Common/Extract.cpp ../../../myWindows/StdAfx.h \
+ ../../../myWindows/config.h ../../../Common/MyWindows.h \
+ ../../../Common/MyGuidDef.h ../../../Common/Types.h \
+ ../../../Common/../../C/Types.h ../../../Common/Types.h \
+ ../../../include_windows/windows.h ../../../include_windows/basetyps.h \
+ ../../../include_windows/tchar.h ../../../Windows/FileDir.h \
+ ../../../Windows/../Common/MyString.h \
+ ../../../Windows/../Common/MyVector.h ../../../Windows/../Common/Defs.h \
+ ../../../Windows/Defs.h ../../../Windows/../Common/MyWindows.h \
+ ../../../Windows/PropVariant.h ../../../Windows/../Common/Types.h \
+ ../../../Windows/PropVariantConversions.h ../../../Common/MyString.h \
+ ../../UI/Common/../Common/ExtractingFilePath.h ../../UI/Common/Extract.h \
+ ../../../Windows/FileFind.h ../../../Windows/FileName.h \
+ ../../../Windows/../../C/Types.h \
+ ../../UI/Common/../../Archive/IArchive.h \
+ ../../UI/Common/../../Archive/../IProgress.h \
+ ../../UI/Common/../../Archive/../../Common/MyUnknown.h \
+ ../../UI/Common/../../Archive/../../Common/MyWindows.h \
+ ../../UI/Common/../../Archive/../../Common/Types.h \
+ ../../UI/Common/../../Archive/../IDecl.h \
+ ../../UI/Common/../../Archive/../IStream.h \
+ ../../UI/Common/../../Archive/../PropID.h \
+ ../../UI/Common/ArchiveExtractCallback.h ../../../Common/MyCom.h \
+ ../../../Common/MyWindows.h ../../../Common/Wildcard.h \
+ ../../../Common/MyString.h ../../UI/Common/../../IPassword.h \
+ ../../UI/Common/../../../Common/MyUnknown.h \
+ ../../UI/Common/../../../Common/Types.h ../../UI/Common/../../IDecl.h \
+ ../../UI/Common/../../Common/FileStreams.h \
+ ../../UI/Common/../../Common/../../Windows/FileIO.h \
+ ../../UI/Common/../../Common/../../Common/MyCom.h \
+ ../../UI/Common/../../Common/../IStream.h \
+ ../../UI/Common/../../Common/ProgressUtils.h \
+ ../../UI/Common/../../Common/../ICoder.h \
+ ../../UI/Common/../../Common/../IStream.h \
+ ../../UI/Common/../../Common/../IProgress.h \
+ ../../UI/Common/../../Archive/Common/OutStreamWithCRC.h \
+ ../../UI/Common/../../Archive/Common/../../../../C/7zCrc.h \
+ ../../UI/Common/../../Archive/Common/../../../../C/Types.h \
+ ../../UI/Common/../../Archive/Common/../../../Common/MyCom.h \
+ ../../UI/Common/../../Archive/Common/../../IStream.h \
+ ../../UI/Common/ExtractMode.h ../../UI/Common/IFileExtractCallback.h \
+ ../../UI/Common/../../IDecl.h ../../UI/Common/OpenArchive.h \
+ ../../UI/Common/ArchiveOpenCallback.h ../../UI/Common/LoadCodecs.h \
+ ../../UI/Common/../../../Common/Types.h \
+ ../../UI/Common/../../../Common/MyCom.h \
+ ../../UI/Common/../../../Common/MyString.h \
+ ../../UI/Common/../../../Common/Buffer.h \
+ ../../UI/Common/../../../Common/Defs.h ../../UI/Common/../../ICoder.h \
+ ../../UI/Common/../../../Windows/DLL.h \
+ ../../UI/Common/../../../Windows/../Common/MyString.h \
+ ../../UI/Common/Property.h ../../UI/Common/../Common/LoadCodecs.h \
+ ../../UI/Common/SetProperties.h
+ExtractingFilePath.o: ../../UI/Common/ExtractingFilePath.cpp \
+ ../../../myWindows/StdAfx.h ../../../myWindows/config.h \
+ ../../../Common/MyWindows.h ../../../Common/MyGuidDef.h \
+ ../../../Common/Types.h ../../../Common/../../C/Types.h \
+ ../../../Common/Types.h ../../../include_windows/windows.h \
+ ../../../include_windows/basetyps.h ../../../include_windows/tchar.h \
+ ../../UI/Common/../../../../C/Types.h ../../../Common/Wildcard.h \
+ ../../../Common/MyString.h ../../../Common/MyVector.h \
+ ../../../Common/Defs.h ../../UI/Common/ExtractingFilePath.h \
+ ../../../Common/MyString.h
+Bench.o: ../../UI/Common/Bench.cpp ../../../myWindows/StdAfx.h \
+ ../../../myWindows/config.h ../../../Common/MyWindows.h \
+ ../../../Common/MyGuidDef.h ../../../Common/Types.h \
+ ../../../Common/../../C/Types.h ../../../Common/Types.h \
+ ../../../include_windows/windows.h ../../../include_windows/basetyps.h \
+ ../../../include_windows/tchar.h ../../UI/Common/Bench.h \
+ ../../UI/Common/../../Common/CreateCoder.h \
+ ../../UI/Common/../../Common/../../Common/MyCom.h \
+ ../../UI/Common/../../Common/../../Common/MyWindows.h \
+ ../../UI/Common/../../Common/../../Common/MyString.h \
+ ../../UI/Common/../../Common/../../Common/MyVector.h \
+ ../../UI/Common/../../Common/../../Common/Defs.h \
+ ../../UI/Common/../../Common/../ICoder.h \
+ ../../UI/Common/../../Common/../IStream.h \
+ ../../UI/Common/../../Common/../../Common/MyUnknown.h \
+ ../../UI/Common/../../Common/../../Common/Types.h \
+ ../../UI/Common/../../Common/../IDecl.h \
+ ../../UI/Common/../../Common/MethodId.h \
+ ../../UI/Common/../../Common/../../Common/Types.h \
+ ../../UI/Common/../../../../C/7zCrc.h \
+ ../../UI/Common/../../../../C/Types.h \
+ ../../UI/Common/../../../../C/Alloc.h \
+ ../../UI/Common/../../../Windows/Synchronization.h \
+ ../../UI/Common/../../../Windows/Defs.h \
+ ../../UI/Common/../../../Windows/../Common/MyWindows.h \
+ ../../UI/Common/../../../Windows/../../C/Threads.h \
+ ../../UI/Common/../../../Windows/../../C/Types.h \
+ ../../UI/Common/../../../Windows/Synchronization2.h \
+ ../../UI/Common/../../../Windows/Thread.h \
+ ../../UI/Common/../../../Windows/PropVariant.h \
+ ../../UI/Common/../../../Windows/../Common/Types.h
+LoadCodecs.o: ../../UI/Common/LoadCodecs.cpp ../../../myWindows/StdAfx.h \
+ ../../../myWindows/config.h ../../../Common/MyWindows.h \
+ ../../../Common/MyGuidDef.h ../../../Common/Types.h \
+ ../../../Common/../../C/Types.h ../../../Common/Types.h \
+ ../../../include_windows/windows.h ../../../include_windows/basetyps.h \
+ ../../../include_windows/tchar.h ../../UI/Common/LoadCodecs.h \
+ ../../UI/Common/../../../Common/Types.h \
+ ../../UI/Common/../../../Common/MyCom.h \
+ ../../UI/Common/../../../Common/MyWindows.h \
+ ../../UI/Common/../../../Common/MyString.h \
+ ../../UI/Common/../../../Common/MyVector.h \
+ ../../UI/Common/../../../Common/Defs.h \
+ ../../UI/Common/../../../Common/Buffer.h ../../UI/Common/../../ICoder.h \
+ ../../UI/Common/../../IStream.h \
+ ../../UI/Common/../../../Common/MyUnknown.h \
+ ../../UI/Common/../../../Common/Types.h ../../UI/Common/../../IDecl.h \
+ ../../UI/Common/../../../Windows/DLL.h \
+ ../../UI/Common/../../../Windows/../Common/MyString.h \
+ ../../UI/Common/../../Archive/IArchive.h \
+ ../../UI/Common/../../Archive/../IProgress.h \
+ ../../UI/Common/../../Archive/../../Common/MyUnknown.h \
+ ../../UI/Common/../../Archive/../../Common/Types.h \
+ ../../UI/Common/../../Archive/../IDecl.h \
+ ../../UI/Common/../../Archive/../IStream.h \
+ ../../UI/Common/../../Archive/../PropID.h \
+ ../../UI/Common/../../../Windows/PropVariant.h \
+ ../../UI/Common/../../../Windows/../Common/MyWindows.h \
+ ../../UI/Common/../../../Windows/../Common/Types.h \
+ ../../UI/Common/../../Common/RegisterArc.h \
+ ../../UI/Common/../../Common/../Archive/IArchive.h \
+ ../../UI/Common/../../../Windows/FileFind.h \
+ ../../UI/Common/../../../Windows/FileName.h \
+ ../../UI/Common/../../../Windows/../../C/Types.h \
+ ../../UI/Common/../../../Windows/Defs.h ../../../Common/StringConvert.h \
+ ../../../Common/MyWindows.h ../../../Common/MyString.h
+OpenArchive.o: ../../UI/Common/OpenArchive.cpp \
+ ../../../myWindows/StdAfx.h ../../../myWindows/config.h \
+ ../../../Common/MyWindows.h ../../../Common/MyGuidDef.h \
+ ../../../Common/Types.h ../../../Common/../../C/Types.h \
+ ../../../Common/Types.h ../../../include_windows/windows.h \
+ ../../../include_windows/basetyps.h ../../../include_windows/tchar.h \
+ ../../../Common/Wildcard.h ../../../Common/MyString.h \
+ ../../../Common/MyVector.h ../../../Common/Defs.h \
+ ../../../Windows/FileDir.h ../../../Windows/../Common/MyString.h \
+ ../../../Windows/Defs.h ../../../Windows/../Common/MyWindows.h \
+ ../../../Windows/PropVariant.h ../../../Windows/../Common/Types.h \
+ ../../UI/Common/../../Common/FileStreams.h \
+ ../../UI/Common/../../Common/../../Windows/FileIO.h \
+ ../../../Common/MyString.h \
+ ../../UI/Common/../../Common/../../Common/MyCom.h \
+ ../../UI/Common/../../Common/../../Common/MyWindows.h \
+ ../../UI/Common/../../Common/../IStream.h \
+ ../../UI/Common/../../Common/../../Common/MyUnknown.h \
+ ../../UI/Common/../../Common/../../Common/Types.h \
+ ../../UI/Common/../../Common/../IDecl.h \
+ ../../UI/Common/../../Common/StreamUtils.h ../../UI/Common/DefaultName.h \
+ ../../UI/Common/OpenArchive.h ../../../Windows/FileFind.h \
+ ../../../Windows/FileName.h ../../../Windows/../../C/Types.h \
+ ../../UI/Common/../../Archive/IArchive.h \
+ ../../UI/Common/../../Archive/../IProgress.h \
+ ../../UI/Common/../../Archive/../../Common/MyUnknown.h \
+ ../../UI/Common/../../Archive/../../Common/Types.h \
+ ../../UI/Common/../../Archive/../IDecl.h \
+ ../../UI/Common/../../Archive/../IStream.h \
+ ../../UI/Common/../../Archive/../PropID.h \
+ ../../UI/Common/ArchiveOpenCallback.h ../../../Common/MyCom.h \
+ ../../UI/Common/../../IPassword.h \
+ ../../UI/Common/../../../Common/MyUnknown.h \
+ ../../UI/Common/../../../Common/Types.h ../../UI/Common/../../IDecl.h \
+ ../../UI/Common/LoadCodecs.h ../../UI/Common/../../../Common/Types.h \
+ ../../UI/Common/../../../Common/MyCom.h \
+ ../../UI/Common/../../../Common/MyString.h \
+ ../../UI/Common/../../../Common/Buffer.h \
+ ../../UI/Common/../../../Common/Defs.h ../../UI/Common/../../ICoder.h \
+ ../../UI/Common/../../IStream.h ../../UI/Common/../../../Windows/DLL.h \
+ ../../UI/Common/../../../Windows/../Common/MyString.h
+PropIDUtils.o: ../../UI/Common/PropIDUtils.cpp \
+ ../../../myWindows/StdAfx.h ../../../myWindows/config.h \
+ ../../../Common/MyWindows.h ../../../Common/MyGuidDef.h \
+ ../../../Common/Types.h ../../../Common/../../C/Types.h \
+ ../../../Common/Types.h ../../../include_windows/windows.h \
+ ../../../include_windows/basetyps.h ../../../include_windows/tchar.h \
+ ../../../Common/IntToString.h ../../../Windows/FileFind.h \
+ ../../../Windows/../Common/MyString.h \
+ ../../../Windows/../Common/MyVector.h ../../../Windows/../Common/Defs.h \
+ ../../../Windows/FileName.h ../../../Windows/../../C/Types.h \
+ ../../../Windows/Defs.h ../../../Windows/../Common/MyWindows.h \
+ ../../../Windows/PropVariantConversions.h ../../../Common/MyString.h \
+ ../../UI/Common/../../PropID.h ../../UI/Common/PropIDUtils.h
+SetProperties.o: ../../UI/Common/SetProperties.cpp \
+ ../../../myWindows/StdAfx.h ../../../myWindows/config.h \
+ ../../../Common/MyWindows.h ../../../Common/MyGuidDef.h \
+ ../../../Common/Types.h ../../../Common/../../C/Types.h \
+ ../../../Common/Types.h ../../../include_windows/windows.h \
+ ../../../include_windows/basetyps.h ../../../include_windows/tchar.h \
+ ../../UI/Common/SetProperties.h ../../UI/Common/Property.h \
+ ../../../Common/MyString.h ../../../Common/MyVector.h \
+ ../../../Common/Defs.h ../../../Windows/PropVariant.h \
+ ../../../Windows/../Common/MyWindows.h \
+ ../../../Windows/../Common/Types.h ../../../Common/StringToInt.h \
+ ../../../Common/MyCom.h ../../../Common/MyWindows.h \
+ ../../UI/Common/../../Archive/IArchive.h \
+ ../../UI/Common/../../Archive/../IProgress.h \
+ ../../UI/Common/../../Archive/../../Common/MyUnknown.h \
+ ../../UI/Common/../../Archive/../../Common/MyWindows.h \
+ ../../UI/Common/../../Archive/../../Common/Types.h \
+ ../../UI/Common/../../Archive/../IDecl.h \
+ ../../UI/Common/../../Archive/../IStream.h \
+ ../../UI/Common/../../Archive/../PropID.h
+SortUtils.o: ../../UI/Common/SortUtils.cpp ../../../myWindows/StdAfx.h \
+ ../../../myWindows/config.h ../../../Common/MyWindows.h \
+ ../../../Common/MyGuidDef.h ../../../Common/Types.h \
+ ../../../Common/../../C/Types.h ../../../Common/Types.h \
+ ../../../include_windows/windows.h ../../../include_windows/basetyps.h \
+ ../../../include_windows/tchar.h ../../UI/Common/SortUtils.h \
+ ../../../Common/MyString.h ../../../Common/MyVector.h \
+ ../../../Common/Defs.h ../../../Common/Wildcard.h \
+ ../../../Common/MyString.h
+TempFiles.o: ../../UI/Common/TempFiles.cpp ../../../myWindows/StdAfx.h \
+ ../../../myWindows/config.h ../../../Common/MyWindows.h \
+ ../../../Common/MyGuidDef.h ../../../Common/Types.h \
+ ../../../Common/../../C/Types.h ../../../Common/Types.h \
+ ../../../include_windows/windows.h ../../../include_windows/basetyps.h \
+ ../../../include_windows/tchar.h ../../UI/Common/TempFiles.h \
+ ../../../Common/MyString.h ../../../Common/MyVector.h \
+ ../../../Common/Defs.h ../../../Windows/FileDir.h \
+ ../../../Windows/../Common/MyString.h ../../../Windows/Defs.h \
+ ../../../Windows/../Common/MyWindows.h ../../../Windows/FileIO.h
+Update.o: ../../UI/Common/Update.cpp ../../../myWindows/StdAfx.h \
+ ../../../myWindows/config.h ../../../Common/MyWindows.h \
+ ../../../Common/MyGuidDef.h ../../../Common/Types.h \
+ ../../../Common/../../C/Types.h ../../../Common/Types.h \
+ ../../../include_windows/windows.h ../../../include_windows/basetyps.h \
+ ../../../include_windows/tchar.h ../../UI/Common/Update.h \
+ ../../../Common/Wildcard.h ../../../Common/MyString.h \
+ ../../../Common/MyVector.h ../../../Common/Defs.h \
+ ../../UI/Common/ArchiveOpenCallback.h ../../../Common/MyCom.h \
+ ../../../Common/MyWindows.h ../../../Common/MyString.h \
+ ../../../Windows/FileFind.h ../../../Windows/../Common/MyString.h \
+ ../../../Windows/FileName.h ../../../Windows/../../C/Types.h \
+ ../../../Windows/Defs.h ../../../Windows/../Common/MyWindows.h \
+ ../../UI/Common/../../IPassword.h \
+ ../../UI/Common/../../../Common/MyUnknown.h \
+ ../../UI/Common/../../../Common/MyWindows.h \
+ ../../UI/Common/../../../Common/Types.h ../../UI/Common/../../IDecl.h \
+ ../../UI/Common/../../Archive/IArchive.h \
+ ../../UI/Common/../../Archive/../IProgress.h \
+ ../../UI/Common/../../Archive/../../Common/MyUnknown.h \
+ ../../UI/Common/../../Archive/../../Common/Types.h \
+ ../../UI/Common/../../Archive/../IDecl.h \
+ ../../UI/Common/../../Archive/../IStream.h \
+ ../../UI/Common/../../Archive/../PropID.h ../../UI/Common/LoadCodecs.h \
+ ../../UI/Common/../../../Common/Types.h \
+ ../../UI/Common/../../../Common/MyCom.h \
+ ../../UI/Common/../../../Common/MyString.h \
+ ../../UI/Common/../../../Common/Buffer.h \
+ ../../UI/Common/../../../Common/Defs.h ../../UI/Common/../../ICoder.h \
+ ../../UI/Common/../../IStream.h ../../UI/Common/../../../Windows/DLL.h \
+ ../../UI/Common/../../../Windows/../Common/MyString.h \
+ ../../UI/Common/Property.h ../../UI/Common/UpdateAction.h \
+ ../../UI/Common/UpdateCallback.h ../../UI/Common/../Common/UpdatePair.h \
+ ../../UI/Common/../Common/DirItem.h \
+ ../../UI/Common/../Common/../../Archive/IArchive.h \
+ ../../UI/Common/../Common/UpdateAction.h \
+ ../../UI/Common/../Common/UpdateProduce.h \
+ ../../UI/Common/../Common/UpdatePair.h ../../../Common/IntToString.h \
+ ../../../Common/StringConvert.h ../../../Windows/FileDir.h \
+ ../../../Windows/FileName.h ../../../Windows/PropVariant.h \
+ ../../../Windows/../Common/Types.h \
+ ../../../Windows/PropVariantConversions.h ../../../Windows/Time.h \
+ ../../UI/Common/../../Common/FileStreams.h \
+ ../../UI/Common/../../Common/../../Windows/FileIO.h \
+ ../../UI/Common/../../Common/../../Common/MyCom.h \
+ ../../UI/Common/../../Common/../IStream.h \
+ ../../UI/Common/../../Compress/CopyCoder.h \
+ ../../UI/Common/../../Compress/../../Common/MyCom.h \
+ ../../UI/Common/../../Compress/../ICoder.h \
+ ../../UI/Common/../Common/DirItem.h \
+ ../../UI/Common/../Common/EnumDirItems.h \
+ ../../UI/Common/../Common/OpenArchive.h \
+ ../../UI/Common/../Common/ArchiveOpenCallback.h \
+ ../../UI/Common/../Common/LoadCodecs.h ../../UI/Common/EnumDirItems.h \
+ ../../UI/Common/SetProperties.h ../../UI/Common/TempFiles.h
+UpdateAction.o: ../../UI/Common/UpdateAction.cpp \
+ ../../../myWindows/StdAfx.h ../../../myWindows/config.h \
+ ../../../Common/MyWindows.h ../../../Common/MyGuidDef.h \
+ ../../../Common/Types.h ../../../Common/../../C/Types.h \
+ ../../../Common/Types.h ../../../include_windows/windows.h \
+ ../../../include_windows/basetyps.h ../../../include_windows/tchar.h \
+ ../../UI/Common/UpdateAction.h
+UpdateCallback.o: ../../UI/Common/UpdateCallback.cpp \
+ ../../../myWindows/StdAfx.h ../../../myWindows/config.h \
+ ../../../Common/MyWindows.h ../../../Common/MyGuidDef.h \
+ ../../../Common/Types.h ../../../Common/../../C/Types.h \
+ ../../../Common/Types.h ../../../include_windows/windows.h \
+ ../../../include_windows/basetyps.h ../../../include_windows/tchar.h \
+ ../../../Common/ComTry.h ../../../Common/MyWindows.h \
+ ../../../Common/Defs.h ../../../Common/IntToString.h \
+ ../../../Common/StringConvert.h ../../../Common/MyString.h \
+ ../../../Common/MyVector.h ../../../Common/Defs.h \
+ ../../../Windows/PropVariant.h ../../../Windows/../Common/MyWindows.h \
+ ../../../Windows/../Common/Types.h \
+ ../../UI/Common/../../Common/FileStreams.h \
+ ../../UI/Common/../../Common/../../Windows/FileIO.h \
+ ../../../Common/MyString.h \
+ ../../UI/Common/../../Common/../../Common/MyCom.h \
+ ../../UI/Common/../../Common/../../Common/MyWindows.h \
+ ../../UI/Common/../../Common/../IStream.h \
+ ../../UI/Common/../../Common/../../Common/MyUnknown.h \
+ ../../UI/Common/../../Common/../../Common/Types.h \
+ ../../UI/Common/../../Common/../IDecl.h ../../UI/Common/UpdateCallback.h \
+ ../../../Common/MyCom.h ../../UI/Common/../../IPassword.h \
+ ../../UI/Common/../../../Common/MyUnknown.h \
+ ../../UI/Common/../../../Common/Types.h ../../UI/Common/../../IDecl.h \
+ ../../UI/Common/../../ICoder.h ../../UI/Common/../../IStream.h \
+ ../../UI/Common/../Common/UpdatePair.h \
+ ../../UI/Common/../Common/DirItem.h \
+ ../../UI/Common/../Common/../../Archive/IArchive.h \
+ ../../UI/Common/../Common/../../Archive/../IProgress.h \
+ ../../UI/Common/../Common/../../Archive/../../Common/MyUnknown.h \
+ ../../UI/Common/../Common/../../Archive/../../Common/Types.h \
+ ../../UI/Common/../Common/../../Archive/../IDecl.h \
+ ../../UI/Common/../Common/../../Archive/../IStream.h \
+ ../../UI/Common/../Common/../../Archive/../PropID.h \
+ ../../UI/Common/../Common/UpdateAction.h \
+ ../../UI/Common/../Common/UpdateProduce.h \
+ ../../UI/Common/../Common/UpdatePair.h
+UpdatePair.o: ../../UI/Common/UpdatePair.cpp ../../../myWindows/StdAfx.h \
+ ../../../myWindows/config.h ../../../Common/MyWindows.h \
+ ../../../Common/MyGuidDef.h ../../../Common/Types.h \
+ ../../../Common/../../C/Types.h ../../../Common/Types.h \
+ ../../../include_windows/windows.h ../../../include_windows/basetyps.h \
+ ../../../include_windows/tchar.h ../../../Common/Defs.h \
+ ../../../Common/Wildcard.h ../../../Common/MyString.h \
+ ../../../Common/MyVector.h ../../../Common/Defs.h \
+ ../../../Windows/Time.h ../../UI/Common/SortUtils.h \
+ ../../../Common/MyString.h ../../UI/Common/UpdatePair.h \
+ ../../UI/Common/DirItem.h ../../UI/Common/../../Archive/IArchive.h \
+ ../../UI/Common/../../Archive/../IProgress.h \
+ ../../UI/Common/../../Archive/../../Common/MyUnknown.h \
+ ../../UI/Common/../../Archive/../../Common/MyWindows.h \
+ ../../UI/Common/../../Archive/../../Common/Types.h \
+ ../../UI/Common/../../Archive/../IDecl.h \
+ ../../UI/Common/../../Archive/../IStream.h \
+ ../../UI/Common/../../Archive/../PropID.h ../../UI/Common/UpdateAction.h
+UpdateProduce.o: ../../UI/Common/UpdateProduce.cpp \
+ ../../../myWindows/StdAfx.h ../../../myWindows/config.h \
+ ../../../Common/MyWindows.h ../../../Common/MyGuidDef.h \
+ ../../../Common/Types.h ../../../Common/../../C/Types.h \
+ ../../../Common/Types.h ../../../include_windows/windows.h \
+ ../../../include_windows/basetyps.h ../../../include_windows/tchar.h \
+ ../../UI/Common/UpdateProduce.h ../../UI/Common/UpdatePair.h \
+ ../../UI/Common/DirItem.h ../../../Common/MyString.h \
+ ../../../Common/MyVector.h ../../../Common/Defs.h \
+ ../../UI/Common/../../Archive/IArchive.h \
+ ../../UI/Common/../../Archive/../IProgress.h \
+ ../../UI/Common/../../Archive/../../Common/MyUnknown.h \
+ ../../UI/Common/../../Archive/../../Common/MyWindows.h \
+ ../../UI/Common/../../Archive/../../Common/Types.h \
+ ../../UI/Common/../../Archive/../IDecl.h \
+ ../../UI/Common/../../Archive/../IStream.h \
+ ../../UI/Common/../../Archive/../PropID.h ../../UI/Common/UpdateAction.h
+OutStreamWithCRC.o: ../../Archive/Common/OutStreamWithCRC.cpp \
+ ../../../myWindows/StdAfx.h ../../../myWindows/config.h \
+ ../../../Common/MyWindows.h ../../../Common/MyGuidDef.h \
+ ../../../Common/Types.h ../../../Common/../../C/Types.h \
+ ../../../Common/Types.h ../../../include_windows/windows.h \
+ ../../../include_windows/basetyps.h ../../../include_windows/tchar.h \
+ ../../Archive/Common/OutStreamWithCRC.h \
+ ../../Archive/Common/../../../../C/7zCrc.h \
+ ../../Archive/Common/../../../../C/Types.h \
+ ../../Archive/Common/../../../Common/MyCom.h \
+ ../../Archive/Common/../../../Common/MyWindows.h \
+ ../../Archive/Common/../../IStream.h \
+ ../../Archive/Common/../../../Common/MyUnknown.h \
+ ../../Archive/Common/../../../Common/Types.h \
+ ../../Archive/Common/../../IDecl.h
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/makefile.list
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/makefile.list?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/makefile.list (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Console/makefile.list Sun Dec 16 23:23:25 2012
@@ -0,0 +1,81 @@
+SRCS=\
+ ../../../myWindows/myAddExeFlag.cpp \
+ ../../../myWindows/mySplitCommandLine.cpp \
+ ../../../myWindows/wine_date_and_time.cpp \
+ \
+ ../../UI/Console/ConsoleClose.cpp \
+ ../../UI/Console/ExtractCallbackConsole.cpp \
+ ../../UI/Console/BenchCon.cpp \
+ ../../UI/Console/List.cpp \
+ ../../UI/Console/Main.cpp \
+ ../../UI/Console/MainAr.cpp \
+ ../../UI/Console/OpenCallbackConsole.cpp \
+ ../../UI/Console/PercentPrinter.cpp \
+ ../../UI/Console/UpdateCallbackConsole.cpp \
+ ../../UI/Console/UserInputUtils.cpp \
+ \
+ ../../../Common/CommandLineParser.cpp \
+ ../../../Common/CRC.cpp \
+ ../../../Common/IntToString.cpp \
+ ../../../Common/ListFileUtils.cpp \
+ ../../../Common/StdInStream.cpp \
+ ../../../Common/StdOutStream.cpp \
+ ../../../Common/MyString.cpp \
+ ../../../Common/MyWindows.cpp \
+ ../../../Common/StringConvert.cpp \
+ ../../../Common/StringToInt.cpp \
+ ../../../Common/UTFConvert.cpp \
+ ../../../Common/MyVector.cpp \
+ ../../../Common/Wildcard.cpp \
+ \
+ ../../../Windows/DLL.cpp \
+ ../../../Windows/Error.cpp \
+ ../../../Windows/FileDir.cpp \
+ ../../../Windows/FileFind.cpp \
+ ../../../Windows/FileIO.cpp \
+ ../../../Windows/FileName.cpp \
+ ../../../Windows/PropVariant.cpp \
+ ../../../Windows/PropVariantConversions.cpp \
+ ../../../Windows/System.cpp \
+ ../../../Windows/Time.cpp \
+ \
+ ../../Common/CreateCoder.cpp \
+ ../../Common/FilePathAutoRename.cpp \
+ ../../Common/FileStreams.cpp \
+ ../../Common/FilterCoder.cpp \
+ ../../Common/ProgressUtils.cpp \
+ ../../Common/StreamUtils.cpp \
+ \
+ ../../UI/Common/ArchiveCommandLine.cpp \
+ ../../UI/Common/ArchiveExtractCallback.cpp \
+ ../../UI/Common/ArchiveOpenCallback.cpp \
+ ../../UI/Common/DefaultName.cpp \
+ ../../UI/Common/EnumDirItems.cpp \
+ ../../UI/Common/Extract.cpp \
+ ../../UI/Common/ExtractingFilePath.cpp \
+ ../../UI/Common/Bench.cpp \
+ ../../UI/Common/LoadCodecs.cpp \
+ ../../UI/Common/OpenArchive.cpp \
+ ../../UI/Common/PropIDUtils.cpp \
+ ../../UI/Common/SetProperties.cpp \
+ ../../UI/Common/SortUtils.cpp \
+ ../../UI/Common/TempFiles.cpp \
+ ../../UI/Common/Update.cpp \
+ ../../UI/Common/UpdateAction.cpp \
+ ../../UI/Common/UpdateCallback.cpp \
+ ../../UI/Common/UpdatePair.cpp \
+ ../../UI/Common/UpdateProduce.cpp \
+ \
+ ../../Archive/Common/OutStreamWithCRC.cpp
+
+
+
+SRCS_C=\
+ ../../../../C/Alloc.c \
+ ../../../../C/Threads.c \
+
+include ../../../../makefile.rules
+
+Main.o : ../../UI/Console/Main.cpp
+ $(CXX) $(CXXFLAGS) ../../UI/Console/Main.cpp
+
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Explorer/ContextMenu.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Explorer/ContextMenu.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Explorer/ContextMenu.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Explorer/ContextMenu.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,5 @@
+
+
+/* TODO */
+
+
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Explorer/MyMessages.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Explorer/MyMessages.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Explorer/MyMessages.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Explorer/MyMessages.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,58 @@
+// MyMessages.cpp
+
+#include "StdAfx.h"
+
+#include "MyMessages.h"
+
+#include "Windows/Error.h"
+#include "Windows/ResourceString.h"
+
+#ifdef LANG
+#include "../FileManager/LangUtils.h"
+#endif
+
+using namespace NWindows;
+
+void ShowErrorMessage(HWND window, LPCWSTR message)
+{
+ ::MessageBoxW(window, message, L"7-Zip", MB_OK | MB_ICONSTOP);
+}
+
+void ShowErrorMessageHwndRes(HWND window, UINT resID
+ #ifdef LANG
+ , UInt32 langID
+ #endif
+ )
+{
+ ShowErrorMessage(window,
+ #ifdef LANG
+ LangString(resID, langID)
+ #else
+ MyLoadStringW(resID)
+ #endif
+ );
+}
+
+void ShowErrorMessageRes(UINT resID
+ #ifdef LANG
+ , UInt32 langID
+ #endif
+ )
+{
+ ShowErrorMessageHwndRes(0, resID
+ #ifdef LANG
+ , langID
+ #endif
+ );
+}
+
+void ShowErrorMessageDWORD(HWND window, DWORD errorCode)
+{
+ ShowErrorMessage(window, NError::MyFormatMessageW(errorCode));
+}
+
+void ShowLastErrorMessage(HWND window)
+{
+ ShowErrorMessageDWORD(window, ::GetLastError());
+}
+
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Explorer/MyMessages.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Explorer/MyMessages.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Explorer/MyMessages.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Explorer/MyMessages.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,28 @@
+// MyMessages.h
+
+#ifndef __MYMESSAGES_H
+#define __MYMESSAGES_H
+
+#include "Common/MyString.h"
+#include "Common/Types.h"
+
+void ShowErrorMessage(HWND window, LPCWSTR message);
+inline void ShowErrorMessage(LPCWSTR message) { ShowErrorMessage(0, message); }
+
+void ShowErrorMessageHwndRes(HWND window, UINT resID
+ #ifdef LANG
+ , UInt32 langID
+ #endif
+ );
+
+void ShowErrorMessageRes(UINT resID
+ #ifdef LANG
+ , UInt32 langID
+ #endif
+ );
+
+// void ShowErrorMessageDWORD(HWND window, DWORD errorCode);
+// inline void ErrorMessageDWORD(DWORD errorCode) { ShowErrorMessageDWORD(0, errorCode); }
+void ShowLastErrorMessage(HWND window = 0);
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/App.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/App.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/App.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/App.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,852 @@
+// App.cpp
+
+#include "StdAfx.h"
+
+#include "resource.h"
+#include "OverwriteDialogRes.h"
+
+#include "Common/IntToString.h"
+#include "Common/StringConvert.h"
+
+#include "Windows/COM.h"
+#include "Windows/Error.h"
+#include "Windows/FileDir.h"
+#include "Windows/PropVariant.h"
+#include "Windows/PropVariantConversions.h"
+#include "Windows/Thread.h"
+
+#include "App.h"
+#include "CopyDialog.h"
+#include "ExtractCallback.h"
+#include "FormatUtils.h"
+#include "IFolder.h"
+#include "LangUtils.h"
+#include "RegistryUtils.h"
+#include "ViewSettings.h"
+
+using namespace NWindows;
+using namespace NFile;
+using namespace NFind;
+
+extern DWORD g_ComCtl32Version;
+extern HINSTANCE g_hInstance;
+
+static LPCWSTR kTempDirPrefix = L"7zE";
+
+void CPanelCallbackImp::OnTab()
+{
+ if (g_App.NumPanels != 1)
+ _app->Panels[1 - _index].SetFocusToList();
+ _app->RefreshTitle();
+}
+
+void CPanelCallbackImp::SetFocusToPath(int index)
+{
+ int newPanelIndex = index;
+ if (g_App.NumPanels == 1)
+ newPanelIndex = g_App.LastFocusedPanel;
+ _app->RefreshTitle();
+ // _app->Panels[newPanelIndex]._headerComboBox.SetFocus();
+ // _app->Panels[newPanelIndex]._headerComboBox.ShowDropDown();
+}
+
+
+void CPanelCallbackImp::OnCopy(bool move, bool copyToSame) { _app->OnCopy(move, copyToSame, _index); }
+void CPanelCallbackImp::OnSetSameFolder() { _app->OnSetSameFolder(_index); }
+void CPanelCallbackImp::OnSetSubFolder() { _app->OnSetSubFolder(_index); }
+void CPanelCallbackImp::PanelWasFocused() { _app->SetFocusedPanel(_index); _app->RefreshTitle(_index); }
+void CPanelCallbackImp::DragBegin() { _app->DragBegin(_index); }
+void CPanelCallbackImp::DragEnd() { _app->DragEnd(); }
+void CPanelCallbackImp::RefreshTitle(bool always) { _app->RefreshTitle(_index, always); }
+
+void CApp::SetListSettings()
+{
+ bool showDots = ReadShowDots();
+ bool showRealFileIcons = ReadShowRealFileIcons();
+
+ DWORD extendedStyle =0; /* FIXME = LVS_EX_HEADERDRAGDROP;
+ if (ReadFullRow())
+ extendedStyle |= LVS_EX_FULLROWSELECT;
+ if (ReadShowGrid())
+ extendedStyle |= LVS_EX_GRIDLINES;
+ */
+ bool mySelectionMode = ReadAlternativeSelection();
+
+#ifdef _WIN32
+ if (ReadSingleClick())
+ {
+ extendedStyle |= LVS_EX_ONECLICKACTIVATE | LVS_EX_TRACKSELECT;
+ /*
+ if (ReadUnderline())
+ extendedStyle |= LVS_EX_UNDERLINEHOT;
+ */
+ }
+#endif
+
+ for (int i = 0; i < kNumPanelsMax; i++)
+ {
+ CPanel &panel = Panels[i];
+ panel._mySelectMode = mySelectionMode;
+ panel._showDots = showDots;
+ panel._showRealFileIcons = showRealFileIcons;
+ panel._exStyle = extendedStyle;
+
+ /* FIXME
+ DWORD style = (DWORD)panel._listView.GetStyle();
+ if (mySelectionMode)
+ style |= LVS_SINGLESEL;
+ else
+ style &= ~LVS_SINGLESEL;
+ panel._listView.SetStyle(style);
+ */
+ panel.SetExtendedStyle();
+ }
+}
+
+void CApp::SetShowSystemMenu()
+{
+ ShowSystemMenu = ReadShowSystemMenu();
+}
+
+#ifndef ILC_COLOR32
+#define ILC_COLOR32 0x0020
+#endif
+
+HRESULT CApp::CreateOnePanel(int panelIndex, const UString &mainPath, const UString &arcFormat,
+ bool &archiveIsOpened, bool &encrypted)
+{
+ if (PanelsCreated[panelIndex])
+ return S_OK;
+ m_PanelCallbackImp[panelIndex].Init(this, panelIndex);
+ UString path;
+ if (mainPath.IsEmpty())
+ {
+ if (!::ReadPanelPath(panelIndex, path))
+ path.Empty();
+ }
+ else
+ path = mainPath;
+ int id = 1000 + 100 * panelIndex;
+ RINOK(Panels[panelIndex].Create(_window, _window,
+ id, path, arcFormat, &m_PanelCallbackImp[panelIndex], &AppState, archiveIsOpened, encrypted));
+ PanelsCreated[panelIndex] = true;
+ return S_OK;
+}
+
+#if _WIN32
+static void CreateToolbar(HWND parent,
+ NWindows::NControl::CImageList &imageList,
+ NWindows::NControl::CToolBar &toolBar,
+ bool largeButtons)
+{
+ toolBar.Attach(::CreateWindowEx(0, TOOLBARCLASSNAME, NULL, 0
+ | WS_CHILD
+ | WS_VISIBLE
+ | TBSTYLE_FLAT
+ | TBSTYLE_TOOLTIPS
+ | TBSTYLE_WRAPABLE
+ // | TBSTYLE_AUTOSIZE
+ // | CCS_NORESIZE
+ #ifdef UNDER_CE
+ | CCS_NODIVIDER
+ | CCS_NOPARENTALIGN
+ #endif
+ ,0,0,0,0, parent, NULL, g_hInstance, NULL));
+
+ // TB_BUTTONSTRUCTSIZE message, which is required for
+ // backward compatibility.
+ toolBar.ButtonStructSize();
+
+ imageList.Create(
+ largeButtons ? 48: 24,
+ largeButtons ? 36: 24,
+ ILC_MASK | ILC_COLOR32, 0, 0);
+ toolBar.SetImageList(0, imageList);
+}
+#endif
+
+struct CButtonInfo
+{
+ int CommandID;
+ UINT BitmapResID;
+ UINT Bitmap2ResID;
+ UINT StringResID;
+ UInt32 LangID;
+ UString GetText() const { return LangString(StringResID, LangID); }
+};
+
+static CButtonInfo g_StandardButtons[] =
+{
+ { IDM_COPY_TO, IDB_COPY, IDB_COPY2, IDS_BUTTON_COPY, 0x03020420},
+ { IDM_MOVE_TO, IDB_MOVE, IDB_MOVE2, IDS_BUTTON_MOVE, 0x03020421},
+ { IDM_DELETE, IDB_DELETE, IDB_DELETE2, IDS_BUTTON_DELETE, 0x03020422} ,
+ { IDM_FILE_PROPERTIES, IDB_INFO, IDB_INFO2, IDS_BUTTON_INFO, 0x03020423}
+};
+
+static CButtonInfo g_ArchiveButtons[] =
+{
+ { kAddCommand, IDB_ADD, IDB_ADD2, IDS_ADD, 0x03020400},
+ { kExtractCommand, IDB_EXTRACT, IDB_EXTRACT2, IDS_EXTRACT, 0x03020401},
+ { kTestCommand , IDB_TEST, IDB_TEST2, IDS_TEST, 0x03020402}
+};
+
+static bool SetButtonText(int commandID, CButtonInfo *buttons, int numButtons, UString &s)
+{
+ for (int i = 0; i < numButtons; i++)
+ {
+ const CButtonInfo &b = buttons[i];
+ if (b.CommandID == commandID)
+ {
+ s = b.GetText();
+ return true;
+ }
+ }
+ return false;
+}
+
+static void SetButtonText(int commandID, UString &s)
+{
+ if (SetButtonText(commandID, g_StandardButtons,
+ sizeof(g_StandardButtons) / sizeof(g_StandardButtons[0]), s))
+ return;
+ SetButtonText(commandID, g_ArchiveButtons,
+ sizeof(g_ArchiveButtons) / sizeof(g_ArchiveButtons[0]), s);
+}
+
+#ifdef _WIN32
+static void AddButton(
+ NControl::CImageList &imageList,
+ NControl::CToolBar &toolBar,
+ CButtonInfo &butInfo, bool showText, bool large)
+{
+ TBBUTTON but;
+ but.iBitmap = 0;
+ but.idCommand = butInfo.CommandID;
+ but.fsState = TBSTATE_ENABLED;
+ but.fsStyle = TBSTYLE_BUTTON;
+ but.dwData = 0;
+
+ UString s = butInfo.GetText();
+ but.iString = 0;
+ if (showText)
+ but.iString = (INT_PTR)(LPCWSTR)s;
+
+ but.iBitmap = imageList.GetImageCount();
+ HBITMAP b = ::LoadBitmap(g_hInstance,
+ large ?
+ MAKEINTRESOURCE(butInfo.BitmapResID):
+ MAKEINTRESOURCE(butInfo.Bitmap2ResID));
+ if (b != 0)
+ {
+ imageList.AddMasked(b, RGB(255, 0, 255));
+ ::DeleteObject(b);
+ }
+ #ifdef _UNICODE
+ toolBar.AddButton(1, &but);
+ #else
+ toolBar.AddButtonW(1, &but);
+ #endif
+}
+
+void CApp::ReloadToolbars()
+{
+ _buttonsImageList.Destroy();
+ _toolBar.Destroy();
+
+
+ if (ShowArchiveToolbar || ShowStandardToolbar)
+ {
+ CreateToolbar(_window, _buttonsImageList, _toolBar, LargeButtons);
+ int i;
+ if (ShowArchiveToolbar)
+ for (i = 0; i < sizeof(g_ArchiveButtons) / sizeof(g_ArchiveButtons[0]); i++)
+ AddButton(_buttonsImageList, _toolBar, g_ArchiveButtons[i], ShowButtonsLables, LargeButtons);
+ if (ShowStandardToolbar)
+ for (i = 0; i < sizeof(g_StandardButtons) / sizeof(g_StandardButtons[0]); i++)
+ AddButton(_buttonsImageList, _toolBar, g_StandardButtons[i], ShowButtonsLables, LargeButtons);
+
+ _toolBar.AutoSize();
+ }
+}
+#endif
+
+void CApp::SaveToolbarChanges()
+{
+#ifdef _WIN32
+ SaveToolbar();
+ ReloadToolbars();
+ MoveSubWindows();
+#endif // #ifdef _WIN32
+}
+
+void MyLoadMenu();
+
+HRESULT CApp::Create(HWND hwnd, const UString &mainPath, const UString &arcFormat, int xSizes[2], bool &archiveIsOpened, bool &encrypted)
+{
+ _window.Attach(hwnd);
+#ifdef _WIN32
+ ReadToolbar();
+ ReloadToolbars();
+#endif
+
+ int i;
+ for (i = 0; i < kNumPanelsMax; i++)
+ PanelsCreated[i] = false;
+
+ AppState.Read();
+ SetListSettings();
+ SetShowSystemMenu();
+ if (LastFocusedPanel >= kNumPanelsMax)
+ LastFocusedPanel = 0;
+
+ CListMode listMode;
+ ReadListMode(listMode);
+ for (i = 0; i < kNumPanelsMax; i++)
+ {
+ CPanel &panel = Panels[i];
+ panel._ListViewMode = listMode.Panels[i];
+ panel._xSize = xSizes[i];
+ panel._flatModeForArc = ReadFlatView(i);
+ }
+ for (i = 0; i < kNumPanelsMax; i++)
+ if (NumPanels > 1 || i == LastFocusedPanel)
+ {
+ if (NumPanels == 1)
+ Panels[i]._xSize = xSizes[0] + xSizes[1];
+ bool archiveIsOpened2 = false;
+ bool encrypted2 = false;
+ bool mainPanel = (i == LastFocusedPanel);
+ RINOK(CreateOnePanel(i, mainPanel ? mainPath : L"", arcFormat, archiveIsOpened2, encrypted2));
+ if (mainPanel)
+ {
+ archiveIsOpened = archiveIsOpened2;
+ encrypted = encrypted2;
+ }
+ }
+ SetFocusedPanel(LastFocusedPanel);
+ Panels[LastFocusedPanel].SetFocusToList();
+ return S_OK;
+}
+
+HRESULT CApp::SwitchOnOffOnePanel()
+{
+ if (NumPanels == 1)
+ {
+ NumPanels++;
+ bool archiveIsOpened, encrypted;
+ RINOK(CreateOnePanel(1 - LastFocusedPanel, UString(), UString(), archiveIsOpened, encrypted));
+ // FIXME Panels[1 - LastFocusedPanel].Enable(true);
+ // FIXME Panels[1 - LastFocusedPanel].Show(SW_SHOWNORMAL);
+ }
+ else
+ {
+ NumPanels--;
+ // FIXME Panels[1 - LastFocusedPanel].Enable(false);
+ // FIXME Panels[1 - LastFocusedPanel].Show(SW_HIDE);
+ }
+ MoveSubWindows();
+ return S_OK;
+}
+
+void CApp::Save()
+{
+ AppState.Save();
+ CListMode listMode;
+ for (int i = 0; i < kNumPanelsMax; i++)
+ {
+ const CPanel &panel = Panels[i];
+ UString path;
+ if (panel._parentFolders.IsEmpty())
+ path = panel._currentFolderPrefix;
+ else
+ path = GetFolderPath(panel._parentFolders[0].ParentFolder);
+ SavePanelPath(i, path);
+ listMode.Panels[i] = panel.GetListViewMode();
+ SaveFlatView(i, panel._flatModeForArc);
+ }
+ SaveListMode(listMode);
+}
+
+void CApp::Release()
+{
+ // It's for unloading COM dll's: don't change it.
+ for (int i = 0; i < kNumPanelsMax; i++)
+ Panels[i].Release();
+}
+
+// reduces path to part that exists on disk
+static void ReducePathToRealFileSystemPath(UString &path)
+{
+ while (!path.IsEmpty())
+ {
+ if (NFind::DoesDirExist(path))
+ {
+ NName::NormalizeDirPathPrefix(path);
+ break;
+ }
+ int pos = path.ReverseFind(WCHAR_PATH_SEPARATOR);
+ if (pos < 0)
+ path.Empty();
+ else
+ {
+ path = path.Left(pos + 1);
+ if (path.Length() == 3 && path[1] == L':')
+ break;
+ if (path.Length() > 2 && path[0] == WCHAR_PATH_SEPARATOR && path[1] == WCHAR_PATH_SEPARATOR)
+ {
+ int nextPos = path.Find(WCHAR_PATH_SEPARATOR, 2); // pos after \\COMPNAME
+ if (nextPos > 0 && path.Find(WCHAR_PATH_SEPARATOR, nextPos + 1) == pos)
+ break;
+ }
+ path = path.Left(pos);
+ }
+ }
+}
+
+// return true for dir\, if dir exist
+static bool CheckFolderPath(const UString &path)
+{
+ UString pathReduced = path;
+ ReducePathToRealFileSystemPath(pathReduced);
+ return (pathReduced == path);
+}
+
+static bool IsPathAbsolute(const UString &path)
+{
+ if (path.Length() >= 1 && path[0] == WCHAR_PATH_SEPARATOR)
+ return true;
+// #ifdef _WIN32
+ if (path.Length() >= 3 && path[1] == L':' && path[2] == L'\\')
+ return true;
+// #endif
+ return false;
+}
+
+extern UString ConvertSizeToString(UInt64 value);
+
+static UString AddSizeValue(UInt64 size)
+{
+ return MyFormatNew(IDS_FILE_SIZE, 0x02000982, ConvertSizeToString(size));
+}
+
+static void AddValuePair1(UINT resourceID, UInt32 langID, UInt64 size, UString &s)
+{
+ s += LangString(resourceID, langID);
+ s += L" ";
+ s += AddSizeValue(size);
+ s += L"\n";
+}
+
+void AddValuePair2(UINT resourceID, UInt32 langID, UInt64 num, UInt64 size, UString &s)
+{
+ if (num == 0)
+ return;
+ s += LangString(resourceID, langID);
+ s += L" ";
+ s += ConvertSizeToString(num);
+
+ if (size != (UInt64)(Int64)-1)
+ {
+ s += L" ( ";
+ s += AddSizeValue(size);
+ s += L" )";
+ }
+ s += L"\n";
+}
+
+static void AddPropValueToSum(IFolderFolder *folder, int index, PROPID propID, UInt64 &sum)
+{
+ if (sum == (UInt64)(Int64)-1)
+ return;
+ NCOM::CPropVariant prop;
+ folder->GetProperty(index, propID, &prop);
+ switch(prop.vt)
+ {
+ case VT_UI4:
+ case VT_UI8:
+ sum += ConvertPropVariantToUInt64(prop);
+ break;
+ default:
+ sum = (UInt64)(Int64)-1;
+ }
+}
+
+UString CPanel::GetItemsInfoString(const CRecordVector<UInt32> &indices)
+{
+ UString info;
+ UInt64 numDirs, numFiles, filesSize, foldersSize;
+ numDirs = numFiles = filesSize = foldersSize = 0;
+ int i;
+ for (i = 0; i < indices.Size(); i++)
+ {
+ int index = indices[i];
+ if (IsItemFolder(index))
+ {
+ AddPropValueToSum(_folder, index, kpidSize, foldersSize);
+ numDirs++;
+ }
+ else
+ {
+ AddPropValueToSum(_folder, index, kpidSize, filesSize);
+ numFiles++;
+ }
+ }
+
+ AddValuePair2(IDS_FOLDERS_COLON, 0x02000321, numDirs, foldersSize, info);
+ AddValuePair2(IDS_FILES_COLON, 0x02000320, numFiles, filesSize, info);
+ int numDefined = ((foldersSize != (UInt64)(Int64)-1) && foldersSize != 0) ? 1: 0;
+ numDefined += ((filesSize != (UInt64)(Int64)-1) && filesSize != 0) ? 1: 0;
+ if (numDefined == 2)
+ AddValuePair1(IDS_SIZE_COLON, 0x02000322, filesSize + foldersSize, info);
+
+ info += L"\n";
+#ifdef _WIN32
+ info += _currentFolderPrefix;
+#else
+ {
+ extern const TCHAR * nameWindowToUnix(const TCHAR * lpFileName);
+
+ UString tmp = nameWindowToUnix(_currentFolderPrefix);
+
+ info += tmp;
+ }
+#endif
+
+
+ for (i = 0; i < indices.Size() && i < kCopyDialog_NumInfoLines - 6; i++)
+ {
+ info += L"\n ";
+ int index = indices[i];
+ info += GetItemRelPath(index);
+ if (IsItemFolder(index))
+ info += WCHAR_PATH_SEPARATOR;
+ }
+ if (i != indices.Size())
+ info += L"\n ...";
+ return info;
+}
+
+void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex)
+{
+ int destPanelIndex = (NumPanels <= 1) ? srcPanelIndex : (1 - srcPanelIndex);
+ CPanel &srcPanel = Panels[srcPanelIndex];
+ CPanel &destPanel = Panels[destPanelIndex];
+
+ CPanel::CDisableTimerProcessing disableTimerProcessing1(destPanel);
+ CPanel::CDisableTimerProcessing disableTimerProcessing2(srcPanel);
+
+ if (!srcPanel.DoesItSupportOperations())
+ {
+ srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
+ return;
+ }
+
+ CRecordVector<UInt32> indices;
+ UString destPath;
+ bool useDestPanel = false;
+
+ {
+ if (copyToSame)
+ {
+ int focusedItem = srcPanel._listView.GetFocusedItem();
+ if (focusedItem < 0)
+ return;
+ int realIndex = srcPanel.GetRealItemIndex(focusedItem);
+ if (realIndex == kParentIndex)
+ return;
+ indices.Add(realIndex);
+ destPath = srcPanel.GetItemName(realIndex);
+ }
+ else
+ {
+ srcPanel.GetOperatedIndicesSmart(indices);
+ if (indices.Size() == 0)
+ return;
+ destPath = destPanel._currentFolderPrefix;
+ if (NumPanels == 1)
+ ReducePathToRealFileSystemPath(destPath);
+ }
+
+ CCopyDialog copyDialog;
+ UStringVector copyFolders;
+ ReadCopyHistory(copyFolders);
+
+ copyDialog.Strings = copyFolders;
+ copyDialog.Value = destPath;
+
+ copyDialog.Title = move ?
+ LangString(IDS_MOVE, 0x03020202):
+ LangString(IDS_COPY, 0x03020201);
+ copyDialog.Static = move ?
+ LangString(IDS_MOVE_TO, 0x03020204):
+ LangString(IDS_COPY_TO, 0x03020203);
+
+ copyDialog.Info = srcPanel.GetItemsInfoString(indices);
+
+ if (copyDialog.Create(srcPanel.GetParent()) == IDCANCEL)
+ return;
+
+ destPath = copyDialog.Value;
+
+ if (destPath.IsEmpty())
+ {
+ srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
+ return;
+ }
+
+ if (!IsPathAbsolute(destPath))
+ {
+ if (!srcPanel.IsFSFolder())
+ {
+ srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
+ return;
+ }
+ destPath = srcPanel._currentFolderPrefix + destPath;
+ }
+
+ #ifndef UNDER_CE
+ if (destPath.Length() > 0 && destPath[0] == '\\')
+ if (destPath.Length() == 1 || destPath[1] != '\\')
+ {
+ srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
+ return;
+ }
+ #endif
+
+ if (indices.Size() > 1 ||
+ (!destPath.IsEmpty() && destPath.Back() == WCHAR_PATH_SEPARATOR) ||
+ NFind::DoesDirExist(destPath) ||
+ srcPanel.IsArcFolder())
+ {
+ NDirectory::CreateComplexDirectory(destPath);
+ NName::NormalizeDirPathPrefix(destPath);
+ if (!CheckFolderPath(destPath))
+ {
+ if (NumPanels < 2 || destPath != destPanel._currentFolderPrefix || !destPanel.DoesItSupportOperations())
+ {
+ srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
+ return;
+ }
+ useDestPanel = true;
+ }
+ }
+ else
+ {
+ int pos = destPath.ReverseFind(WCHAR_PATH_SEPARATOR);
+ if (pos >= 0)
+ {
+ UString prefix = destPath.Left(pos + 1);
+ NDirectory::CreateComplexDirectory(prefix);
+ if (!CheckFolderPath(prefix))
+ {
+ srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
+ return;
+ }
+ }
+ }
+
+ AddUniqueStringToHeadOfList(copyFolders, destPath);
+ while (copyFolders.Size() > 20)
+ copyFolders.DeleteBack();
+ SaveCopyHistory(copyFolders);
+ }
+
+ /*
+ if (destPath == destPanel._currentFolderPrefix)
+ {
+ if (destPanel.GetFolderTypeID() == L"PhysDrive")
+ useDestPanel = true;
+ }
+ */
+
+ bool useSrcPanel = (!useDestPanel || !srcPanel.IsFsOrDrivesFolder() || destPanel.IsFSFolder());
+ bool useTemp = useSrcPanel && useDestPanel;
+ NFile::NDirectory::CTempDirectoryW tempDirectory;
+ UString tempDirPrefix;
+ if (useTemp)
+ {
+ tempDirectory.Create(kTempDirPrefix);
+ tempDirPrefix = tempDirectory.GetPath();
+ NFile::NName::NormalizeDirPathPrefix(tempDirPrefix);
+ }
+
+ CSelectedState srcSelState;
+ CSelectedState destSelState;
+ srcPanel.SaveSelectedState(srcSelState);
+ destPanel.SaveSelectedState(destSelState);
+
+ HRESULT result;
+ if (useSrcPanel)
+ {
+ UString folder = useTemp ? tempDirPrefix : destPath;
+ result = srcPanel.CopyTo(indices, folder, move, true, 0);
+ if (result != S_OK)
+ {
+ disableTimerProcessing1.Restore();
+ disableTimerProcessing2.Restore();
+ // For Password:
+ srcPanel.SetFocusToList();
+ if (result != E_ABORT)
+ srcPanel.MessageBoxError(result, L"Error");
+ return;
+ }
+ }
+
+ if (useDestPanel)
+ {
+ UStringVector filePaths;
+ UString folderPrefix;
+ if (useTemp)
+ folderPrefix = tempDirPrefix;
+ else
+ folderPrefix = srcPanel._currentFolderPrefix;
+ filePaths.Reserve(indices.Size());
+ for (int i = 0; i < indices.Size(); i++)
+ filePaths.Add(srcPanel.GetItemRelPath(indices[i]));
+
+ result = destPanel.CopyFrom(folderPrefix, filePaths, true, 0);
+
+ if (result != S_OK)
+ {
+ disableTimerProcessing1.Restore();
+ disableTimerProcessing2.Restore();
+ // For Password:
+ srcPanel.SetFocusToList();
+ if (result != E_ABORT)
+ srcPanel.MessageBoxError(result, L"Error");
+ return;
+ }
+ }
+
+ RefreshTitleAlways();
+ if (copyToSame || move)
+ {
+ srcPanel.RefreshListCtrl(srcSelState);
+ }
+ if (!copyToSame)
+ {
+ destPanel.RefreshListCtrl(destSelState);
+ srcPanel.KillSelection();
+ }
+ disableTimerProcessing1.Restore();
+ disableTimerProcessing2.Restore();
+ srcPanel.SetFocusToList();
+}
+
+void CApp::OnSetSameFolder(int srcPanelIndex)
+{
+ if (NumPanels <= 1)
+ return;
+ const CPanel &srcPanel = Panels[srcPanelIndex];
+ CPanel &destPanel = Panels[1 - srcPanelIndex];
+ destPanel.BindToPathAndRefresh(srcPanel._currentFolderPrefix);
+}
+
+void CApp::OnSetSubFolder(int srcPanelIndex)
+{
+ if (NumPanels <= 1)
+ return;
+ const CPanel &srcPanel = Panels[srcPanelIndex];
+ CPanel &destPanel = Panels[1 - srcPanelIndex];
+
+ int focusedItem = srcPanel._listView.GetFocusedItem();
+ if (focusedItem < 0)
+ return;
+ int realIndex = srcPanel.GetRealItemIndex(focusedItem);
+ if (!srcPanel.IsItemFolder(realIndex))
+ return;
+
+ // destPanel.BindToFolder(srcPanel._currentFolderPrefix + srcPanel.GetItemName(realIndex) + WCHAR_PATH_SEPARATOR);
+
+ CMyComPtr<IFolderFolder> newFolder;
+ if (realIndex == kParentIndex)
+ {
+ if (srcPanel._folder->BindToParentFolder(&newFolder) != S_OK)
+ return;
+ }
+ else
+ {
+ if (srcPanel._folder->BindToFolder(realIndex, &newFolder) != S_OK)
+ return;
+ }
+ destPanel.CloseOpenFolders();
+ destPanel._folder = newFolder;
+ destPanel.RefreshListCtrl();
+}
+
+/*
+int CApp::GetFocusedPanelIndex() const
+{
+ return LastFocusedPanel;
+ HWND hwnd = ::GetFocus();
+ for (;;)
+ {
+ if (hwnd == 0)
+ return 0;
+ for (int i = 0; i < kNumPanelsMax; i++)
+ {
+ if (PanelsCreated[i] &&
+ ((HWND)Panels[i] == hwnd || Panels[i]._listView == hwnd))
+ return i;
+ }
+ hwnd = GetParent(hwnd);
+ }
+}
+*/
+
+static UString g_ToolTipBuffer;
+static CSysString g_ToolTipBufferSys;
+
+#ifdef _WIN32
+void CApp::OnNotify(int /* ctrlID */, LPNMHDR pnmh)
+{
+ {
+ if (pnmh->code == TTN_GETDISPINFO)
+ {
+ LPNMTTDISPINFO info = (LPNMTTDISPINFO)pnmh;
+ info->hinst = 0;
+ g_ToolTipBuffer.Empty();
+ SetButtonText((int)info->hdr.idFrom, g_ToolTipBuffer);
+ g_ToolTipBufferSys = GetSystemString(g_ToolTipBuffer);
+ info->lpszText = (LPTSTR)(LPCTSTR)g_ToolTipBufferSys;
+ return;
+ }
+ #ifndef _UNICODE
+ if (pnmh->code == TTN_GETDISPINFOW)
+ {
+ LPNMTTDISPINFOW info = (LPNMTTDISPINFOW)pnmh;
+ info->hinst = 0;
+ g_ToolTipBuffer.Empty();
+ SetButtonText((int)info->hdr.idFrom, g_ToolTipBuffer);
+ info->lpszText = (LPWSTR)(LPCWSTR)g_ToolTipBuffer;
+ return;
+ }
+ #endif
+ }
+}
+#endif
+
+void CApp::RefreshTitle(bool always)
+{
+ UString path = GetFocusedPanel()._currentFolderPrefix;
+#ifndef _WIN32
+ {
+ extern const TCHAR * nameWindowToUnix(const TCHAR * lpFileName);
+ UString tmp = nameWindowToUnix(path);
+ path = tmp;
+ }
+#endif
+ if (path.IsEmpty())
+ path += LangString(IDS_APP_TITLE, 0x03000000);
+ if (!always && path == PrevTitle)
+ return;
+ PrevTitle = path;
+ NWindows::MySetWindowText(_window, path);
+}
+
+void CApp::RefreshTitle(int panelIndex, bool always)
+{
+ if (panelIndex != GetFocusedPanelIndex())
+ return;
+ RefreshTitle(always);
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/App.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/App.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/App.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/App.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,327 @@
+// App.h
+
+#ifndef __APP_H
+#define __APP_H
+
+// #include "Windows/Control/CommandBar.h"
+// #include "Windows/Control/ImageList.h"
+
+#include "AppState.h"
+#include "Panel.h"
+
+class CApp;
+
+extern CApp g_App;
+extern HWND g_HWND;
+
+const int kNumPanelsMax = 2;
+
+extern bool g_IsSmallScreen;
+
+enum
+{
+ kAddCommand = kToolbarStartID,
+ kExtractCommand,
+ kTestCommand
+};
+
+class CPanelCallbackImp: public CPanelCallback
+{
+ CApp *_app;
+ int _index;
+public:
+ void Init(CApp *app, int index)
+ {
+ _app = app;
+ _index = index;
+ }
+ virtual void OnTab();
+ virtual void SetFocusToPath(int index);
+ virtual void OnCopy(bool move, bool copyToSame);
+ virtual void OnSetSameFolder();
+ virtual void OnSetSubFolder();
+ virtual void PanelWasFocused();
+ virtual void DragBegin();
+ virtual void DragEnd();
+ virtual void RefreshTitle(bool always);
+};
+
+class CApp;
+
+#if _WIN32
+class CDropTarget:
+ public IDropTarget,
+ public CMyUnknownImp
+{
+ CMyComPtr<IDataObject> m_DataObject;
+ UStringVector m_SourcePaths;
+ int m_SelectionIndex;
+ bool m_DropIsAllowed; // = true, if data contain fillist
+ bool m_PanelDropIsAllowed; // = false, if current target_panel is source_panel.
+ // check it only if m_DropIsAllowed == true
+ int m_SubFolderIndex;
+ UString m_SubFolderName;
+
+ CPanel *m_Panel;
+ bool m_IsAppTarget; // true, if we want to drop to app window (not to panel).
+
+ bool m_SetPathIsOK;
+
+ bool IsItSameDrive() const;
+
+ void QueryGetData(IDataObject *dataObject);
+ bool IsFsFolderPath() const;
+ DWORD GetEffect(DWORD keyState, POINTL pt, DWORD allowedEffect);
+ void RemoveSelection();
+ void PositionCursor(POINTL ptl);
+ UString GetTargetPath() const;
+ bool SetPath(bool enablePath) const;
+ bool SetPath();
+
+public:
+ MY_UNKNOWN_IMP1_MT(IDropTarget)
+ STDMETHOD(DragEnter)(IDataObject * dataObject, DWORD keyState, POINTL pt, DWORD *effect);
+ STDMETHOD(DragOver)(DWORD keyState, POINTL pt, DWORD * effect);
+ STDMETHOD(DragLeave)();
+ STDMETHOD(Drop)(IDataObject * dataObject, DWORD keyState, POINTL pt, DWORD *effect);
+
+ CDropTarget():
+ TargetPanelIndex(-1),
+ SrcPanelIndex(-1),
+ m_IsAppTarget(false),
+ m_Panel(0),
+ App(0),
+ m_PanelDropIsAllowed(false),
+ m_DropIsAllowed(false),
+ m_SelectionIndex(-1),
+ m_SubFolderIndex(-1),
+ m_SetPathIsOK(false) {}
+
+ CApp *App;
+ int SrcPanelIndex; // index of D&D source_panel
+ int TargetPanelIndex; // what panel to use as target_panel of Application
+};
+#endif
+
+class CApp
+{
+public:
+ NWindows::CWindow _window;
+ bool ShowSystemMenu;
+ int NumPanels;
+ int LastFocusedPanel;
+
+ bool ShowStandardToolbar;
+ bool ShowArchiveToolbar;
+ bool ShowButtonsLables;
+ bool LargeButtons;
+
+ CAppState AppState;
+ CPanelCallbackImp m_PanelCallbackImp[kNumPanelsMax];
+ CPanel Panels[kNumPanelsMax];
+ bool PanelsCreated[kNumPanelsMax];
+
+#ifdef _WIN32
+ NWindows::NControl::CImageList _buttonsImageList;
+
+ #ifdef UNDER_CE
+ NWindows::NControl::CCommandBar _commandBar;
+ #endif
+ NWindows::NControl::CToolBar _toolBar;
+
+ CDropTarget *_dropTargetSpec;
+ CMyComPtr<IDropTarget> _dropTarget;
+#endif
+
+ CApp(): _window(0), NumPanels(2), LastFocusedPanel(0) {}
+
+#ifdef _WIN32
+ void CreateDragTarget()
+ {
+ _dropTargetSpec = new CDropTarget();
+ _dropTarget = _dropTargetSpec;
+ _dropTargetSpec->App = (this);
+ }
+#endif
+
+ void SetFocusedPanel(int index)
+ {
+ LastFocusedPanel = index;
+ // FIXME _dropTargetSpec->TargetPanelIndex = LastFocusedPanel;
+ }
+
+ void DragBegin(int panelIndex)
+ {
+#ifdef _WIN32
+ _dropTargetSpec->TargetPanelIndex = (NumPanels > 1) ? 1 - panelIndex : panelIndex;
+ _dropTargetSpec->SrcPanelIndex = panelIndex;
+#endif
+ }
+
+ void DragEnd()
+ {
+#ifdef _WIN32
+ _dropTargetSpec->TargetPanelIndex = LastFocusedPanel;
+ _dropTargetSpec->SrcPanelIndex = -1;
+#endif
+ }
+
+
+ void OnCopy(bool move, bool copyToSame, int srcPanelIndex);
+ void OnSetSameFolder(int srcPanelIndex);
+ void OnSetSubFolder(int srcPanelIndex);
+
+ HRESULT CreateOnePanel(int panelIndex, const UString &mainPath, const UString &arcFormat, bool &archiveIsOpened, bool &encrypted);
+ HRESULT Create(HWND hwnd, const UString &mainPath, const UString &arcFormat, int xSizes[2], bool &archiveIsOpened, bool &encrypted);
+ void Read();
+ void Save();
+ void Release();
+
+ // void SetFocus(int panelIndex) { Panels[panelIndex].SetFocusToList(); }
+ // void SetFocusToLastItem() { Panels[LastFocusedPanel].SetFocusToLastRememberedItem(); }
+ int GetFocusedPanelIndex() const { return LastFocusedPanel; }
+ bool IsPanelVisible(int index) const { return (NumPanels > 1 || index == LastFocusedPanel); }
+ CPanel &GetFocusedPanel() { return Panels[GetFocusedPanelIndex()]; }
+
+ // File Menu
+ void OpenItem() { GetFocusedPanel().OpenSelectedItems(true); }
+ void OpenItemInside() { GetFocusedPanel().OpenFocusedItemAsInternal(); }
+ void OpenItemOutside() { GetFocusedPanel().OpenSelectedItems(false); }
+ void EditItem() { GetFocusedPanel().EditItem(); }
+ void Rename() { GetFocusedPanel().RenameFile(); }
+ void CopyTo() { OnCopy(false, false, GetFocusedPanelIndex()); }
+ void MoveTo() { OnCopy(true, false, GetFocusedPanelIndex()); }
+ void Delete(bool toRecycleBin) { GetFocusedPanel().DeleteItems(toRecycleBin); }
+ void CalculateCrc();
+ void DiffFiles();
+ void Split();
+ void Combine();
+ void Properties() { GetFocusedPanel().Properties(); }
+ void Comment() { GetFocusedPanel().ChangeComment(); }
+
+ void CreateFolder() { GetFocusedPanel().CreateFolder(); }
+ void CreateFile() { GetFocusedPanel().CreateFile(); }
+
+ // Edit
+ void EditCut() { GetFocusedPanel().EditCut(); }
+ void EditCopy() { GetFocusedPanel().EditCopy(); }
+ void EditPaste() { GetFocusedPanel().EditPaste(); }
+
+ void SelectAll(bool selectMode) { GetFocusedPanel().SelectAll(selectMode); }
+ void InvertSelection() { GetFocusedPanel().InvertSelection(); }
+ void SelectSpec(bool selectMode) { GetFocusedPanel().SelectSpec(selectMode); }
+ void SelectByType(bool selectMode) { GetFocusedPanel().SelectByType(selectMode); }
+
+ void RefreshStatusBar() { GetFocusedPanel().RefreshStatusBar(); }
+
+ void SetListViewMode(UInt32 index) { GetFocusedPanel().SetListViewMode(index); }
+ UInt32 GetListViewMode() { return GetFocusedPanel().GetListViewMode(); }
+ PROPID GetSortID() { return GetFocusedPanel().GetSortID(); }
+
+ void SortItemsWithPropID(PROPID propID) { GetFocusedPanel().SortItemsWithPropID(propID); }
+
+ void OpenRootFolder() { GetFocusedPanel().OpenDrivesFolder(); }
+ void OpenParentFolder() { GetFocusedPanel().OpenParentFolder(); }
+ void FoldersHistory() { GetFocusedPanel().FoldersHistory(); }
+ void RefreshView() { GetFocusedPanel().OnReload(); }
+ void RefreshAllPanels()
+ {
+ for (int i = 0; i < NumPanels; i++)
+ {
+ int index = i;
+ if (NumPanels == 1)
+ index = LastFocusedPanel;
+ Panels[index].OnReload();
+ }
+ }
+
+ /*
+ void SysIconsWereChanged()
+ {
+ for (int i = 0; i < NumPanels; i++)
+ {
+ int index = i;
+ if (NumPanels == 1)
+ index = LastFocusedPanel;
+ Panels[index].SysIconsWereChanged();
+ }
+ }
+ */
+
+ void SetListSettings();
+ void SetShowSystemMenu();
+ HRESULT SwitchOnOffOnePanel();
+ bool GetFlatMode() { return Panels[LastFocusedPanel].GetFlatMode(); }
+ void ChangeFlatMode() { Panels[LastFocusedPanel].ChangeFlatMode(); }
+
+ void OpenBookmark(int index) { GetFocusedPanel().OpenBookmark(index); }
+ void SetBookmark(int index) { GetFocusedPanel().SetBookmark(index); }
+
+ void ReloadToolbars();
+ void ReadToolbar()
+ {
+ UInt32 mask = ReadToolbarsMask();
+ if (mask & ((UInt32)1 << 31))
+ {
+ ShowButtonsLables = !g_IsSmallScreen;
+ LargeButtons = false;
+ ShowStandardToolbar = ShowArchiveToolbar = true;
+ }
+ else
+ {
+ ShowButtonsLables = ((mask & 1) != 0);
+ LargeButtons = ((mask & 2) != 0);
+ ShowStandardToolbar = ((mask & 4) != 0);
+ ShowArchiveToolbar = ((mask & 8) != 0);
+ }
+ }
+ void SaveToolbar()
+ {
+ UInt32 mask = 0;
+ if (ShowButtonsLables) mask |= 1;
+ if (LargeButtons) mask |= 2;
+ if (ShowStandardToolbar) mask |= 4;
+ if (ShowArchiveToolbar) mask |= 8;
+ SaveToolbarsMask(mask);
+ }
+
+ void SaveToolbarChanges();
+
+ void SwitchStandardToolbar()
+ {
+ ShowStandardToolbar = !ShowStandardToolbar;
+ SaveToolbarChanges();
+ }
+ void SwitchArchiveToolbar()
+ {
+ ShowArchiveToolbar = !ShowArchiveToolbar;
+ SaveToolbarChanges();
+ }
+ void SwitchButtonsLables()
+ {
+ ShowButtonsLables = !ShowButtonsLables;
+ SaveToolbarChanges();
+ }
+ void SwitchLargeButtons()
+ {
+ LargeButtons = !LargeButtons;
+ SaveToolbarChanges();
+ }
+
+ void AddToArchive() { GetFocusedPanel().AddToArchive(); }
+ void ExtractArchives() { GetFocusedPanel().ExtractArchives(); }
+ void TestArchives() { GetFocusedPanel().TestArchives(); }
+
+#ifdef _WIN32
+ void OnNotify(int ctrlID, LPNMHDR pnmh);
+#endif
+
+ UString PrevTitle;
+ void RefreshTitle(bool always = false);
+ void RefreshTitleAlways() { RefreshTitle(true); }
+ void RefreshTitle(int panelIndex, bool always = false);
+
+ void MoveSubWindows();
+};
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/AppState.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/AppState.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/AppState.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/AppState.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,114 @@
+// AppState.h
+
+#ifndef __APP_STATE_H
+#define __APP_STATE_H
+
+#include "Windows/Synchronization.h"
+
+#include "ViewSettings.h"
+
+void inline AddUniqueStringToHead(UStringVector &list,
+ const UString &string)
+{
+ for(int i = 0; i < list.Size();)
+ if (string.CompareNoCase(list[i]) == 0)
+ list.Delete(i);
+ else
+ i++;
+ list.Insert(0, string);
+}
+
+class CFastFolders
+{
+ NWindows::NSynchronization::CCriticalSection _criticalSection;
+public:
+ UStringVector Strings;
+ void SetString(int index, const UString &string)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
+ while(Strings.Size() <= index)
+ Strings.Add(UString());
+ Strings[index] = string;
+ }
+ UString GetString(int index)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
+ if (index >= Strings.Size())
+ return UString();
+ return Strings[index];
+ }
+ void Save()
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
+ SaveFastFolders(Strings);
+ }
+ void Read()
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
+ ReadFastFolders(Strings);
+ }
+};
+
+class CFolderHistory
+{
+ NWindows::NSynchronization::CCriticalSection _criticalSection;
+ UStringVector Strings;
+ void Normalize()
+ {
+ const int kMaxSize = 100;
+ if (Strings.Size() > kMaxSize)
+ Strings.Delete(kMaxSize, Strings.Size() - kMaxSize);
+ }
+
+public:
+
+ void GetList(UStringVector &foldersHistory)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
+ foldersHistory = Strings;
+ }
+
+ void AddString(const UString &string)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
+ AddUniqueStringToHead(Strings, string);
+ Normalize();
+ }
+
+ void RemoveAll()
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
+ Strings.Clear();
+ }
+
+ void Save()
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
+ SaveFolderHistory(Strings);
+ }
+
+ void Read()
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
+ ReadFolderHistory(Strings);
+ Normalize();
+ }
+};
+
+struct CAppState
+{
+ CFastFolders FastFolders;
+ CFolderHistory FolderHistory;
+ void Save()
+ {
+ FastFolders.Save();
+ FolderHistory.Save();
+ }
+ void Read()
+ {
+ FastFolders.Read();
+ FolderHistory.Read();
+ }
+};
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/BrowseDialog.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/BrowseDialog.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/BrowseDialog.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/BrowseDialog.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,77 @@
+// BrowseDialog.h
+
+#ifndef __BROWSE_DIALOG_H
+#define __BROWSE_DIALOG_H
+
+#ifdef UNDER_CE
+
+#include "Windows/FileFind.h"
+
+#include "Windows/Control/Dialog.h"
+#include "Windows/Control/ListView.h"
+
+#include "BrowseDialogRes.h"
+#include "SysIconUtils.h"
+
+class CBrowseDialog: public NWindows::NControl::CModalDialog
+{
+ NWindows::NControl::CListView _list;
+ CObjectVector<NWindows::NFile::NFind::CFileInfoW> _files;
+ CExtToIconMap _extToIconMap;
+ int _sortIndex;
+ bool _ascending;
+ bool _showDots;
+
+ virtual bool OnInit();
+ virtual bool OnSize(WPARAM wParam, int xSize, int ySize);
+ virtual bool OnNotify(UINT controlID, LPNMHDR header);
+ virtual void OnOK();
+
+ virtual bool OnButtonClicked(int buttonID, HWND buttonHWND);
+ virtual bool OnKeyDown(LPNMLVKEYDOWN keyDownInfo, LRESULT &result);
+
+ void FinishOnOK();
+ HRESULT Reload(const UString &pathPrefix, const UString &selectedName);
+ HRESULT Reload();
+ void OpenParentFolder();
+
+ void OnItemEnter();
+
+ int GetRealItemIndex(int indexInListView) const
+ {
+ LPARAM param;
+ if (!_list.GetItemParam(indexInListView, param))
+ return (int)-1;
+ return (int)param;
+ }
+
+ void ShowError(LPCWSTR s);
+ void ShowSelectError();
+public:
+ UString Title;
+ UString Path;
+ bool FolderMode;
+
+ CBrowseDialog(): FolderMode(true), _showDots(false) {}
+
+ INT_PTR Create(HWND parent = 0) { return CModalDialog::Create(IDD_DIALOG_BROWSE, parent); }
+ int CompareItems(LPARAM lParam1, LPARAM lParam2);
+};
+
+bool MyBrowseForFolder(HWND owner, LPCWSTR title, LPCWSTR initialFolder, UString &resultPath);
+bool MyBrowseForFile(HWND owner, LPCWSTR title, LPCWSTR initialFolder, LPCWSTR s, UString &resultPath);
+
+#else
+
+#include "Windows/CommonDialog.h"
+#include "Windows/Shell.h"
+
+#define MyBrowseForFolder(h, title, initialFolder, resultPath) \
+ NShell::BrowseForFolder(h, title, initialFolder, resultPath)
+
+#define MyBrowseForFile(h, title, initialFolder, s, resultPath) \
+ MyGetOpenFileName(h, title, initialFolder, s, resultPath)
+
+#endif
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ClassDefs.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ClassDefs.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ClassDefs.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ClassDefs.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,7 @@
+// ClassDefs.cpp
+
+#include "StdAfx.h"
+
+#include "Common/MyInitGuid.h"
+
+#include "../Agent/Agent.h"
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ComboDialog.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ComboDialog.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ComboDialog.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ComboDialog.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,54 @@
+// ComboDialog.cpp
+
+#include "StdAfx.h"
+#include "ComboDialog.h"
+
+#include "Windows/Control/Static.h"
+
+#ifdef LANG
+#include "LangUtils.h"
+#endif
+
+using namespace NWindows;
+
+#ifdef LANG
+static CIDLangPair kIDLangPairs[] =
+{
+ { IDOK, 0x02000702 },
+ { IDCANCEL, 0x02000710 }
+};
+#endif
+
+bool CComboDialog::OnInit()
+{
+ #ifdef LANG
+ LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
+ #endif
+ _comboBox.Attach(GetItem(IDC_COMBO_COMBO));
+
+ /*
+ // why it doesn't work ?
+ DWORD style = _comboBox.GetStyle();
+ if (Sorted)
+ style |= CBS_SORT;
+ else
+ style &= ~CBS_SORT;
+ _comboBox.SetStyle(style);
+ */
+ SetText(Title);
+
+ NControl::CStatic staticContol;
+ staticContol.Attach(GetItem(IDC_COMBO_STATIC));
+ staticContol.SetText(Static);
+ _comboBox.SetText(Value);
+ for(int i = 0; i < Strings.Size(); i++)
+ _comboBox.AddString(Strings[i]);
+ NormalizeSize();
+ return CModalDialog::OnInit();
+}
+
+void CComboDialog::OnOK()
+{
+ _comboBox.GetText(Value);
+ CModalDialog::OnOK();
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ComboDialog.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ComboDialog.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ComboDialog.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ComboDialog.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,26 @@
+// ComboDialog.h
+
+#ifndef __COMBO_DIALOG_H
+#define __COMBO_DIALOG_H
+
+#include "Windows/Control/ComboBox.h"
+#include "Windows/Control/Dialog.h"
+
+#include "ComboDialogRes.h"
+
+class CComboDialog: public NWindows::NControl::CModalDialog
+{
+ NWindows::NControl::CComboBox _comboBox;
+ virtual void OnOK();
+ virtual bool OnInit();
+public:
+ // bool Sorted;
+ UString Title;
+ UString Static;
+ UString Value;
+ UStringVector Strings;
+ // CComboDialog(): Sorted(false) {};
+ INT_PTR Create(HWND parentWindow = 0) { return CModalDialog::Create(IDD_DIALOG_COMBO, parentWindow); }
+};
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ComboDialogRes.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ComboDialogRes.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ComboDialogRes.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ComboDialogRes.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,4 @@
+#define IDD_DIALOG_COMBO 505
+
+#define IDC_COMBO_STATIC 1000
+#define IDC_COMBO_COMBO 1001
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ComboDialog_rc.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ComboDialog_rc.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ComboDialog_rc.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ComboDialog_rc.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,60 @@
+// PasswordDialog.cpp
+
+#include "StdAfx.h"
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+// for all others, include the necessary headers (this file is usually all you
+// need because it includes almost all "standard" wxWidgets headers)
+#ifndef WX_PRECOMP
+ #include "wx/wx.h"
+#endif
+
+#undef _WIN32
+
+#include "Windows/Control/DialogImpl.h"
+
+#include "ComboDialogRes.h"
+
+class ComboDialogImpl : public NWindows::NControl::CModalDialogImpl
+{
+ public:
+ ComboDialogImpl(NWindows::NControl::CModalDialog *dialog,wxWindow * parent,int id) : CModalDialogImpl(dialog, parent, id, wxT("Combo"))
+ {
+
+ wxBoxSizer* topsizer = new wxBoxSizer(wxVERTICAL);
+
+
+ topsizer->Add(new wxStaticText(this, IDC_COMBO_STATIC, _T("")) , 0 ,wxALL | wxALIGN_LEFT, 5 );
+
+
+ wxArrayString pathArray;
+ wxComboBox *combo = new wxComboBox(this, IDC_COMBO_COMBO, wxEmptyString, wxDefaultPosition, wxSize(200,-1), pathArray, wxCB_DROPDOWN|wxCB_SORT);
+
+ topsizer->Add(combo, 0 ,wxALL | wxALIGN_LEFT, 5 );
+
+ topsizer->Add(CreateButtonSizer(wxOK|wxCANCEL), 0, wxALL|wxEXPAND, 5);
+
+ this->OnInit();
+
+ SetSizer(topsizer); // use the sizer for layout
+ topsizer->SetSizeHints(this); // set size hints to honour minimum size
+ }
+private:
+ // Any class wishing to process wxWindows events must use this macro
+ DECLARE_EVENT_TABLE()
+};
+
+REGISTER_DIALOG(IDD_DIALOG_COMBO,ComboDialog,0)
+
+BEGIN_EVENT_TABLE(ComboDialogImpl, wxDialog)
+ EVT_BUTTON(wxID_ANY, CModalDialogImpl::OnAnyButton)
+ EVT_CHECKBOX(wxID_ANY, CModalDialogImpl::OnAnyButton)
+ EVT_MENU(WORKER_EVENT, CModalDialogImpl::OnWorkerEvent)
+END_EVENT_TABLE()
+
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/CopyDialog.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/CopyDialog.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/CopyDialog.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/CopyDialog.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,87 @@
+// CopyDialog.cpp
+
+#include "StdAfx.h"
+
+#include "Windows/FileName.h"
+
+#include "Windows/Control/Static.h"
+
+#include "BrowseDialog.h"
+#include "CopyDialog.h"
+
+#ifdef LANG
+#include "LangUtils.h"
+#endif
+
+using namespace NWindows;
+
+#ifdef LANG
+static CIDLangPair kIDLangPairs[] =
+{
+ { IDOK, 0x02000702 },
+ { IDCANCEL, 0x02000710 }
+};
+#endif
+
+#ifndef _WIN32
+extern const TCHAR * nameWindowToUnix(const TCHAR * lpFileName);
+#endif
+
+bool CCopyDialog::OnInit()
+{
+ #ifdef LANG
+ LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
+ #endif
+ _path.Attach(GetItem(IDC_COPY_COMBO));
+ SetText(Title);
+
+ NControl::CStatic staticContol;
+ staticContol.Attach(GetItem(IDC_COPY_STATIC));
+ staticContol.SetText(Static);
+ #ifdef UNDER_CE
+ // we do it, since WinCE selects Value\something instead of Value !!!!
+ _path.AddString(Value);
+ #endif
+ for (int i = 0; i < Strings.Size(); i++)
+ _path.AddString(Strings[i]);
+#ifndef _WIN32
+ UString tmp = nameWindowToUnix(Value);
+ Value = tmp;
+#endif
+ _path.SetText(Value);
+ SetItemText(IDC_COPY_INFO, Info);
+ NormalizeSize(true);
+ return CModalDialog::OnInit();
+}
+
+bool CCopyDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
+{
+ switch(buttonID)
+ {
+ case IDC_COPY_SET_PATH:
+ OnButtonSetPath();
+ return true;
+ }
+ return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
+}
+
+void CCopyDialog::OnButtonSetPath()
+{
+ UString currentPath;
+ _path.GetText(currentPath);
+
+ UString title = LangStringSpec(IDS_SET_FOLDER, 0x03020209);
+
+ UString resultPath;
+ if (!MyBrowseForFolder(HWND(*this), title, currentPath, resultPath))
+ return;
+ NFile::NName::NormalizeDirPathPrefix(resultPath);
+ _path.SetCurSel(-1);
+ _path.SetText(resultPath);
+}
+
+void CCopyDialog::OnOK()
+{
+ _path.GetText(Value);
+ CModalDialog::OnOK();
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/CopyDialog.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/CopyDialog.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/CopyDialog.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/CopyDialog.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,30 @@
+// CopyDialog.h
+
+#ifndef __COPY_DIALOG_H
+#define __COPY_DIALOG_H
+
+#include "Windows/Control/ComboBox.h"
+#include "Windows/Control/Dialog.h"
+
+#include "CopyDialogRes.h"
+
+const int kCopyDialog_NumInfoLines = 11;
+
+class CCopyDialog: public NWindows::NControl::CModalDialog
+{
+ NWindows::NControl::CComboBox _path;
+ virtual void OnOK();
+ virtual bool OnInit();
+ void OnButtonSetPath();
+ bool OnButtonClicked(int buttonID, HWND buttonHWND);
+public:
+ UString Title;
+ UString Static;
+ UString Value;
+ UString Info;
+ UStringVector Strings;
+
+ INT_PTR Create(HWND parentWindow = 0) { return CModalDialog::Create(IDD_DIALOG_COPY, parentWindow); }
+};
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/CopyDialogRes.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/CopyDialogRes.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/CopyDialogRes.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/CopyDialogRes.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,8 @@
+#define IDD_DIALOG_COPY 506
+
+#define IDC_COPY_STATIC 1000
+#define IDC_COPY_COMBO 1001
+#define IDC_COPY_SET_PATH 1002
+#define IDC_COPY_INFO 1003
+
+#define IDS_SET_FOLDER 210
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/CopyDialog_rc.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/CopyDialog_rc.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/CopyDialog_rc.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/CopyDialog_rc.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,77 @@
+// PasswordDialog.cpp
+
+#include "StdAfx.h"
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+// for all others, include the necessary headers (this file is usually all you
+// need because it includes almost all "standard" wxWidgets headers)
+#ifndef WX_PRECOMP
+ #include "wx/wx.h"
+#endif
+
+#undef _WIN32
+
+#include "Windows/Control/DialogImpl.h"
+
+#include "CopyDialogRes.h"
+
+class CopyDialogImpl : public NWindows::NControl::CModalDialogImpl
+{
+ public:
+ CopyDialogImpl(NWindows::NControl::CModalDialog *dialog,wxWindow * parent,int id) : CModalDialogImpl(dialog, parent, id, wxT("Copy"))
+ {
+
+ wxBoxSizer* topsizer = new wxBoxSizer(wxVERTICAL);
+
+
+ topsizer->Add(new wxStaticText(this, IDC_COPY_STATIC, _T("")) , 0 ,wxEXPAND | wxALL | wxALIGN_LEFT, 5 );
+
+
+ {
+ wxBoxSizer *pathSizer = new wxBoxSizer(wxHORIZONTAL);
+
+ wxArrayString pathArray;
+ wxComboBox *combo = new wxComboBox(this, IDC_COPY_COMBO, wxEmptyString, wxDefaultPosition, wxSize(600,-1), pathArray, wxCB_DROPDOWN|wxCB_SORT);
+ wxButton *button = new wxButton(this, IDC_COPY_SET_PATH, wxT("..."), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
+ pathSizer->Add(combo, 1, wxLEFT|wxRIGHT|wxEXPAND, 5);
+ pathSizer->Add(button, 0, wxLEFT|wxRIGHT|wxEXPAND, 5);
+
+ topsizer->Add(pathSizer, 0 ,wxALL | wxALIGN_LEFT, 5 );
+ }
+
+// topsizer->Add(new wxStaticText(this, IDC_COPY_INFO, _T("line1\nline2\nline3\nline4\n")) , 0 ,wxEXPAND | wxALL | wxALIGN_LEFT, 5 );
+ topsizer->Add(new wxStaticText(this, IDC_COPY_INFO, _T("")) , 0 ,wxEXPAND | wxALL | wxALIGN_LEFT, 5 );
+
+ topsizer->Add(CreateButtonSizer(wxOK|wxCANCEL), 0, wxALL|wxEXPAND, 5);
+
+ this->OnInit();
+
+ SetSizer(topsizer); // use the sizer for layout
+ topsizer->SetSizeHints(this); // set size hints to honour minimum size
+ }
+private:
+ // Any class wishing to process wxWindows events must use this macro
+ DECLARE_EVENT_TABLE()
+};
+
+static CStringTable g_stringTable[] =
+{
+ { IDS_SET_FOLDER, L"Specify a location for output folder." },
+ { 0 , 0 }
+};
+
+
+REGISTER_DIALOG(IDD_DIALOG_COPY,CopyDialog,g_stringTable)
+
+BEGIN_EVENT_TABLE(CopyDialogImpl, wxDialog)
+ EVT_BUTTON(wxID_ANY, CModalDialogImpl::OnAnyButton)
+ EVT_CHECKBOX(wxID_ANY, CModalDialogImpl::OnAnyButton)
+ EVT_MENU(WORKER_EVENT, CModalDialogImpl::OnWorkerEvent)
+END_EVENT_TABLE()
+
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/DialogSize.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/DialogSize.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/DialogSize.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/DialogSize.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,16 @@
+// DialogSize.h
+
+#ifndef __DIALOG_SIZE_H
+#define __DIALOG_SIZE_H
+
+#include "Windows/Control/Dialog.h"
+
+#ifdef UNDER_CE
+#define BIG_DIALOG_SIZE(x, y) bool isBig = NWindows::NControl::IsDialogSizeOK(x, y);
+#define SIZED_DIALOG(big) (isBig ? big : big ## _2)
+#else
+#define BIG_DIALOG_SIZE(x, y)
+#define SIZED_DIALOG(big) big
+#endif
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ExtractCallback.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ExtractCallback.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ExtractCallback.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ExtractCallback.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,453 @@
+// ExtractCallback.cpp
+
+#include "StdAfx.h"
+
+#include "Windows/Error.h"
+#include "Windows/FileDir.h"
+#include "Windows/FileFind.h"
+
+#include "../../Common/FilePathAutoRename.h"
+
+#include "../GUI/ExtractRes.h"
+
+#include "ExtractCallback.h"
+#include "FormatUtils.h"
+#include "OverwriteDialog.h"
+#ifndef _NO_CRYPTO
+#include "PasswordDialog.h"
+#endif
+
+using namespace NWindows;
+using namespace NFile;
+using namespace NFind;
+
+CExtractCallbackImp::~CExtractCallbackImp() {}
+
+void CExtractCallbackImp::Init()
+{
+ NumArchiveErrors = 0;
+ ThereAreMessageErrors = false;
+ #ifndef _SFX
+ NumFolders = NumFiles = 0;
+ NeedAddFile = false;
+ #endif
+}
+
+void CExtractCallbackImp::AddErrorMessage(LPCWSTR message)
+{
+ ThereAreMessageErrors = true;
+ ProgressDialog->Sync.AddErrorMessage(message);
+}
+
+STDMETHODIMP CExtractCallbackImp::SetNumFiles(UInt64
+ #ifndef _SFX
+ numFiles
+ #endif
+ )
+{
+ #ifndef _SFX
+ ProgressDialog->Sync.SetNumFilesTotal(numFiles);
+ #endif
+ return S_OK;
+}
+
+STDMETHODIMP CExtractCallbackImp::SetTotal(UInt64 total)
+{
+ ProgressDialog->Sync.SetProgress(total, 0);
+ return S_OK;
+}
+
+STDMETHODIMP CExtractCallbackImp::SetCompleted(const UInt64 *value)
+{
+ RINOK(ProgressDialog->Sync.ProcessStopAndPause());
+ if (value != NULL)
+ ProgressDialog->Sync.SetPos(*value);
+ return S_OK;
+}
+
+HRESULT CExtractCallbackImp::Open_CheckBreak()
+{
+ return ProgressDialog->Sync.ProcessStopAndPause();
+}
+
+HRESULT CExtractCallbackImp::Open_SetTotal(const UInt64 * /* numFiles */, const UInt64 * /* numBytes */)
+{
+ // if (numFiles != NULL) ProgressDialog->Sync.SetNumFilesTotal(*numFiles);
+ return S_OK;
+}
+
+HRESULT CExtractCallbackImp::Open_SetCompleted(const UInt64 * /* numFiles */, const UInt64 * /* numBytes */)
+{
+ RINOK(ProgressDialog->Sync.ProcessStopAndPause());
+ // if (numFiles != NULL) ProgressDialog->Sync.SetNumFilesCur(*numFiles);
+ return S_OK;
+}
+
+#ifndef _NO_CRYPTO
+
+HRESULT CExtractCallbackImp::Open_CryptoGetTextPassword(BSTR *password)
+{
+ return CryptoGetTextPassword(password);
+}
+
+HRESULT CExtractCallbackImp::Open_GetPasswordIfAny(UString &password)
+{
+ if (PasswordIsDefined)
+ password = Password;
+ return S_OK;
+}
+
+bool CExtractCallbackImp::Open_WasPasswordAsked()
+{
+ return PasswordWasAsked;
+}
+
+void CExtractCallbackImp::Open_ClearPasswordWasAskedFlag()
+{
+ PasswordWasAsked = false;
+}
+
+#endif
+
+
+#ifndef _SFX
+STDMETHODIMP CExtractCallbackImp::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize)
+{
+ ProgressDialog->Sync.SetRatioInfo(inSize, outSize);
+ return S_OK;
+}
+#endif
+
+/*
+STDMETHODIMP CExtractCallbackImp::SetTotalFiles(UInt64 total)
+{
+ ProgressDialog->Sync.SetNumFilesTotal(total);
+ return S_OK;
+}
+
+STDMETHODIMP CExtractCallbackImp::SetCompletedFiles(const UInt64 *value)
+{
+ if (value != NULL)
+ ProgressDialog->Sync.SetNumFilesCur(*value);
+ return S_OK;
+}
+*/
+
+STDMETHODIMP CExtractCallbackImp::AskOverwrite(
+ const wchar_t *existName, const FILETIME *existTime, const UInt64 *existSize,
+ const wchar_t *newName, const FILETIME *newTime, const UInt64 *newSize,
+ Int32 *answer)
+{
+ COverwriteDialog dialog;
+
+ dialog.OldFileInfo.SetTime(existTime);
+ dialog.OldFileInfo.SetSize(existSize);
+ dialog.OldFileInfo.Name = existName;
+
+ dialog.NewFileInfo.SetTime(newTime);
+ dialog.NewFileInfo.SetSize(newSize);
+ dialog.NewFileInfo.Name = newName;
+
+ ProgressDialog->WaitCreating();
+ INT_PTR writeAnswer = dialog.Create(*ProgressDialog);
+
+ switch(writeAnswer)
+ {
+ case IDCANCEL: *answer = NOverwriteAnswer::kCancel; return E_ABORT;
+ case IDYES: *answer = NOverwriteAnswer::kYes; break;
+ case IDNO: *answer = NOverwriteAnswer::kNo; break;
+ case IDC_BUTTON_OVERWRITE_YES_TO_ALL: *answer = NOverwriteAnswer::kYesToAll; break;
+ case IDC_BUTTON_OVERWRITE_NO_TO_ALL: *answer = NOverwriteAnswer::kNoToAll; break;
+ case IDC_BUTTON_OVERWRITE_AUTO_RENAME: *answer = NOverwriteAnswer::kAutoRename; break;
+ default: return E_FAIL;
+ }
+ return S_OK;
+}
+
+
+STDMETHODIMP CExtractCallbackImp::PrepareOperation(const wchar_t *name, bool isFolder, Int32 /* askExtractMode */, const UInt64 * /* position */)
+{
+ _isFolder = isFolder;
+ return SetCurrentFilePath2(name);
+}
+
+STDMETHODIMP CExtractCallbackImp::MessageError(const wchar_t *message)
+{
+ AddErrorMessage(message);
+ return S_OK;
+}
+
+STDMETHODIMP CExtractCallbackImp::ShowMessage(const wchar_t *message)
+{
+ AddErrorMessage(message);
+ return S_OK;
+}
+
+STDMETHODIMP CExtractCallbackImp::SetOperationResult(Int32 operationResult, bool encrypted)
+{
+ switch(operationResult)
+ {
+ case NArchive::NExtract::NOperationResult::kOK:
+ break;
+ default:
+ {
+ UINT messageID;
+ UInt32 langID;
+ switch(operationResult)
+ {
+ case NArchive::NExtract::NOperationResult::kUnSupportedMethod:
+ messageID = IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_UNSUPPORTED_METHOD;
+ langID = 0x02000A91;
+ break;
+ case NArchive::NExtract::NOperationResult::kDataError:
+ messageID = encrypted ?
+ IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_DATA_ERROR_ENCRYPTED:
+ IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_DATA_ERROR;
+ langID = encrypted ? 0x02000A94 : 0x02000A92;
+ break;
+ case NArchive::NExtract::NOperationResult::kCRCError:
+ messageID = encrypted ?
+ IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_CRC_ENCRYPTED:
+ IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_CRC;
+ langID = encrypted ? 0x02000A95 : 0x02000A93;
+ break;
+ default:
+ return E_FAIL;
+ }
+ if (_needWriteArchivePath)
+ {
+ if (!_currentArchivePath.IsEmpty())
+ AddErrorMessage(_currentArchivePath);
+ _needWriteArchivePath = false;
+ }
+ AddErrorMessage(
+ MyFormatNew(messageID,
+ #ifdef LANG
+ langID,
+ #endif
+ _currentFilePath));
+ }
+ }
+ #ifndef _SFX
+ if (_isFolder)
+ NumFolders++;
+ else
+ NumFiles++;
+ ProgressDialog->Sync.SetNumFilesCur(NumFiles);
+ #endif
+ return S_OK;
+}
+
+////////////////////////////////////////
+// IExtractCallbackUI
+
+HRESULT CExtractCallbackImp::BeforeOpen(const wchar_t *name)
+{
+ #ifndef _SFX
+ ProgressDialog->Sync.SetTitleFileName(name);
+ #endif
+ _currentArchivePath = name;
+ return S_OK;
+}
+
+HRESULT CExtractCallbackImp::SetCurrentFilePath2(const wchar_t *path)
+{
+ _currentFilePath = path;
+ #ifndef _SFX
+ ProgressDialog->Sync.SetCurrentFileName(path);
+ #endif
+ return S_OK;
+}
+
+HRESULT CExtractCallbackImp::SetCurrentFilePath(const wchar_t *path)
+{
+ #ifndef _SFX
+ if (NeedAddFile)
+ NumFiles++;
+ NeedAddFile = true;
+ ProgressDialog->Sync.SetNumFilesCur(NumFiles);
+ #endif
+ return SetCurrentFilePath2(path);
+}
+
+HRESULT CExtractCallbackImp::OpenResult(const wchar_t *name, HRESULT result, bool encrypted)
+{
+ if (result != S_OK)
+ {
+ UString message;
+ if (result == S_FALSE)
+ {
+ message = MyFormatNew(encrypted ? IDS_CANT_OPEN_ENCRYPTED_ARCHIVE : IDS_CANT_OPEN_ARCHIVE,
+ #ifdef LANG
+ (encrypted ? 0x0200060A : 0x02000609),
+ #endif
+ name);
+ }
+ else
+ {
+ message = name;
+ message += L": ";
+ UString message2;
+ if (result == E_OUTOFMEMORY)
+ message2 =
+ #ifdef LANG
+ LangString(IDS_MEM_ERROR, 0x0200060B);
+ #else
+ MyLoadStringW(IDS_MEM_ERROR);
+ #endif
+ else
+ NError::MyFormatMessage(result, message2);
+ message += message2;
+ }
+ MessageError(message);
+ NumArchiveErrors++;
+ }
+ _currentArchivePath = name;
+ _needWriteArchivePath = true;
+ return S_OK;
+}
+
+HRESULT CExtractCallbackImp::ThereAreNoFiles()
+{
+ return S_OK;
+}
+
+HRESULT CExtractCallbackImp::ExtractResult(HRESULT result)
+{
+ if (result == S_OK)
+ return result;
+ NumArchiveErrors++;
+ if (result == E_ABORT || result == ERROR_DISK_FULL)
+ return result;
+ MessageError(_currentFilePath);
+ MessageError(NError::MyFormatMessageW(result));
+ return S_OK;
+}
+
+#ifndef _NO_CRYPTO
+
+HRESULT CExtractCallbackImp::SetPassword(const UString &password)
+{
+ PasswordIsDefined = true;
+ Password = password;
+ return S_OK;
+}
+
+STDMETHODIMP CExtractCallbackImp::CryptoGetTextPassword(BSTR *password)
+{
+ PasswordWasAsked = true;
+ if (!PasswordIsDefined)
+ {
+ CPasswordDialog dialog;
+ ProgressDialog->WaitCreating();
+ if (dialog.Create(*ProgressDialog) == IDCANCEL)
+ return E_ABORT;
+ Password = dialog.Password;
+ PasswordIsDefined = true;
+ }
+ return StringToBstr(Password, password);
+}
+
+#endif
+
+// IExtractCallBack3
+STDMETHODIMP CExtractCallbackImp::AskWrite(
+ const wchar_t *srcPath, Int32 srcIsFolder,
+ const FILETIME *srcTime, const UInt64 *srcSize,
+ const wchar_t *destPath,
+ BSTR *destPathResult,
+ Int32 *writeAnswer)
+{
+ UString destPathResultTemp = destPath;
+
+ // RINOK(StringToBstr(destPath, destPathResult));
+
+ *destPathResult = 0;
+ *writeAnswer = BoolToInt(false);
+
+ UString destPathSpec = destPath;
+ UString destPathSys = destPathSpec;
+ bool srcIsFolderSpec = IntToBool(srcIsFolder);
+ CFileInfoW destFileInfo;
+ if (destFileInfo.Find(destPathSys))
+ {
+ if (srcIsFolderSpec)
+ {
+ if (!destFileInfo.IsDir())
+ {
+ UString message = UString(L"can not replace file \'")
+ + destPathSpec +
+ UString(L"\' with folder with same name");
+ RINOK(MessageError(message));
+ return E_ABORT;
+ }
+ *writeAnswer = BoolToInt(false);
+ return S_OK;
+ }
+ if (destFileInfo.IsDir())
+ {
+ UString message = UString(L"can not replace folder \'")
+ + destPathSpec +
+ UString(L"\' with file with same name");
+ RINOK(MessageError(message));
+ return E_FAIL;
+ }
+
+ switch(OverwriteMode)
+ {
+ case NExtract::NOverwriteMode::kSkipExisting:
+ return S_OK;
+ case NExtract::NOverwriteMode::kAskBefore:
+ {
+ Int32 overwiteResult;
+ RINOK(AskOverwrite(
+ destPathSpec,
+ &destFileInfo.MTime, &destFileInfo.Size,
+ srcPath,
+ srcTime, srcSize,
+ &overwiteResult));
+ switch(overwiteResult)
+ {
+ case NOverwriteAnswer::kCancel:
+ return E_ABORT;
+ case NOverwriteAnswer::kNo:
+ return S_OK;
+ case NOverwriteAnswer::kNoToAll:
+ OverwriteMode = NExtract::NOverwriteMode::kSkipExisting;
+ return S_OK;
+ case NOverwriteAnswer::kYesToAll:
+ OverwriteMode = NExtract::NOverwriteMode::kWithoutPrompt;
+ break;
+ case NOverwriteAnswer::kYes:
+ break;
+ case NOverwriteAnswer::kAutoRename:
+ OverwriteMode = NExtract::NOverwriteMode::kAutoRename;
+ break;
+ default:
+ return E_FAIL;
+ }
+ }
+ }
+ if (OverwriteMode == NExtract::NOverwriteMode::kAutoRename)
+ {
+ if (!AutoRenamePath(destPathSys))
+ {
+ UString message = UString(L"can not create name of file ")
+ + destPathSys;
+ RINOK(MessageError(message));
+ return E_ABORT;
+ }
+ destPathResultTemp = destPathSys;
+ }
+ else
+ if (!NFile::NDirectory::DeleteFileAlways(destPathSys))
+ {
+ UString message = UString(L"can not delete output file ")
+ + destPathSys;
+ RINOK(MessageError(message));
+ return E_ABORT;
+ }
+ }
+ *writeAnswer = BoolToInt(true);
+ return StringToBstr(destPathResultTemp, destPathResult);
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ExtractCallback.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ExtractCallback.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ExtractCallback.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ExtractCallback.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,138 @@
+// ExtractCallback.h
+
+#ifndef __EXTRACT_CALLBACK_H
+#define __EXTRACT_CALLBACK_H
+
+#include "Common/MyCom.h"
+
+#include "Windows/ResourceString.h"
+
+#include "../Agent/IFolderArchive.h"
+#include "../Common/ArchiveOpenCallback.h"
+
+#ifndef _NO_CRYPTO
+#include "../../IPassword.h"
+#endif
+
+#include "IFolder.h"
+
+#include "ProgressDialog2.h"
+
+#ifdef LANG
+#include "LangUtils.h"
+#endif
+
+class CExtractCallbackImp:
+ public IExtractCallbackUI,
+ public IOpenCallbackUI,
+ public IFolderOperationsExtractCallback,
+ // public IFolderArchiveExtractCallback, // mkultiple from IProgress
+ #ifndef _SFX
+ public ICompressProgressInfo,
+ #endif
+ #ifndef _NO_CRYPTO
+ public ICryptoGetTextPassword,
+ #endif
+ public CMyUnknownImp
+{
+public:
+ MY_QUERYINTERFACE_BEGIN2(IFolderOperationsExtractCallback)
+ MY_QUERYINTERFACE_ENTRY(IFolderArchiveExtractCallback)
+ #ifndef _SFX
+ MY_QUERYINTERFACE_ENTRY(ICompressProgressInfo)
+ #endif
+ #ifndef _NO_CRYPTO
+ MY_QUERYINTERFACE_ENTRY(ICryptoGetTextPassword)
+ #endif
+ MY_QUERYINTERFACE_END
+ MY_ADDREF_RELEASE
+
+ #ifndef _SFX
+ STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
+ #endif
+
+ INTERFACE_IProgress(;)
+ INTERFACE_IOpenCallbackUI(;)
+
+ // IFolderArchiveExtractCallback
+ // STDMETHOD(SetTotalFiles)(UInt64 total);
+ // STDMETHOD(SetCompletedFiles)(const UInt64 *value);
+ STDMETHOD(AskOverwrite)(
+ const wchar_t *existName, const FILETIME *existTime, const UInt64 *existSize,
+ const wchar_t *newName, const FILETIME *newTime, const UInt64 *newSize,
+ Int32 *answer);
+ STDMETHOD (PrepareOperation)(const wchar_t *name, bool isFolder, Int32 askExtractMode, const UInt64 *position);
+
+ STDMETHOD(MessageError)(const wchar_t *message);
+ STDMETHOD(SetOperationResult)(Int32 operationResult, bool encrypted);
+
+ // IExtractCallbackUI
+
+ HRESULT BeforeOpen(const wchar_t *name);
+ HRESULT OpenResult(const wchar_t *name, HRESULT result, bool encrypted);
+ HRESULT ThereAreNoFiles();
+ HRESULT ExtractResult(HRESULT result);
+
+ #ifndef _NO_CRYPTO
+ HRESULT SetPassword(const UString &password);
+ #endif
+
+ // IFolderOperationsExtractCallback
+ STDMETHOD(AskWrite)(
+ const wchar_t *srcPath,
+ Int32 srcIsFolder,
+ const FILETIME *srcTime,
+ const UInt64 *srcSize,
+ const wchar_t *destPathRequest,
+ BSTR *destPathResult,
+ Int32 *writeAnswer);
+ STDMETHOD(ShowMessage)(const wchar_t *message);
+ STDMETHOD(SetCurrentFilePath)(const wchar_t *filePath);
+ STDMETHOD(SetNumFiles)(UInt64 numFiles);
+
+ // ICryptoGetTextPassword
+ #ifndef _NO_CRYPTO
+ STDMETHOD(CryptoGetTextPassword)(BSTR *password);
+ #endif
+
+private:
+ UString _currentArchivePath;
+ bool _needWriteArchivePath;
+
+ UString _currentFilePath;
+ bool _isFolder;
+
+ HRESULT SetCurrentFilePath2(const wchar_t *filePath);
+ void AddErrorMessage(LPCWSTR message);
+public:
+ CProgressDialog *ProgressDialog;
+ #ifndef _SFX
+ UInt64 NumFolders;
+ UInt64 NumFiles;
+ bool NeedAddFile;
+ #endif
+ UInt32 NumArchiveErrors;
+ bool ThereAreMessageErrors;
+ NExtract::NOverwriteMode::EEnum OverwriteMode;
+
+ #ifndef _NO_CRYPTO
+ bool PasswordIsDefined;
+ bool PasswordWasAsked;
+ UString Password;
+ #endif
+
+ CExtractCallbackImp():
+ #ifndef _NO_CRYPTO
+ PasswordIsDefined(false),
+ PasswordWasAsked(false),
+ #endif
+ OverwriteMode(NExtract::NOverwriteMode::kAskBefore)
+ {}
+
+ ~CExtractCallbackImp();
+ void Init();
+
+ bool IsOK() const { return NumArchiveErrors == 0 && !ThereAreMessageErrors; }
+};
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/FM.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/FM.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/FM.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/FM.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,980 @@
+// FM.cpp
+
+#include "StdAfx.h"
+
+#include "resource.h"
+#include "Panel.h"
+
+extern "C"
+{
+ #include "../../../../C/Alloc.h"
+}
+
+#include "Common/Defs.h"
+#include "Common/StringConvert.h"
+// #include "Common/CommandLineParser.h"
+
+// FIXME #include "Windows/Control/Toolbar.h"
+#include "Windows/Error.h"
+#include "Windows/COM.h"
+#include "Windows/DLL.h"
+// FIXME #include "Windows/Security.h"
+// FIXME #include "Windows/MemoryLock.h"
+
+#include "ViewSettings.h"
+#include "../GUI/ExtractRes.h"
+
+#include "App.h"
+#include "StringUtils.h"
+
+#include "MyLoadMenu.h"
+#include "LangUtils.h"
+#include "FormatUtils.h"
+#include "RegistryUtils.h"
+
+using namespace NWindows;
+using namespace NFile;
+using namespace NFind;
+// using namespace NCommandLineParser;
+
+#define MAX_LOADSTRING 100
+
+#define MENU_HEIGHT 26
+
+#ifndef _UNICODE
+bool g_IsNT = false;
+#endif
+HINSTANCE g_hInstance;
+HWND g_HWND;
+bool g_OpenArchive = false;
+static UString g_MainPath;
+static UString g_ArcFormat;
+
+const int kNumDefaultPanels = 1;
+
+const int kSplitterWidth = 4;
+int kSplitterRateMax = 1 << 16;
+
+// bool OnMenuCommand(HWND hWnd, int id);
+
+static void local_WM_CREATE(HWND hWnd);
+
+#ifdef _WIN32
+static UString GetProgramPath()
+{
+ UString s;
+ NDLL::MyGetModuleFileName(g_hInstance, s);
+ return s;
+}
+
+UString GetProgramFolderPrefix()
+{
+ UString path = GetProgramPath();
+ int pos = path.ReverseFind(WCHAR_PATH_SEPARATOR);
+ return path.Left(pos + 1);
+}
+
+
+class CSplitterPos
+{
+ int _ratio; // 10000 is max
+ int _pos;
+ int _fullWidth;
+ void SetRatioFromPos(HWND hWnd)
+ { _ratio = (_pos + kSplitterWidth / 2) * kSplitterRateMax /
+ MyMax(GetWidth(hWnd), 1); }
+public:
+ int GetPos() const
+ { return _pos; }
+ int GetWidth(HWND hWnd) const
+ {
+ RECT rect;
+ ::GetClientRect(hWnd, &rect);
+ return rect.right;
+ }
+ void SetRatio(HWND hWnd, int aRatio)
+ {
+ _ratio = aRatio;
+ SetPosFromRatio(hWnd);
+ }
+ void SetPosPure(HWND hWnd, int pos)
+ {
+ int posMax = GetWidth(hWnd) - kSplitterWidth;
+ if (pos > posMax)
+ pos = posMax;
+ if (pos < 0)
+ pos = 0;
+ _pos = pos;
+ }
+ void SetPos(HWND hWnd, int pos)
+ {
+ _fullWidth = GetWidth(hWnd);
+ SetPosPure(hWnd, pos);
+ SetRatioFromPos(hWnd);
+ }
+ void SetPosFromRatio(HWND hWnd)
+ {
+ int fullWidth = GetWidth(hWnd);
+ if (_fullWidth != fullWidth)
+ {
+ _fullWidth = fullWidth;
+ SetPosPure(hWnd, GetWidth(hWnd) * _ratio / kSplitterRateMax - kSplitterWidth / 2);
+ }
+ }
+};
+#endif
+
+bool g_CanChangeSplitter = false;
+UINT32 g_SplitterPos = 0;
+// FIXME CSplitterPos g_Splitter;
+bool g_PanelsInfoDefined = false;
+
+int g_StartCaptureMousePos;
+int g_StartCaptureSplitterPos;
+
+CApp g_App;
+
+void MoveSubWindows(HWND hWnd);
+void OnSize(HWND hWnd);
+
+// FIXME LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
+
+const wchar_t *kWindowClass = L"FM";
+
+#ifndef _UNICODE
+static bool IsItWindowsNT()
+{
+ OSVERSIONINFO versionInfo;
+ versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
+ if (!::GetVersionEx(&versionInfo))
+ return false;
+ return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
+}
+#endif
+
+// FUNCTION: InitInstance(HANDLE, int)
+BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
+{
+ CWindow wnd;
+
+ g_hInstance = hInstance;
+
+ ReloadLangSmart();
+
+ // LoadString(hInstance, IDS_CLASS, windowClass, MAX_LOADSTRING);
+
+ // LoadString(hInstance, IDS_APP_TITLE, title, MAX_LOADSTRING);
+ UString title = LangString(IDS_APP_TITLE, 0x03000000);
+
+ /*
+ //If it is already running, then focus on the window
+ hWnd = FindWindow(windowClass, title);
+ if (hWnd)
+ {
+ SetForegroundWindow ((HWND) (((DWORD)hWnd) | 0x01));
+ return 0;
+ }
+ */
+
+#ifdef _WIN32
+ WNDCLASSW wc;
+
+ // wc.style = CS_HREDRAW | CS_VREDRAW;
+ wc.style = 0;
+ wc.lpfnWndProc = (WNDPROC) WndProc;
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = 0;
+ wc.hInstance = hInstance;
+ wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_FAM));
+
+ // wc.hCursor = LoadCursor (NULL, IDC_ARROW);
+ wc.hCursor = ::LoadCursor(0, IDC_SIZEWE);
+ // wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
+ wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1);
+
+ wc.lpszMenuName = MAKEINTRESOURCEW(IDM_MENU);
+ wc.lpszClassName = kWindowClass;
+
+ MyRegisterClass(&wc);
+
+ // RECT rect;
+ // GetClientRect(hWnd, &rect);
+
+ DWORD style = WS_OVERLAPPEDWINDOW;
+ // DWORD style = 0;
+
+ RECT rect;
+ bool maximized = false;
+ int x , y, xSize, ySize;
+ x = y = xSize = ySize = CW_USEDEFAULT;
+ bool windowPosIsRead = ReadWindowSize(rect, maximized);
+
+ if (windowPosIsRead)
+ {
+ // x = rect.left;
+ // y = rect.top;
+ xSize = rect.right - rect.left;
+ ySize = rect.bottom - rect.top;
+ }
+#endif
+
+ UINT32 numPanels, currentPanel;
+ g_PanelsInfoDefined = ReadPanelsInfo(numPanels, currentPanel, g_SplitterPos);
+ if (g_PanelsInfoDefined)
+ {
+ if (numPanels < 1 || numPanels > 2)
+ numPanels = kNumDefaultPanels;
+ if (currentPanel >= 2)
+ currentPanel = 0;
+ }
+ else
+ {
+ numPanels = kNumDefaultPanels;
+ currentPanel = 0;
+ }
+ g_App.NumPanels = numPanels;
+ g_App.LastFocusedPanel = currentPanel;
+
+#ifdef _WIN32 // FIXME
+ if (!wnd.Create(kWindowClass, title, style,
+ x, y, xSize, ySize, NULL, NULL, hInstance, NULL))
+ return FALSE;
+ g_HWND = (HWND)wnd;
+#else
+ {
+ extern HWND myCreateAndShowMainWindow(LPCTSTR title,void (*fct)(HWND));
+ g_HWND = myCreateAndShowMainWindow(title,local_WM_CREATE);
+ }
+#endif
+
+#ifdef _WIN32
+ WINDOWPLACEMENT placement;
+ placement.length = sizeof(placement);
+ if (wnd.GetPlacement(&placement))
+ {
+ if (nCmdShow == SW_SHOWNORMAL || nCmdShow == SW_SHOW ||
+ nCmdShow == SW_SHOWDEFAULT)
+ {
+ if (maximized)
+ placement.showCmd = SW_SHOWMAXIMIZED;
+ else
+ placement.showCmd = SW_SHOWNORMAL;
+ }
+ else
+ placement.showCmd = nCmdShow;
+ if (windowPosIsRead)
+ placement.rcNormalPosition = rect;
+ wnd.SetPlacement(&placement);
+ // window.Show(nCmdShow);
+ }
+ else
+ wnd.Show(nCmdShow);
+#endif
+ return TRUE;
+}
+
+/*
+static void GetCommands(const UString &aCommandLine, UString &aCommands)
+{
+ UString aProgramName;
+ aCommands.Empty();
+ bool aQuoteMode = false;
+ for (int i = 0; i < aCommandLine.Length(); i++)
+ {
+ wchar_t aChar = aCommandLine[i];
+ if (aChar == L'\"')
+ aQuoteMode = !aQuoteMode;
+ else if (aChar == L' ' && !aQuoteMode)
+ {
+ if (!aQuoteMode)
+ {
+ i++;
+ break;
+ }
+ }
+ else
+ aProgramName += aChar;
+ }
+ aCommands = aCommandLine.Mid(i);
+}
+*/
+
+#ifdef _WIN32
+DWORD GetDllVersion(LPCTSTR lpszDllName)
+{
+ HINSTANCE hinstDll;
+ DWORD dwVersion = 0;
+ hinstDll = LoadLibrary(lpszDllName);
+ if(hinstDll)
+ {
+ DLLGETVERSIONPROC pDllGetVersion;
+ pDllGetVersion = (DLLGETVERSIONPROC) GetProcAddress(hinstDll, "DllGetVersion");
+
+ /*Because some DLLs might not implement this function, you
+ must test for it explicitly. Depending on the particular
+ DLL, the lack of a DllGetVersion function can be a useful
+ indicator of the version.
+ */
+ if(pDllGetVersion)
+ {
+ DLLVERSIONINFO dvi;
+ HRESULT hr;
+
+ ZeroMemory(&dvi, sizeof(dvi));
+ dvi.cbSize = sizeof(dvi);
+
+ hr = (*pDllGetVersion)(&dvi);
+
+ if(SUCCEEDED(hr))
+ {
+ dwVersion = MAKELONG(dvi.dwMinorVersion, dvi.dwMajorVersion);
+ }
+ }
+ FreeLibrary(hinstDll);
+ }
+ return dwVersion;
+}
+
+DWORD g_ComCtl32Version;
+#endif
+
+/*
+#ifndef _WIN64
+typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
+
+static bool IsWow64()
+{
+ LPFN_ISWOW64PROCESS fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(
+ GetModuleHandle("kernel32"), "IsWow64Process");
+ if (fnIsWow64Process == NULL)
+ return false;
+ BOOL isWow;
+ if (!fnIsWow64Process(GetCurrentProcess(),&isWow))
+ return false;
+ return isWow != FALSE;
+}
+#endif
+*/
+
+#ifdef _WIN32
+bool IsLargePageSupported()
+{
+ #ifdef _WIN64
+ return true;
+ #else
+ OSVERSIONINFO versionInfo;
+ versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
+ if (!::GetVersionEx(&versionInfo))
+ return false;
+ if (versionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || versionInfo.dwMajorVersion < 5)
+ return false;
+ if (versionInfo.dwMajorVersion > 5)
+ return true;
+ if (versionInfo.dwMinorVersion < 1)
+ return false;
+ if (versionInfo.dwMinorVersion > 1)
+ return true;
+ // return IsWow64();
+ return false;
+ #endif
+}
+
+static void SetMemoryLock()
+{
+ if (!IsLargePageSupported())
+ return;
+ // if (ReadLockMemoryAdd())
+ NSecurity::AddLockMemoryPrivilege();
+
+ if (ReadLockMemoryEnable())
+ NSecurity::EnableLockMemoryPrivilege();
+}
+#endif
+
+/*
+static const int kNumSwitches = 1;
+
+namespace NKey {
+enum Enum
+{
+ kOpenArachive = 0,
+};
+
+}
+
+static const CSwitchForm kSwitchForms[kNumSwitches] =
+ {
+ { L"SOA", NSwitchType::kSimple, false },
+ };
+*/
+
+// int APIENTRY WinMain2(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /* lpCmdLine */, int /* nCmdShow */);
+
+#ifdef _WIN32
+int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /* lpCmdLine */, int nCmdShow)
+{
+ #ifndef _UNICODE
+ g_IsNT = IsItWindowsNT();
+ #endif
+
+ #ifdef _WIN32
+ SetLargePageSize();
+ #endif
+
+ InitCommonControls();
+
+ g_ComCtl32Version = ::GetDllVersion(TEXT("comctl32.dll"));
+
+ // OleInitialize is required for drag and drop.
+ OleInitialize(NULL);
+ // Maybe needs CoInitializeEx also ?
+ // NCOM::CComInitializer comInitializer;
+
+ UString programString, commandsString;
+ // MessageBoxW(0, GetCommandLineW(), L"", 0);
+ SplitStringToTwoStrings(GetCommandLineW(), programString, commandsString);
+
+ commandsString.Trim();
+ UString paramString, tailString;
+ SplitStringToTwoStrings(commandsString, paramString, tailString);
+ paramString.Trim();
+
+ if (!paramString.IsEmpty())
+ {
+ g_MainPath = paramString;
+ // return WinMain2(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
+
+ // MessageBoxW(0, paramString, L"", 0);
+ }
+ /*
+ UStringVector commandStrings;
+ NCommandLineParser::SplitCommandLine(GetCommandLineW(), commandStrings);
+ NCommandLineParser::CParser parser(kNumSwitches);
+ try
+ {
+ parser.ParseStrings(kSwitchForms, commandStrings);
+ const UStringVector &nonSwitchStrings = parser.NonSwitchStrings;
+ if(nonSwitchStrings.Size() > 1)
+ {
+ g_MainPath = nonSwitchStrings[1];
+ // g_OpenArchive = parser[NKey::kOpenArachive].ThereIs;
+ CFileInfoW fileInfo;
+ if (FindFile(g_MainPath, fileInfo))
+ {
+ if (!fileInfo.IsDir())
+ g_OpenArchive = true;
+ }
+ }
+ }
+ catch(...) { }
+ */
+
+
+ SetMemoryLock();
+
+ MSG msg;
+ if (!InitInstance (hInstance, nCmdShow))
+ return FALSE;
+
+ MyLoadMenu(g_HWND);
+
+ #ifndef _UNICODE
+ if (g_IsNT)
+ {
+ HACCEL hAccels = LoadAcceleratorsW(hInstance, MAKEINTRESOURCEW(IDR_ACCELERATOR1));
+ while (GetMessageW(&msg, NULL, 0, 0))
+ {
+ if (TranslateAcceleratorW(g_HWND, hAccels, &msg) == 0)
+ {
+ TranslateMessage(&msg);
+ DispatchMessageW(&msg);
+ }
+ }
+ }
+ else
+ #endif
+ {
+ HACCEL hAccels = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDR_ACCELERATOR1));
+ while (GetMessage(&msg, NULL, 0, 0))
+ {
+ if (TranslateAccelerator(g_HWND, hAccels, &msg) == 0)
+ {
+ // if (g_Hwnd != NULL || !IsDialogMessage(g_Hwnd, &msg))
+ // if (!IsDialogMessage(g_Hwnd, &msg))
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ }
+ }
+
+ g_HWND = 0;
+ OleUninitialize();
+ return (int)msg.wParam;
+}
+
+static void SaveWindowInfo(HWND aWnd)
+{
+ /*
+ RECT rect;
+ if (!::GetWindowRect(aWnd, &rect))
+ return;
+ */
+ WINDOWPLACEMENT placement;
+ placement.length = sizeof(placement);
+ if (!::GetWindowPlacement(aWnd, &placement))
+ return;
+ SaveWindowSize(placement.rcNormalPosition,
+ BOOLToBool(::IsZoomed(aWnd)));
+ SavePanelsInfo(g_App.NumPanels, g_App.LastFocusedPanel,
+ g_Splitter.GetPos());
+}
+#else
+int Main1(int argc,TCHAR **argv)
+{
+ if (argc >= 2)
+ {
+ g_MainPath = argv[1];
+ }
+
+ if (!InitInstance (0, 0))
+ return FALSE;
+
+ MyLoadMenu(g_HWND);
+
+ // FIXME : install Accelerators ?
+
+ return 0;
+}
+
+#endif
+
+void ExecuteCommand(UINT commandID)
+{
+// CPanel::CDisableTimerProcessing disableTimerProcessing1(g_App.Panels[0]);
+// CPanel::CDisableTimerProcessing disableTimerProcessing2(g_App.Panels[1]);
+
+ printf("FM - ExecuteCommand(%d)\n",commandID);
+ switch (commandID)
+ {
+ case kAddCommand: g_App.AddToArchive(); break;
+ case kExtractCommand: g_App.ExtractArchives(); break;
+ case kTestCommand: g_App.TestArchives(); break;
+ case IDEXIT: { // FIXME only for MacOSX ?
+ extern void appClose(void);
+ appClose();
+ break;
+ }
+ case IDM_ABOUT: { // FIXME only for MacOSX ?
+ extern void createAboutDialog(void);
+ createAboutDialog();
+ break;
+ }
+ }
+}
+
+#ifdef _WIN32
+LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ int wmId, wmEvent;
+ switch (message)
+ {
+ case WM_COMMAND:
+ wmId = LOWORD(wParam);
+ wmEvent = HIWORD(wParam);
+ if ((HWND) lParam != NULL && wmEvent != 0)
+ break;
+ if (wmId >= kToolbarStartID)
+ {
+ ExecuteCommand(wmId);
+ return 0;
+ }
+ if (OnMenuCommand(hWnd, wmId))
+ return 0;
+ break;
+ case WM_INITMENUPOPUP:
+ OnMenuActivating(hWnd, HMENU(wParam), LOWORD(lParam));
+ break;
+
+ /*
+ It doesn't help
+ case WM_EXITMENULOOP:
+ {
+ OnMenuUnActivating(hWnd);
+ break;
+ }
+ case WM_UNINITMENUPOPUP:
+ OnMenuUnActivating(hWnd, HMENU(wParam), lParam);
+ break;
+ */
+
+ case WM_CREATE:
+ {
+
+ /*
+ INITCOMMONCONTROLSEX icex;
+ icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
+ icex.dwICC = ICC_BAR_CLASSES;
+ InitCommonControlsEx(&icex);
+
+ // Toolbar buttons used to create the first 4 buttons.
+ TBBUTTON tbb [ ] =
+ {
+ // {0, 0, TBSTATE_ENABLED, BTNS_SEP, 0L, 0},
+ // {VIEW_PARENTFOLDER, kParentFolderID, TBSTATE_ENABLED, BTNS_BUTTON, 0L, 0},
+ // {0, 0, TBSTATE_ENABLED, BTNS_SEP, 0L, 0},
+ {VIEW_NEWFOLDER, ID_FILE_CREATEFOLDER, TBSTATE_ENABLED, BTNS_BUTTON, 0L, 0},
+ };
+
+ int baseID = 100;
+ NWindows::NControl::CToolBar aToolBar;
+ aToolBar.Attach(::CreateToolbarEx (hWnd,
+ WS_CHILD | WS_BORDER | WS_VISIBLE | TBSTYLE_TOOLTIPS, // | TBSTYLE_FLAT
+ baseID + 2, 11,
+ (HINSTANCE)HINST_COMMCTRL, IDB_VIEW_SMALL_COLOR,
+ (LPCTBBUTTON)&tbb, sizeof(tbb) / sizeof(tbb[0]),
+ 0, 0, 100, 30, sizeof (TBBUTTON)));
+ */
+ // HCURSOR cursor = ::LoadCursor(0, IDC_SIZEWE);
+ // ::SetCursor(cursor);
+
+ if (g_PanelsInfoDefined)
+ g_Splitter.SetPos(hWnd, g_SplitterPos);
+ else
+ {
+ g_Splitter.SetRatio(hWnd, kSplitterRateMax / 2);
+ g_SplitterPos = g_Splitter.GetPos();
+ }
+
+ RECT rect;
+ ::GetClientRect(hWnd, &rect);
+ int xSize = rect.right;
+ int xSizes[2];
+ xSizes[0] = g_Splitter.GetPos();
+ xSizes[1] = xSize - kSplitterWidth - xSizes[0];
+ if (xSizes[1] < 0)
+ xSizes[1] = 0;
+
+ g_App.CreateDragTarget();
+ bool archiveIsOpened;
+ bool encrypted;
+ bool needOpenFile = false;
+ if (!g_MainPath.IsEmpty() /* && g_OpenArchive */)
+ {
+ NFile::NFind::CFileInfoW fileInfo;
+ if (NFile::NFind::FindFile(g_MainPath, fileInfo))
+ if (!fileInfo.IsDir())
+ needOpenFile = true;
+ }
+ g_App.Create(hWnd, g_MainPath, xSizes, archiveIsOpened, encrypted);
+
+ if (needOpenFile && !archiveIsOpened)
+ {
+ UString message;
+ if (encrypted)
+ message = MyFormatNew(IDS_CANT_OPEN_ENCRYPTED_ARCHIVE, 0x0200060A, g_MainPath);
+ else
+ message = MyFormatNew(IDS_CANT_OPEN_ARCHIVE, 0x02000609, g_MainPath);
+ MessageBoxW(0, message, L"7-zip", MB_ICONERROR);
+ return -1;
+ }
+ // g_SplitterPos = 0;
+
+ // ::DragAcceptFiles(hWnd, TRUE);
+ RegisterDragDrop(hWnd, g_App._dropTarget);
+
+ break;
+ }
+ case WM_DESTROY:
+ {
+ // ::DragAcceptFiles(hWnd, FALSE);
+ RevokeDragDrop(hWnd);
+ g_App._dropTarget.Release();
+
+ g_App.Save();
+ g_App.Release();
+ SaveWindowInfo(hWnd);
+ PostQuitMessage(0);
+ break;
+ }
+ /*
+ case WM_MOVE:
+ {
+ break;
+ }
+ */
+ case WM_LBUTTONDOWN:
+ g_StartCaptureMousePos = LOWORD(lParam);
+ g_StartCaptureSplitterPos = g_Splitter.GetPos();
+ ::SetCapture(hWnd);
+ break;
+ case WM_LBUTTONUP:
+ {
+ ::ReleaseCapture();
+ break;
+ }
+ case WM_MOUSEMOVE:
+ {
+ if ((wParam & MK_LBUTTON) != 0 && ::GetCapture() == hWnd)
+ {
+ g_Splitter.SetPos(hWnd, g_StartCaptureSplitterPos +
+ (short)LOWORD(lParam) - g_StartCaptureMousePos);
+ MoveSubWindows(hWnd);
+ }
+ break;
+ }
+
+ case WM_SIZE:
+ {
+ if (g_CanChangeSplitter)
+ g_Splitter.SetPosFromRatio(hWnd);
+ else
+ {
+ g_Splitter.SetPos(hWnd, g_SplitterPos );
+ g_CanChangeSplitter = true;
+ }
+
+ OnSize(hWnd);
+ /*
+ int xSize = LOWORD(lParam);
+ int ySize = HIWORD(lParam);
+ // int xSplitter = 2;
+ int xWidth = g_SplitPos;
+ // int xSplitPos = xWidth;
+ g_Panel[0]._listView.MoveWindow(0, 0, xWidth, ySize);
+ g_Panel[1]._listView.MoveWindow(xSize - xWidth, 0, xWidth, ySize);
+ */
+ return 0;
+ break;
+ }
+ case WM_SETFOCUS:
+ // g_App.SetFocus(g_App.LastFocusedPanel);
+ g_App.SetFocusToLastItem();
+ break;
+ /*
+ case WM_ACTIVATE:
+ {
+ int fActive = LOWORD(wParam);
+ switch (fActive)
+ {
+ case WA_INACTIVE:
+ {
+ // g_FocusIndex = g_App.LastFocusedPanel;
+ // g_App.LastFocusedPanel = g_App.GetFocusedPanelIndex();
+ // return 0;
+ }
+ }
+ break;
+ }
+ */
+ /*
+ case kLangWasChangedMessage:
+ MyLoadMenu(g_HWND);
+ return 0;
+ */
+
+ /*
+ case WM_SETTINGCHANGE:
+ break;
+ */
+ case WM_NOTIFY:
+ {
+ g_App.OnNotify((int)wParam, (LPNMHDR)lParam);
+ break;
+ }
+ /*
+ case WM_DROPFILES:
+ {
+ g_App.GetFocusedPanel().CompressDropFiles((HDROP)wParam);
+ return 0 ;
+ }
+ */
+ }
+ #ifndef _UNICODE
+ if (g_IsNT)
+ return DefWindowProcW(hWnd, message, wParam, lParam);
+ else
+ #endif
+ return DefWindowProc(hWnd, message, wParam, lParam);
+
+}
+
+void OnSize(HWND hWnd)
+{
+ /*
+ if (g_App._rebar)
+ {
+ RECT rect;
+ ::GetClientRect(hWnd, &rect);
+ int xSize = rect.right;
+ int ySize = rect.bottom;
+ // rect.bottom = 0;
+ // g_App._rebar.SizeToRect(&rect);
+ // g_App._rebar.Move(0, 0, xSize, ySize);
+ }
+ */
+ MoveSubWindows(hWnd);
+}
+
+int Window_GetRealHeight(NWindows::CWindow &w)
+{
+ RECT rect;
+ WINDOWPLACEMENT placement;
+ w.GetWindowRect(&rect);
+ int res = rect.bottom - rect.top;
+ if (w.GetPlacement(&placement))
+ res += placement.rcNormalPosition.top;
+ return res;
+}
+#else // _WIN32
+static void local_WM_CREATE(HWND hWnd)
+ {
+ printf("**local_WM_CREATE**\n");
+#if 0
+ if (g_PanelsInfoDefined)
+ g_Splitter.SetPos(hWnd, g_SplitterPos);
+ else
+ {
+ g_Splitter.SetRatio(hWnd, kSplitterRateMax / 2);
+ g_SplitterPos = g_Splitter.GetPos();
+ }
+
+ RECT rect;
+ ::GetClientRect(hWnd, &rect);
+ int xSize = rect.right;
+ int xSizes[2];
+ xSizes[0] = g_Splitter.GetPos();
+ xSizes[1] = xSize - kSplitterWidth - xSizes[0];
+ if (xSizes[1] < 0)
+ xSizes[1] = 0;
+
+ g_App.CreateDragTarget();
+#else
+ int xSizes[2] = { 0,0 };
+#endif
+ bool archiveIsOpened;
+ bool encrypted;
+ bool needOpenFile = false;
+ if (!g_MainPath.IsEmpty() /* && g_OpenArchive */)
+ {
+ NFile::NFind::CFileInfoW fileInfo;
+ if (NFile::NFind::FindFile(g_MainPath, fileInfo))
+ if (!fileInfo.IsDir())
+ needOpenFile = true;
+ }
+ g_App.Create(hWnd, g_MainPath, g_ArcFormat, xSizes, archiveIsOpened, encrypted);
+
+ if (needOpenFile && !archiveIsOpened)
+ {
+ UString message;
+ if (encrypted)
+ message = MyFormatNew(IDS_CANT_OPEN_ENCRYPTED_ARCHIVE, 0x0200060A, g_MainPath);
+ else
+ message = MyFormatNew(IDS_CANT_OPEN_ARCHIVE, 0x02000609, g_MainPath);
+ MessageBoxW(0, message, L"7-zip", MB_ICONERROR);
+ return ;// -1;
+ }
+ // g_SplitterPos = 0;
+
+ // FIXME RegisterDragDrop(hWnd, g_App._dropTarget);
+
+}
+
+void main_WM_DESTROY()
+{
+ // RevokeDragDrop(hWnd);
+ // g_App._dropTarget.Release();
+printf("main_WM_DESTROY\n");
+ g_App.Save();
+ g_App.Release();
+ // SaveWindowInfo(hWnd);
+ // PostQuitMessage(0);
+}
+#endif
+
+void MoveSubWindows(HWND hWnd)
+{
+#ifdef _WIN32
+ RECT rect;
+ ::GetClientRect(hWnd, &rect);
+ int xSize = rect.right;
+ int headerSize = 0;
+ if (g_App._rebar)
+ headerSize = Window_GetRealHeight(g_App._rebar);
+ int ySize = MyMax((int)(rect.bottom - headerSize), 0);
+
+ if (g_App.NumPanels > 1)
+ {
+ g_App.Panels[0].Move(0, headerSize, g_Splitter.GetPos(), ySize);
+ int xWidth1 = g_Splitter.GetPos() + kSplitterWidth;
+ g_App.Panels[1].Move(xWidth1, headerSize, xSize - xWidth1, ySize);
+ }
+ else
+ {
+ /*
+ int otherPanel = 1 - g_App.LastFocusedPanel;
+ if (g_App.PanelsCreated[otherPanel])
+ g_App.Panels[otherPanel].Move(0, headerSize, 0, ySize);
+ */
+ g_App.Panels[g_App.LastFocusedPanel].Move(0, headerSize, xSize, ySize);
+ }
+#endif
+}
+
+
+void CApp::MoveSubWindows()
+{
+#ifdef _WIN32
+ HWND hWnd = _window;
+ RECT rect;
+ if (hWnd == 0)
+ return;
+ ::GetClientRect(hWnd, &rect);
+ int xSize = rect.right;
+ if (xSize == 0)
+ return;
+ int headerSize = 0;
+ #ifdef UNDER_CE
+ _commandBar.AutoSize();
+ {
+ _commandBar.Show(true); // maybe we need it for
+ headerSize += _commandBar.Height();
+ }
+ #endif
+ if (_toolBar)
+ {
+ _toolBar.AutoSize();
+ #ifdef UNDER_CE
+ int h2 = Window_GetRealHeight(_toolBar);
+ _toolBar.Move(0, headerSize, xSize, h2);
+ #endif
+ headerSize += Window_GetRealHeight(_toolBar);
+ }
+ int ySize = MyMax((int)(rect.bottom - headerSize), 0);
+
+ if (NumPanels > 1)
+ {
+ Panels[0].Move(0, headerSize, g_Splitter.GetPos(), ySize);
+ int xWidth1 = g_Splitter.GetPos() + kSplitterWidth;
+ Panels[1].Move(xWidth1, headerSize, xSize - xWidth1, ySize);
+ }
+ else
+ {
+ /*
+ int otherPanel = 1 - LastFocusedPanel;
+ if (PanelsCreated[otherPanel])
+ Panels[otherPanel].Move(0, headerSize, 0, ySize);
+ */
+ Panels[LastFocusedPanel].Move(0, headerSize, xSize, ySize);
+ }
+#endif
+}
+
+
+
+// FIXME for mac
+void doMacOpenFile( const UString & fileName )
+{
+ g_App.GetFocusedPanel().BindToPathAndRefresh(fileName);
+}
+
+
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/FM_rc.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/FM_rc.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/FM_rc.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/FM_rc.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,1122 @@
+#include "StdAfx.h"
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx/wx.h"
+#endif
+
+#include "wx/mimetype.h"
+#include "wx/artprov.h"
+#include "wx/imaglist.h"
+
+#undef _WIN32
+
+#include "resource.h"
+
+#include "PropertyNameRes.h"
+
+#include "App.h"
+
+#include "Windows/Window.h" // FIXME
+#include "Windows/Control/DialogImpl.h"
+#include "Windows/Control/ListView.h"
+#include "Windows/Control/Window2.h"
+
+#define static const
+#include "../GUI/p7zip_32.xpm"
+#undef static
+
+extern HWND g_HWND;
+
+#define BASE_ID_PANEL_1 (1000 + 100 * 0)
+#define BASE_ID_PANEL_2 (1000 + 100 * 1)
+
+////////////////////////////////////// Tool bar images
+#include "res/AddPNG.h"
+#include "res/Add2PNG.h"
+#include "res/ExtractPNG.h"
+#include "res/Extract2PNG.h"
+#include "res/TestPNG.h"
+#include "res/Test2PNG.h"
+#include "res/CopyPNG.h"
+#include "res/Copy2PNG.h"
+#include "res/MovePNG.h"
+#include "res/Move2PNG.h"
+#include "res/DeletePNG.h"
+#include "res/Delete2PNG.h"
+#include "res/InfoPNG.h"
+#include "res/Info2PNG.h"
+
+#include "LangUtils.h"
+
+#include <wx/mstream.h>
+#define wxGetBitmapFromMemory(name) _wxGetBitmapFromMemory(name ## _png, sizeof(name ## _png))
+
+static inline wxBitmap _wxGetBitmapFromMemory(const unsigned char *data, int length) {
+ wxMemoryInputStream is(data, length);
+ return wxBitmap(wxImage(is, wxBITMAP_TYPE_ANY, -1), -1);
+}
+
+///////////////////////////////////// SevenZipPanel.h /////////////////////
+
+#include <wx/listctrl.h>
+
+typedef wxListCtrl CExplorerListCtrl;
+
+class MyFrame;
+
+class SevenZipPanel : public wxPanel
+{
+ static int count;
+
+ MyFrame *m_frame;
+
+ CExplorerListCtrl *m_pListCtrlExplorer;
+ NWindows::NControl::CWindow2 *_wList;
+
+
+ wxBitmapButton *m_pBmpButtonParentFolder;
+ wxComboBox *m_pComboBoxPath;
+ wxStatusBar *m_pStatusBar;
+
+ wxImageList imgList;
+
+ int _panelIndex;
+
+ // wxString m_currentDirectory;
+
+ // int m_nbDirs;
+
+ // wxString m_prompt;
+
+public:
+ SevenZipPanel(MyFrame *frame, wxWindow *parent,int id,int panelIndex);
+
+ void registerWindow2(NWindows::NControl::CWindow2 *w)
+ {
+ _wList = w;
+ _wList->OnMessage(WM_CREATE,0,0);
+ }
+
+ void OnAnyButton( wxCommandEvent &event );
+ void OnSelected(wxListEvent& event);
+ void OnDeselected(wxListEvent& event);
+ void OnActivated(wxListEvent& event);
+ void OnFocused(wxListEvent& event);
+ void OnLeftDownBeginDrag(wxListEvent& event);
+ void OnRightClick(wxListEvent& event);
+ void OnColumnClick(wxListEvent& event);
+
+ void OnLeftDown(wxMouseEvent &event );
+ void OnRightDown(wxMouseEvent &event );
+
+ void OnTextEnter(wxCommandEvent& event);
+
+ void WriteText(const wxString& text) {
+ printf("DEBUG : %ls",(const wchar_t *)text);
+ }
+
+ /* Don't work ...
+ void OnCloseWindow(wxCloseEvent& WXUNUSED(event)) {
+ _wList->OnDestroy();
+ }
+ */
+
+ void evt_destroy() {
+ _wList->OnDestroy();
+ }
+
+
+private:
+ DECLARE_EVENT_TABLE()
+};
+
+
+
+///////////////////////////////////// SevenZipPanel.h /////////////////////
+
+
+
+class MyFrame: public wxFrame
+{
+public:
+ // ctor
+ MyFrame(void (*fct)(HWND),wxFrame *frame, const wxString& title, int x, int y, int w, int h);
+ // virtual ~MyFrame();
+
+ void registerWindow2(int baseID,NWindows::NControl::CWindow2 *w)
+ {
+ printf("MyFrame::registerWindow2(%d,%p)\n",baseID,w);
+ switch (baseID)
+ {
+ case BASE_ID_PANEL_1: _panel1->registerWindow2(w); break;
+ case BASE_ID_PANEL_2: _panel2->registerWindow2(w); break;
+ default: printf("FIXME - MyFrame::registerWindow2\n");
+ }
+ }
+
+ void PopulateToolbar(wxToolBar* toolBar);
+ void RecreateToolbar();
+
+
+protected:
+ // callbacks
+ void OnWorkerEvent(wxCommandEvent& event);
+ void OnAnyMenu(wxCommandEvent& event)
+ {
+ extern bool OnMenuCommand(HWND hWnd, int id);
+ extern void ExecuteCommand(UINT commandID);
+
+ int wmId = event.GetId();
+
+ if (wmId >= kToolbarStartID)
+ {
+ ExecuteCommand(wmId);
+ return ; // 0;
+ }
+ OnMenuCommand(this, wmId);
+ }
+ void OnCloseWindow(wxCloseEvent& WXUNUSED(event))
+ {
+ if (_panel1) _panel1->evt_destroy();
+ if (_panel2) _panel2->evt_destroy();
+
+ extern void main_WM_DESTROY();
+ main_WM_DESTROY();
+ Destroy();
+ }
+private:
+ SevenZipPanel * _panel1;
+ SevenZipPanel * _panel2;
+ DECLARE_EVENT_TABLE()
+};
+
+BEGIN_EVENT_TABLE(MyFrame, wxFrame)
+ EVT_MENU(WORKER_EVENT, MyFrame::OnWorkerEvent)
+ EVT_MENU(wxID_ANY, MyFrame::OnAnyMenu)
+ EVT_CLOSE(MyFrame::OnCloseWindow)
+END_EVENT_TABLE()
+
+
+static bool TEST_create(HWND hWnd) // FIXME
+{
+extern HWND g_HWND;
+ CMyListView _listView;
+
+ int _baseID = 1000;
+
+ HWND w = NWindows::GetDlgItem(g_HWND, _baseID + 1);
+ if (w == 0)
+ {
+ printf("Can't find id=%d\n",_baseID + 1);
+ return false;
+ }
+ printf("CPanel::OnCreate : _listView.Attach(%p)\n",w);
+ _listView.Attach(w);
+
+ _listView.SetRedraw(false);
+
+ _listView.DeleteAllItems();
+
+ _listView.DeleteColumn(1);
+
+ _listView.InsertColumn(0, L"toto", 100);
+
+// _listView.SetItemCount(1);
+
+ _listView.InsertItem(0, L"item 1");
+
+
+ _listView.SetRedraw(true);
+
+ return true;
+}
+
+// My frame constructor
+MyFrame::MyFrame(void (*wm_create)(HWND),wxFrame *frame, const wxString& title,
+ int x, int y, int w, int h)
+ : wxFrame(frame, wxID_ANY, title, wxPoint(x, y), wxSize(w, h))
+{
+printf("===MyFrame::MyFrame===BEGIN===\n");
+
+ this->SetIcon(wxICON(p7zip_32));
+
+ g_HWND = this; // FIXME
+
+ SetMinSize(wxSize(800,700));
+
+ wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );
+
+ _panel1 = new SevenZipPanel(this,this,BASE_ID_PANEL_1,0); // FIXME panelIndex = 0
+ _panel2 = 0;
+ topsizer->Add(
+ _panel1,
+ 1, // make vertically stretchable
+ wxEXPAND | // make horizontally stretchable
+ wxALL, // and make border all around
+ 0 ); // set border width to 10
+
+ // Create the toolbar
+ // FIXME RecreateToolbar();
+printf("===MyFrame::MyFrame===WM_CREATE===\n");
+ wm_create(this);
+// FIXME TEST_create(this);
+
+
+ // Create the toolbar // FIXME
+ RecreateToolbar();
+
+
+printf("===MyFrame::MyFrame===SIZER===\n");
+
+ SetSizer( topsizer ); // use the sizer for layout
+
+ topsizer->SetSizeHints( this ); // set size hints to honour minimum size
+printf("===MyFrame::MyFrame===END===\n");
+}
+
+void myCreateHandle(int n);
+void MyFrame::OnWorkerEvent(wxCommandEvent& event)
+{
+ int n = event.GetInt();
+// printf(" MyFrame::OnWorkerEvent(n=%d)\n",n);
+ myCreateHandle(n);
+}
+
+wxWindow * g_window=0;
+HWND myCreateAndShowMainWindow(LPCTSTR title,void (*fct)(HWND))
+{
+ MyFrame *frame = new MyFrame(fct,(wxFrame *)NULL, title, 40, 40, 800, 600);
+
+ g_window = frame;
+
+ // Don't Show the frame !
+ frame->Show(true); // FIXME
+
+ // FIXME : SetTopWindow(g_HWND);
+
+ return frame;
+}
+
+
+class myToolBar
+{
+ wxToolBar * m_toolbar;
+
+ bool m_bShowText;
+
+public:
+ myToolBar(wxToolBar * toolbar,bool bShowText ) : m_toolbar(toolbar), m_bShowText(bShowText) { }
+
+ myToolBar* AddTool(int toolId, const wxString& label, const wxBitmap& bitmap1, const wxString& shortHelpString = _T(""), wxItemKind kind = wxITEM_NORMAL)
+ {
+ wxString text = wxEmptyString;
+ if (m_bShowText) text = label;
+
+ wxSize tb_size = m_toolbar->GetToolBitmapSize();
+ int tb_witdh = tb_size.GetWidth();
+ int tb_height = tb_size.GetHeight();
+
+ if ((bitmap1.GetWidth() > tb_witdh) || ( bitmap1.GetHeight()> tb_height))
+ {
+ wxBitmap bmp(bitmap1.ConvertToImage().Scale(tb_witdh, tb_height));
+ m_toolbar->AddTool(toolId,text,bmp,shortHelpString,kind);
+ }
+ else
+ {
+ m_toolbar->AddTool(toolId,text,bitmap1,shortHelpString,kind);
+ }
+
+ return this;
+ }
+
+ void SetToolBitmapSize(const wxSize& size)
+ {
+ m_toolbar->SetToolBitmapSize(size);
+ }
+
+ bool Realize()
+ {
+ return m_toolbar->Realize();
+ }
+
+ void AddSeparator() { m_toolbar->AddSeparator(); }
+};
+
+void MyFrame::PopulateToolbar(wxToolBar* p_toolBar)
+{/*
+ toolBar->AddTool(wxID_NEW, _T("New"),toolBarBitmaps[Tool_new], wxNullBitmap, wxITEM_NORMAL,
+ _T("New file"), _T("This is help for new file tool"));
+ */
+ myToolBar toolBar(p_toolBar,true);
+
+ const int kWidth = 24;
+ const int kHeight = 24;
+
+ UString msg;
+
+ // FIXME toolBar->SetToolBitmapSize(wxSize(24,24));
+ toolBar.SetToolBitmapSize(wxSize(kWidth,kHeight));
+
+
+
+ msg = LangString(0x03020400); // { kAddCommand, IDB_ADD, IDB_ADD2, IDS_ADD, 0x03020400}
+ if (msg == L"") msg = L"Add";
+ toolBar.AddTool(kAddCommand, (const wchar_t *)msg, wxGetBitmapFromMemory(ADD2));
+
+ msg = LangString(0x03020401); // { kExtractCommand, IDB_EXTRACT, IDB_EXTRACT2, IDS_EXTRACT, 0x03020401}
+ if (msg == L"") msg = L"Extract";
+ toolBar.AddTool(kExtractCommand,(const wchar_t *)msg, wxGetBitmapFromMemory(EXTRACT2));
+
+ msg = LangString(0x03020402); // { kTestCommand , IDB_TEST, IDB_TEST2, IDS_TEST, 0x03020402}
+ if (msg == L"") msg = L"Test";
+ toolBar.AddTool(kTestCommand,(const wchar_t *)msg, wxGetBitmapFromMemory(TEST2));
+
+ toolBar.AddSeparator();
+
+ msg = LangString(0x03020420); // { IDM_COPY_TO, IDB_COPY, IDB_COPY2, IDS_BUTTON_COPY, 0x03020420}
+ if (msg == L"") msg = L"Copy";
+ toolBar.AddTool(IDM_COPY_TO, (const wchar_t *)msg, wxGetBitmapFromMemory(COPY2));
+
+ msg = LangString(0x03020421); // { IDM_MOVE_TO, IDB_MOVE, IDB_MOVE2, IDS_BUTTON_MOVE, 0x03020421}
+ if (msg == L"") msg = L"Move";
+ toolBar.AddTool(IDM_MOVE_TO, (const wchar_t *)msg, wxGetBitmapFromMemory(MOVE2));
+
+ msg = LangString(0x03020422); // { IDM_DELETE, IDB_DELETE, IDB_DELETE2, IDS_BUTTON_DELETE, 0x03020422}
+ if (msg == L"") msg = L"Delete";
+ toolBar.AddTool(IDM_DELETE, (const wchar_t *)msg, wxGetBitmapFromMemory(DELETE2));
+
+ msg = LangString(0x03020423); // { IDM_FILE_PROPERTIES, IDB_INFO, IDB_INFO2, IDS_BUTTON_INFO, 0x03020423}
+ if (msg == L"") msg = L"Info";
+ toolBar.AddTool(IDM_FILE_PROPERTIES, (const wchar_t *)msg, wxGetBitmapFromMemory(INFO2));
+
+ ////////////////////////////////////////////////////////
+
+ /* FIXME
+ if (g_mimeDatabase)
+ {
+ toolBar.AddSeparator();
+
+ TryMime(&toolBar, _T("txt"));
+ TryMime(&toolBar, _T("rar"));
+ TryMime(&toolBar, _T("7z"));
+ }
+
+ toolBar.AddSeparator();
+
+ wxIcon i_plus = wxArtProvider::GetIcon(wxART_ADD_BOOKMARK , wxART_TOOLBAR , wxSize(kWidth,kHeight));
+ toolBar.AddTool(wxID_ANY, wxT("Add Bookmark"), i_plus);
+
+ wxIcon i_go_up_dir = wxArtProvider::GetIcon(wxART_GO_DIR_UP , wxART_TOOLBAR , wxSize(kWidth,kHeight));
+ toolBar.AddTool(wxID_ANY, wxT("Go up dir"), i_go_up_dir);
+
+ wxIcon i_folder = wxArtProvider::GetIcon(wxART_FOLDER , wxART_TOOLBAR , wxSize(kWidth,kHeight));
+ toolBar.AddTool(wxID_ANY, wxT("Folder"), i_folder);
+
+ wxIcon i_missing_image = wxArtProvider::GetIcon(wxART_MISSING_IMAGE , wxART_TOOLBAR , wxSize(kWidth,kHeight));
+ toolBar.AddTool(wxID_ANY, wxT("missing image"), i_missing_image);
+ */
+
+ ///////////////////////////////////////////////////////
+
+ toolBar.Realize();
+
+ // toolBar->SetRows(!(toolBar->IsVertical()) ? m_rows : 10 / m_rows);
+}
+void MyFrame::RecreateToolbar()
+{
+ // delete and recreate the toolbar
+ wxToolBar *toolBar = GetToolBar();
+ // long style = toolBar ? toolBar->GetWindowStyle() : TOOLBAR_STYLE;
+
+ SetToolBar(NULL);
+
+ delete toolBar;
+ /*
+ style &= ~(wxTB_HORIZONTAL | wxTB_VERTICAL | wxTB_BOTTOM | wxTB_RIGHT | wxTB_HORZ_LAYOUT);
+ switch( m_toolbarPosition )
+ {
+ case TOOLBAR_LEFT:style |= wxTB_LEFT; break;
+ case TOOLBAR_TOP: style |= wxTB_TOP;break;
+ case TOOLBAR_RIGHT:style |= wxTB_RIGHT;break;
+ case TOOLBAR_BOTTOM:style |= wxTB_BOTTOM;break;
+ }
+ */
+ long style = wxTB_FLAT | wxTB_NODIVIDER | wxTB_TEXT; // TOOLBAR_STYLE | wxTB_TOP;
+ /*
+ if ( m_showTooltips ) style &= ~wxTB_NO_TOOLTIPS;
+ else style |= wxTB_NO_TOOLTIPS;
+
+ if ( style & wxTB_TEXT && !(style & wxTB_NOICONS) && m_horzText ) style |= wxTB_HORZ_LAYOUT;
+ */
+ toolBar = CreateToolBar(style, wxID_ANY);
+
+ PopulateToolbar(toolBar);
+}
+
+void registerWindow2(int baseID,NWindows::NControl::CWindow2 *w)
+{
+ MyFrame * f = (MyFrame *) g_HWND;
+ f->registerWindow2(baseID,w);
+
+}
+
+
+/////////////////////////////////////////////////////////
+#include "LangUtils.h"
+
+static const UINT kOpenBookmarkMenuID = 730; // FIXME / duplicate
+static const UINT kSetBookmarkMenuID = 740;
+
+
+void rc_MyLoadMenu(HWND hWnd)
+{
+ wxFrame *hwnd = (wxFrame *)hWnd;
+ wxMenu *m;
+ wxMenu *m_file = m = new wxMenu;
+ {
+ m->Append(IDM_FILE_OPEN, _T("&Open")); // FIXME "&Open\tEnter" - don't use Enter to support combobox enter ...
+ m->Append(IDM_FILE_OPEN_INSIDE,_T("Open &Inside\tCtrl+PgDn"));
+ m->Append(IDM_FILE_OPEN_OUTSIDE,_T("Open O&utside\tShift+Enter"));
+// m->Append(IDM_FILE_EDIT,_T("&Edit\tF4"));
+ m->AppendSeparator();
+// m->Append(IDM_RENAME,_T("Rena&me\tF2"));
+ m->Append(IDM_COPY_TO,_T("&Copy To...\tF5"));
+ m->Append(IDM_MOVE_TO,_T("&Move To...\tF6"));
+ m->Append(IDM_DELETE,_T("&Delete\tDel"));
+ m->AppendSeparator();
+ m->Append(IDM_FILE_SPLIT,_T("&Split file..."));
+ m->Append(IDM_FILE_COMBINE,_T("Com&bine files..."));
+ m->AppendSeparator();
+// m->Append(IDM_FILE_PROPERTIES,_T("P&roperties\tAlt+Enter"));
+// m->Append(IDM_FILE_COMMENT,_T("Comme&nt\tCtrl+Z"));
+ m->Append(IDM_FILE_CRC,_T("Calculate checksum"));
+ m->Append(IDM_FILE_DIFF,_T("Di&ff"));
+ m->AppendSeparator();
+ m->Append(IDM_CREATE_FOLDER,_T("Create Folder\tF7"));
+ m->Append(IDM_CREATE_FILE,_T("Create File\tCtrl+N"));
+ m->AppendSeparator();
+ m->Append(IDEXIT,_T("E&xit\tAlt+F4"));
+ }
+ wxMenu *m_edit = m = new wxMenu;
+ {
+ m->Append(IDM_EDIT_CUT, _T("Cu&t\tCtrl+X"))->Enable(true); // GRAYED
+ // m->Enable(IDM_EDIT_CUT, false);
+ m->Append(IDM_EDIT_COPY, _T("&Copy\tCtrl+C"))->Enable(true); // GRAYED
+ m->Append(IDM_EDIT_PASTE, _T("&Paste\tCtrl+V"))->Enable(true); // GRAYED
+ m->AppendSeparator();
+ m->Append(IDM_SELECT_ALL, _T("Select &All\tShift+[Grey +]"));
+ m->Append(IDM_DESELECT_ALL, _T("Deselect All\tShift+[Grey -]"));
+ m->Append(IDM_INVERT_SELECTION, _T("&Invert Selection\tGrey *"));
+ m->Append(IDM_SELECT, _T("Select...\tGrey +"));
+ m->Append(IDM_DESELECT, _T("Deselect...\tGrey -"));
+// FIXME m->Append(IDM_SELECT_BY_TYPE, _T("Select by Type\tAlt+[Grey+]"));
+// FIXME m->Append(IDM_DESELECT_BY_TYPE, _T("Deselect by Type\tAlt+[Grey -]"));
+ }
+ wxMenu *m_view = m = new wxMenu;
+ {
+/*
+ m->AppendRadioItem(IDM_VIEW_LARGE_ICONS, _T("Lar&ge Icons\tCtrl+1"));
+ m->AppendRadioItem(IDM_VIEW_SMALL_ICONS, _T("S&mall Icons\tCtrl+2"));
+ m->AppendRadioItem(IDM_VIEW_LIST, _T("&List\tCtrl+3"));
+ m->AppendRadioItem(IDM_VIEW_DETAILS, _T("&Details\tCtrl+4"))->Check(true); // CHECKED
+ m->AppendSeparator();
+ m->Append(IDM_VIEW_ARANGE_BY_NAME, _T("Name\tCtrl+F3"));
+ m->Append(IDM_VIEW_ARANGE_BY_TYPE, _T("Type\tCtrl+F4"));
+ m->Append(IDM_VIEW_ARANGE_BY_DATE, _T("Date\tCtrl+F5"));
+ m->Append(IDM_VIEW_ARANGE_BY_SIZE, _T("Size\tCtrl+F6"));
+ m->Append(IDM_VIEW_ARANGE_NO_SORT, _T("Unsorted\tCtrl+F7"));
+ m->AppendSeparator();
+ m->AppendCheckItem(IDM_VIEW_FLAT_VIEW, _T("Flat View"));
+ m->AppendCheckItem(IDM_VIEW_TWO_PANELS, _T("&2 Panels\tF9"));
+
+ {
+ wxMenu* subMenu = new wxMenu;
+ subMenu->AppendCheckItem(IDM_VIEW_ARCHIVE_TOOLBAR, _T("Archive Toolbar"));
+ subMenu->AppendCheckItem(IDM_VIEW_STANDARD_TOOLBAR, _T("Standard Toolbar"));
+ subMenu->AppendSeparator();
+ subMenu->AppendCheckItem(IDM_VIEW_TOOLBARS_LARGE_BUTTONS, _T("Large Buttons"));
+ subMenu->AppendCheckItem(IDM_VIEW_TOOLBARS_SHOW_BUTTONS_TEXT, _T("Show Buttons Text"));
+ m->Append(12112, _T("Toolbars"), subMenu); // FIXME ID ?
+ }
+ m->AppendSeparator();
+*/
+ m->Append(IDM_OPEN_ROOT_FOLDER, _T("Open Root Folder\t" STRING_PATH_SEPARATOR));
+ m->Append(IDM_OPEN_PARENT_FOLDER, _T("Up One Level\tBackspace"));
+ m->Append(IDM_FOLDERS_HISTORY, _T("Folders History...\tAlt+F12"));
+ m->AppendSeparator();
+ m->Append(IDM_VIEW_REFRESH, _T("&Refresh\tCtrl+R"));
+ }
+ wxMenu *m_favorites = m = new wxMenu;
+ {
+ {
+ wxMenu* subMenu = new wxMenu;
+ for (int i = 0; i < 10; i++)
+ {
+ UString s = LangString(IDS_BOOKMARK, 0x03000720);
+ s += L" ";
+ wchar_t c = (wchar_t)(L'0' + i);
+ s += c;
+ s += L"\tAlt+Shift+";
+ s += c;
+ subMenu->Append( kSetBookmarkMenuID + i, wxString(s));
+ }
+
+ m->Append(12111, _T("&Add folder to Favorites as"), subMenu); // FIXME ID ?
+ }
+ m->AppendSeparator();
+ for (int i = 0; i < 10; i++)
+ {
+ UString path = g_App.AppState.FastFolders.GetString(i);
+ const int kMaxSize = 100;
+ const int kFirstPartSize = kMaxSize / 2;
+ if (path.Length() > kMaxSize)
+ {
+ path = path.Left(kFirstPartSize) + UString(L" ... ") +
+ path.Right(kMaxSize - kFirstPartSize);
+ }
+ UString s = path;
+ if (s.IsEmpty())
+ s = L"-";
+ s += L"\tAlt+";
+ s += (wchar_t)(L'0' + i);
+ // menu.AppendItem(MF_STRING, kOpenBookmarkMenuID + i, s);
+ m->Append( kOpenBookmarkMenuID + i, wxString(s));
+ }
+
+ }
+ wxMenu *m_tools = m = new wxMenu;
+ {
+// m->Append(IDM_OPTIONS, _T("&Options..."));
+ m->Append(IDM_BENCHMARK, _T("&Benchmark"));
+ }
+ wxMenu *m_help = m = new wxMenu;
+ {
+ m->Append(IDM_HELP_CONTENTS, _T("&Contents...\tF1"));
+ m->AppendSeparator();
+ m->Append(IDM_ABOUT, _T("&About 7-Zip..."));
+ }
+
+ wxMenuBar *menuBar = new wxMenuBar;
+
+ menuBar->Append(m_file, _T("&File"));
+ menuBar->Append(m_edit, _T("&Edit"));
+ menuBar->Append(m_view, _T("&View"));
+ menuBar->Append(m_favorites, _T("F&avorites"));
+ menuBar->Append(m_tools, _T("&Tools"));
+ menuBar->Append(m_help, _T("&Help"));
+ hwnd->SetMenuBar(menuBar);
+}
+
+//////////////////////////////////////////////////////////////////
+
+
+static CStringTable g_stringTable[] =
+{
+ /* resource.rc */
+ /***************/
+ { IDS_APP_TITLE, L"7-Zip File Manager" },
+
+ { IDS_COPY , L"Copy" },
+ { IDS_MOVE , L"Move" },
+ { IDS_COPY_TO , L"Copy to:" },
+ { IDS_MOVE_TO , L"Move to:" },
+ { IDS_COPYING , L"Copying..." },
+ { IDS_MOVING , L"Moving..." },
+ { IDS_CANNOT_COPY , L"You cannot move or copy items for such folders." },
+ { IDS_SPLITTING , L"Splitting..." },
+ { IDS_SPLIT_CONFIRM_TITLE , L"Confirm Splitting" },
+ { IDS_SPLIT_CONFIRM_MESSAGE , L"Are you sure you want to split file into {0} volumes?" },
+ { IDS_SPLIT_VOL_MUST_BE_SMALLER , L"Volume size must be smaller than size of original file" },
+
+ { IDS_COMBINE , L"Combine Files" },
+ { IDS_COMBINE_TO , L"&Combine to:" },
+ { IDS_COMBINING , L"Combining..." },
+ { IDS_COMBINE_SELECT_ONE_FILE , L"Select only first file" },
+
+ { IDS_CHECKSUM_CALCULATING , L"Checksum calculating..." },
+ { IDS_CHECKSUM_INFORMATION , L"Checksum information" },
+ { IDS_CHECKSUM_CRC_DATA , L"CRC checksum for data:" },
+ { IDS_CHECKSUM_CRC_DATA_NAMES , L"CRC checksum for data and names:" },
+
+ { IDS_SCANNING , L"Scanning..." },
+
+ { IDS_PROPERTIES , L"Properties" },
+
+ { IDS_OPERATION_IS_NOT_SUPPORTED , L"Operation is not supported." },
+
+ { IDS_CONFIRM_FILE_DELETE , L"Confirm File Delete" },
+ { IDS_CONFIRM_FOLDER_DELETE , L"Confirm Folder Delete" },
+ { IDS_CONFIRM_ITEMS_DELETE , L"Confirm Multiple File Delete" },
+ { IDS_WANT_TO_DELETE_FILE , L"Are you sure you want to delete '{0}'?" },
+ { IDS_WANT_TO_DELETE_FOLDER , L"Are you sure you want to delete the folder '{0}' and all its contents?" },
+ { IDS_WANT_TO_DELETE_ITEMS , L"Are you sure you want to delete these {0} items?" },
+ { IDS_DELETING , L"Deleting..." },
+ { IDS_ERROR_DELETING , L"Error Deleting File or Folder" },
+ { IDS_RENAMING , L"Renaming..." },
+ { IDS_ERROR_RENAMING , L"Error Renaming File or Folder" },
+ { IDS_CONFIRM_FILE_COPY , L"Confirm File Copy" },
+ { IDS_WANT_TO_COPY_FILES , L"Are you sure you want to copy files to archive" },
+
+ { IDS_CREATE_FOLDER , L"Create Folder" },
+ { IDS_CREATE_FOLDER_NAME , L"Folder name:" },
+ { IDS_CREATE_FOLDER_DEFAULT_NAME , L"New Folder" },
+ { IDS_CREATE_FOLDER_ERROR , L"Error Creating Folder" },
+ { IDS_CREATE_FILE , L"Create File" },
+ { IDS_CREATE_FILE_NAME , L"File Name:" },
+ { IDS_CREATE_FILE_DEFAULT_NAME , L"New File" },
+ { IDS_CREATE_FILE_ERROR , L"Error Creating File" },
+ { IDS_SELECT , L"Select" },
+ { IDS_DESELECT , L"Deselect" },
+ { IDS_SELECT_MASK , L"Mask:" },
+ { IDS_FOLDERS_HISTORY , L"Folders History" },
+ { IDS_N_SELECTED_ITEMS , L"{0} object(s) selected" },
+ { IDS_FILES_COLON , L"Files:" },
+ { IDS_FOLDERS_COLON , L"Folders:" },
+ { IDS_SIZE_COLON , L"Size:" },
+
+ { IDS_PROP_TOTAL_SIZE , L"Total Size" },
+ { IDS_PROP_FREE_SPACE , L"Free Space" },
+ { IDS_PROP_CLUSTER_SIZE , L"Cluster Size" },
+ { IDS_PROP_VOLUME_NAME , L"Label" },
+ { IDS_PROP_LOCAL_NAME , L"Local Name" },
+ { IDS_PROP_PROVIDER , L"Provider" },
+ { IDS_OPTIONS , L"Options" },
+ { IDS_COMMENT , L"Comment" },
+ { IDS_COMMENT2 , L"&Comment:" },
+ { IDS_SYSTEM , L"System" },
+ { IDS_TOO_MANY_ITEMS , L"Too many items" },
+ { IDS_WANT_UPDATE_MODIFIED_FILE , L"File '{0}' was modified.\nDo you want to update it in the archive?" },
+ { IDS_CANNOT_UPDATE_FILE , L"Can not update file\n'{0}'" },
+ { IDS_CANNOT_START_EDITOR , L"Cannot start editor." },
+ { IDS_OPENNING , L"Opening..." },
+ { IDS_ADD , L"Add" },
+ { IDS_EXTRACT , L"Extract" },
+ { IDS_TEST , L"Test" },
+ { IDS_BUTTON_COPY , L"Copy" },
+ { IDS_BUTTON_MOVE , L"Move" },
+ { IDS_BUTTON_DELETE , L"Delete" },
+ { IDS_BUTTON_INFO , L"Info" },
+ { IDS_BOOKMARK , L"Bookmark" },
+ { IDS_COMPUTER , L"Computer" },
+ { IDS_NETWORK , L"Network" },
+
+ { IDS_PROGRESS_TESTING , L"Testing" },
+ { IDS_MESSAGE_NO_ERRORS , L"There are no errors" },
+
+ /* PropertyName.rc */
+ /*******************/
+ { IDS_PROP_PATH , L"Path" },
+ { IDS_PROP_NAME , L"Name" },
+ { IDS_PROP_EXTENSION , L"Extension" },
+ { IDS_PROP_IS_FOLDER , L"Folder" },
+ { IDS_PROP_SIZE , L"Size" },
+ { IDS_PROP_PACKED_SIZE , L"Packed Size" },
+ { IDS_PROP_ATTRIBUTES , L"Attributes" },
+ { IDS_PROP_CTIME , L"Created" },
+ { IDS_PROP_ATIME , L"Accessed" },
+ { IDS_PROP_MTIME , L"Modified" },
+ { IDS_PROP_SOLID , L"Solid" },
+ { IDS_PROP_C0MMENTED , L"Commented" },
+ { IDS_PROP_ENCRYPTED , L"Encrypted" },
+ { IDS_PROP_DICTIONARY_SIZE , L"Dictionary Size" },
+ { IDS_PROP_SPLIT_BEFORE , L"Split Before" },
+ { IDS_PROP_SPLIT_AFTER , L"Split After" },
+ { IDS_PROP_CRC , L"CRC" },
+ { IDS_PROP_FILE_TYPE , L"Type" },
+ { IDS_PROP_ANTI , L"Anti" },
+ { IDS_PROP_METHOD , L"Method" },
+ { IDS_PROP_HOST_OS , L"Host OS" },
+ { IDS_PROP_FILE_SYSTEM , L"File System" },
+ { IDS_PROP_USER , L"User" },
+ { IDS_PROP_GROUP , L"Group" },
+ { IDS_PROP_BLOCK , L"Block" },
+ { IDS_PROP_COMMENT , L"Comment" },
+ { IDS_PROP_POSITION , L"Position" },
+ { IDS_PROP_PREFIX , L"Path Prefix" },
+ { IDS_PROP_FOLDERS , L"Folders" },
+ { IDS_PROP_FILES , L"Files" },
+ { IDS_PROP_VERSION , L"Version" },
+ { IDS_PROP_VOLUME , L"Volume" },
+ { IDS_PROP_IS_VOLUME , L"Multivolume" },
+ { IDS_PROP_OFFSET , L"Offset" },
+ { IDS_PROP_LINKS , L"Links" },
+ { IDS_PROP_NUM_BLOCKS , L"Blocks" },
+ { IDS_PROP_NUM_VOLUMES , L"Volumes" },
+
+ { IDS_PROP_BIT64 , L"64-bit" },
+ { IDS_PROP_BIG_ENDIAN , L"Big-endian" },
+ { IDS_PROP_CPU , L"CPU" },
+ { IDS_PROP_PHY_SIZE , L"Physical Size" },
+ { IDS_PROP_HEADERS_SIZE , L"Headers Size" },
+ { IDS_PROP_CHECKSUM , L"Checksum" },
+ { IDS_PROP_CHARACTS , L"Characteristics" },
+ { IDS_PROP_VA , L"Virtual Address" },
+ { IDS_PROP_ID , L"ID" },
+ { IDS_PROP_SHORT_NAME , L"Short Name" },
+ { IDS_PROP_CREATOR_APP , L"Creator Application" },
+ { IDS_PROP_SECTOR_SIZE , L"Sector Size" },
+ { IDS_PROP_POSIX_ATTRIB , L"Mode" },
+ { IDS_PROP_LINK , L"Link" },
+ { IDS_PROP_ERROR , L"Error" },
+
+
+ { 0 , 0 }
+};
+
+REGISTER_STRINGTABLE(g_stringTable)
+
+/////////////////////////////////////////////////////
+
+#include "res/ParentFolder.h"
+
+ SevenZipPanel::SevenZipPanel(MyFrame *frame, wxWindow *parent,int id,int panelIndex) :
+ wxPanel(parent,id) , m_frame(frame), _wList(0)
+ {
+ _panelIndex = panelIndex;
+
+ int _baseID = id; // FIXME
+ int _listID = _baseID + 1;
+ int _comboBoxID = _baseID + 3;
+ int _statusBarID = _comboBoxID + 1;
+ int kParentFolderID = 100; // FIXME Panel.h
+
+
+ ///Sizer for adding the controls created by users
+ wxBoxSizer* pMainSizer = new wxBoxSizer(wxVERTICAL);
+ int sizes[] = {150, 250, 350, -1};
+ wxArrayString pathArray;
+ wxBoxSizer *pPathSizer = new wxBoxSizer(wxHORIZONTAL);
+ m_pBmpButtonParentFolder = new wxBitmapButton(this, kParentFolderID, wxGetBitmapFromMemory(PARENT_FOLDER), wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW);
+ m_pComboBoxPath = new wxComboBox(this, _comboBoxID, wxEmptyString, wxDefaultPosition, wxSize(300,-1), pathArray, wxCB_DROPDOWN | wxCB_SORT );
+ pPathSizer->Add(m_pBmpButtonParentFolder, 0, wxALL|wxEXPAND, 0);
+ pPathSizer->Add(m_pComboBoxPath, 1, wxALL|wxEXPAND, 5);
+
+ m_pListCtrlExplorer = new CExplorerListCtrl(this,_listID,wxDefaultPosition, wxSize(300,300),
+ wxLC_REPORT | // wxLC_EDIT_LABELS | FIXME
+ wxSUNKEN_BORDER);
+
+ printf("DEBUG : new CExplorerListCtrl(id=%d) => %p\n",_listID,m_pListCtrlExplorer);
+
+ m_pStatusBar = new wxStatusBar(this, _statusBarID);
+ m_pStatusBar->SetFieldsCount(4, sizes);
+ pMainSizer->Add(pPathSizer, 0, wxALL|wxEXPAND, 0);
+ pMainSizer->Add(m_pListCtrlExplorer, 1, wxALL|wxEXPAND, 0);
+ pMainSizer->Add(m_pStatusBar, 0, wxALL|wxEXPAND, 0);
+ SetSizer(pMainSizer);
+ SetAutoLayout (true);
+ Layout();
+
+
+ // m_pListCtrlExplorer->SetDropTarget(new DnDFile(this));
+
+ }
+
+ void SevenZipPanel::OnAnyButton( wxCommandEvent &event )
+ {
+ count++;
+
+ int id = event.GetId();
+
+ wxString msg = wxString::Format(_T("P %d : button %d \n"), count,id);
+
+ WriteText(msg);
+
+ _wList->OnMessage(WM_COMMAND , id , 0);
+ }
+
+ void SevenZipPanel::OnSelected(wxListEvent& event)
+ {
+ const wxListItem & item = event.GetItem();
+ count++;
+
+ wxString msg = wxString::Format(_T("P %d : OnSelected %d \n"), count,event.GetId());
+
+ WriteText(msg);
+
+ NMLISTVIEW info;
+ info.hdr.hwndFrom = m_pListCtrlExplorer;
+ info.hdr.code = LVN_ITEMCHANGED;
+ info.uOldState = 0;
+ info.uNewState = LVIS_SELECTED;
+ info.lParam = item.GetData(); // event.GetIndex(); // FIXME ? event.GetData();
+ _wList->OnMessage(WM_NOTIFY , event.GetId() , (LPARAM)&info);
+ /*
+ if ( GetWindowStyle() & wxLC_REPORT )
+ {
+ wxListItem info;
+ info.m_itemId = event.m_itemIndex;
+ info.m_col = 1;
+ info.m_mask = wxLIST_MASK_TEXT;
+ if ( GetItem(info) )
+ {
+ wxLogMessage(wxT("Value of the 2nd field of the selected item: %s"),
+ info.m_text.c_str());
+ }
+ else
+ {
+ wxFAIL_MSG(wxT("wxListCtrl::GetItem() failed"));
+ }
+ }
+ */
+ }
+
+
+
+ void SevenZipPanel::OnDeselected(wxListEvent& event)
+ {
+ const wxListItem & item = event.GetItem();
+ count++;
+ wxString msg = wxString::Format(_T("P %d : OnDeselected %d \n"), count,event.GetId());
+ WriteText(msg);
+
+ NMLISTVIEW info;
+ info.hdr.hwndFrom = m_pListCtrlExplorer;
+ info.hdr.code = LVN_ITEMCHANGED;
+ info.uOldState = LVIS_SELECTED;
+ info.uNewState = 0;
+ info.lParam = item.GetData(); // event.GetIndex(); // FIXME ? event.GetData();
+ _wList->OnMessage(WM_NOTIFY , event.GetId() , (LPARAM)&info);
+ }
+
+ void SevenZipPanel::OnColumnClick(wxListEvent& event)
+ {
+ count++;
+ wxString msg = wxString::Format(_T("P %d : OnColumnClick %d col=%d\n"), count,event.GetId(),event.GetColumn());
+ WriteText(msg);
+
+ NMLISTVIEW info;
+ info.hdr.hwndFrom = m_pListCtrlExplorer;
+ info.hdr.code = LVN_COLUMNCLICK;
+ info.iSubItem = event.GetColumn();
+ _wList->OnMessage(WM_NOTIFY , event.GetId() , (LPARAM)&info);
+
+ }
+
+
+ void SevenZipPanel::OnActivated(wxListEvent& event)
+ {
+ count++;
+
+ int ind = event.GetIndex();
+
+ NMHDR info;
+ info.hwndFrom = m_pListCtrlExplorer;
+ info.code = NM_DBLCLK;
+ _wList->OnMessage(WM_NOTIFY , event.GetId() , (LPARAM)&info);
+
+ /*
+ if ((ind >= 0) && ( ind < m_nbDirs))
+ {
+ wxString msg = wxString::Format(_T("P %d : OnActivated %d : DIR = %d\n"), count,event.GetId(),ind);
+ WriteText(msg);
+
+ wxString name = m_pListCtrlExplorer->GetItemText(ind);
+
+ wxFileName filename (m_currentDirectory,name);
+ BinPath(filename.GetFullPath());
+
+ }
+ else
+ */
+ {
+ wxString msg = wxString::Format(_T("P %d : OnActivated %d : FILE = %d\n"), count,event.GetId(),ind);
+ WriteText(msg);
+ }
+ }
+
+ void SevenZipPanel::OnFocused(wxListEvent& event)
+ {
+ count++;
+
+ wxString msg = wxString::Format(_T("P %d : OnFocused %d \n"), count,event.GetId());
+
+ WriteText(msg);
+
+ event.Skip();
+ }
+
+ void SevenZipPanel::OnLeftDownBeginDrag(wxListEvent& event)
+ {
+ count++;
+
+ wxString msg = wxString::Format(_T("P %d : OnLeftDownBeginDrag %d \n"), count,event.GetId());
+ WriteText(msg);
+
+#if 0
+ if ( m_pListCtrlExplorer->GetSelectedItemCount() < 1) return ;
+
+ // start drag operation
+ wxFileDataObject filesData;
+
+
+ long item = -1;
+ for ( ;; )
+ {
+ item = m_pListCtrlExplorer->GetNextItem(item,
+ wxLIST_NEXT_ALL,
+ wxLIST_STATE_SELECTED);
+ if ( item == -1 )
+ break;
+
+ // this item is selected - do whatever is needed with it
+ // wxLogMessage("Item %ld is selected.", item);
+ wxString file = m_currentDirectory + _T("/") + m_pListCtrlExplorer->GetItemText(item);
+
+ filesData.AddFile(file);
+
+ }
+
+ msg = wxString::Format(_T("P %d : wxDropSource %d \n"), count,event.GetId());
+ WriteText(msg);
+
+ wxDropSource source(filesData, this,
+ wxDROP_ICON(dnd_copy),
+ wxDROP_ICON(dnd_move),
+ wxDROP_ICON(dnd_none));
+
+ int flags = 0;
+ /*
+ if ( m_moveByDefault )
+ flags |= wxDrag_DefaultMove;
+ else if ( m_moveAllow )
+ flags |= wxDrag_AllowMove;
+ */
+ flags |= wxDrag_AllowMove;
+
+ msg = wxString::Format(_T("P %d : DoDragDrop %d \n"), count,event.GetId());
+ WriteText(msg);
+
+
+ wxDragResult result = source.DoDragDrop(flags);
+
+
+ const wxChar *pc;
+ switch ( result )
+ {
+ case wxDragError: pc = _T("Error!"); break;
+ case wxDragNone: pc = _T("Nothing"); break;
+ case wxDragCopy: pc = _T("Copied"); break;
+ case wxDragMove: pc = _T("Moved"); break;
+ case wxDragCancel: pc = _T("Cancelled"); break;
+ default: pc = _T("Huh?"); break;
+ }
+
+ WriteText(wxString(_T(" Drag result: ")) + pc);
+#endif
+ }
+
+void SevenZipPanel::OnLeftDown(wxMouseEvent &WXUNUSED(event) )
+{
+ WriteText(_T("OnLeftDown"));
+#if 0
+ if ( !m_strText.empty() )
+ {
+ // start drag operation
+ wxTextDataObject textData(m_strText);
+ wxDropSource source(textData, this,
+ wxDROP_ICON(dnd_copy),
+ wxDROP_ICON(dnd_move),
+ wxDROP_ICON(dnd_none));
+
+ int flags = 0;
+ if ( m_moveByDefault )
+ flags |= wxDrag_DefaultMove;
+ else if ( m_moveAllow )
+ flags |= wxDrag_AllowMove;
+
+ wxDragResult result = source.DoDragDrop(flags);
+
+#if wxUSE_STATUSBAR
+ const wxChar *pc;
+ switch ( result )
+ {
+ case wxDragError: pc = _T("Error!"); break;
+ case wxDragNone: pc = _T("Nothing"); break;
+ case wxDragCopy: pc = _T("Copied"); break;
+ case wxDragMove: pc = _T("Moved"); break;
+ case wxDragCancel: pc = _T("Cancelled"); break;
+ default: pc = _T("Huh?"); break;
+ }
+
+ SetStatusText(wxString(_T("Drag result: ")) + pc);
+#else
+ wxUnusedVar(result);
+#endif // wxUSE_STATUSBAR
+ }
+#endif // wxUSE_DRAG_AND_DROP
+}
+
+void SevenZipPanel::OnRightClick(wxListEvent& event)
+{
+ wxPoint point = event.GetPoint();
+
+ WriteText(_T("OnRightClick"));
+ wxMenu menu; // (_T("Dnd sample menu"));
+
+ menu.Append(wxID_ANY, _T("&Test drag..."));
+ menu.AppendSeparator();
+ menu.Append(wxID_ANY, _T("item1"));
+ menu.Append(wxID_ANY, _T("item2"));
+ menu.Append(wxID_ANY, _T("item3"));
+ menu.Append(wxID_ANY, _T("&About"));
+
+ PopupMenu( &menu, point.x, point.y );
+}
+
+void SevenZipPanel::OnTextEnter(wxCommandEvent& event)
+{
+ count++;
+
+ NMCBEENDEDITW info;
+ info.hdr.hwndFrom = m_pComboBoxPath;
+ info.hdr.code = CBEN_ENDEDITW;
+ info.iWhy = CBENF_RETURN;
+
+ _wList->OnMessage(WM_NOTIFY , event.GetId() , (LPARAM)&info);
+
+ {
+ wxString msg = wxString::Format(_T("P %d : OnTextEnter %d\n"), count,event.GetId());
+ WriteText(msg);
+ }
+}
+
+int SevenZipPanel::count = 0;
+
+BEGIN_EVENT_TABLE(SevenZipPanel, wxPanel)
+// EVT_MENU(wxID_ANY, SevenZipPanel::OnAnyMenu)
+// EVT_LISTBOX (wxID_ANY, MyPanel::OnListBox)
+// EVT_LISTBOX_DCLICK(wxID_ANY, MyPanel::OnAnyListBoxDoubleClick)
+EVT_BUTTON (wxID_ANY, SevenZipPanel::OnAnyButton)
+
+ // EVT_CLOSE(SevenZipPanel::OnCloseWindow)
+
+/////////////////
+EVT_LIST_ITEM_SELECTED(wxID_ANY, SevenZipPanel::OnSelected)
+EVT_LIST_ITEM_DESELECTED(wxID_ANY, SevenZipPanel::OnDeselected)
+EVT_LIST_ITEM_ACTIVATED(wxID_ANY, SevenZipPanel::OnActivated)
+EVT_LIST_ITEM_FOCUSED(wxID_ANY, SevenZipPanel::OnFocused)
+
+EVT_LIST_BEGIN_DRAG(wxID_ANY, SevenZipPanel::OnLeftDownBeginDrag)
+// FIXME - add for menu on item - EVT_LIST_ITEM_RIGHT_CLICK(wxID_ANY, SevenZipPanel::OnRightClick)
+
+EVT_LIST_COL_CLICK(wxID_ANY, SevenZipPanel::OnColumnClick)
+
+
+EVT_TEXT_ENTER(wxID_ANY, SevenZipPanel::OnTextEnter) // FIXME - not called
+
+
+END_EVENT_TABLE()
+
+
+
+void appClose(void)
+{
+ g_window->Close(true);
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/FSDrives.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/FSDrives.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/FSDrives.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/FSDrives.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,456 @@
+// FSDrives.cpp
+
+#include "StdAfx.h"
+
+#include "../../../../C/Alloc.h"
+
+#include "Common/ComTry.h"
+#include "Common/StringConvert.h"
+
+#include "Windows/Defs.h"
+#include "Windows/FileDir.h"
+#include "Windows/FileIO.h"
+// FIXME #include "Windows/FileSystem.h"
+#include "Windows/PropVariant.h"
+
+#include "../../PropID.h"
+
+#include "FSDrives.h"
+#include "FSFolder.h"
+#include "LangUtils.h"
+#include "SysIconUtils.h"
+
+#include "resource.h"
+
+using namespace NWindows;
+using namespace NFile;
+using namespace NFind;
+
+static const wchar_t *kVolPrefix = L"\\\\.\\";
+
+UString CDriveInfo::GetDeviceFileIoName() const
+{
+ return kVolPrefix + Name;
+}
+
+struct CPhysTempBuffer
+{
+ void *buffer;
+ CPhysTempBuffer(): buffer(0) {}
+ ~CPhysTempBuffer() { MidFree(buffer); }
+};
+
+static HRESULT CopyFileSpec(LPCWSTR fromPath, LPCWSTR toPath, bool writeToDisk, UInt64 fileSize,
+ UInt32 bufferSize, UInt64 progressStart, IProgress *progress)
+{
+ NFile::NIO::CInFile inFile;
+ if (!inFile.Open(fromPath))
+ return GetLastError();
+ if (fileSize == (UInt64)(Int64)-1)
+ {
+ if (!inFile.GetLength(fileSize))
+ ::GetLastError();
+ }
+ NFile::NIO::COutFile outFile;
+ if (writeToDisk)
+ {
+ if (!outFile.Open(toPath, FILE_SHARE_WRITE, OPEN_EXISTING, 0))
+ return GetLastError();
+ }
+ else
+ if (!outFile.Create(toPath, true))
+ return GetLastError();
+ CPhysTempBuffer tempBuffer;
+ tempBuffer.buffer = MidAlloc(bufferSize);
+ if (tempBuffer.buffer == 0)
+ return E_OUTOFMEMORY;
+
+ for (UInt64 pos = 0; pos < fileSize;)
+ {
+ UInt64 progressCur = progressStart + pos;
+ RINOK(progress->SetCompleted(&progressCur));
+ UInt64 rem = fileSize - pos;
+ UInt32 curSize = (UInt32)MyMin(rem, (UInt64)bufferSize);
+ UInt32 processedSize;
+ if (!inFile.Read(tempBuffer.buffer, curSize, processedSize))
+ return GetLastError();
+ if (processedSize == 0)
+ break;
+ curSize = processedSize;
+ if (writeToDisk)
+ {
+ const UInt32 kMask = 0x1FF;
+ curSize = (curSize + kMask) & ~kMask;
+ if (curSize > bufferSize)
+ return E_FAIL;
+ }
+
+ if (!outFile.Write(tempBuffer.buffer, curSize, processedSize))
+ return GetLastError();
+ if (curSize != processedSize)
+ return E_FAIL;
+ pos += curSize;
+ }
+ return S_OK;
+}
+
+static const STATPROPSTG kProps[] =
+{
+ { NULL, kpidName, VT_BSTR},
+ { NULL, kpidTotalSize, VT_UI8},
+ { NULL, kpidFreeSpace, VT_UI8},
+ { NULL, kpidType, VT_BSTR},
+ { NULL, kpidVolumeName, VT_BSTR},
+ { NULL, kpidFileSystem, VT_BSTR},
+ { NULL, kpidClusterSize, VT_UI8}
+};
+
+static const char *kDriveTypes[] =
+{
+ "Unknown",
+ "No Root Dir",
+ "Removable",
+ "Fixed",
+ "Remote",
+ "CD-ROM",
+ "RAM disk"
+};
+
+STDMETHODIMP CFSDrives::LoadItems()
+{
+ _drives.Clear();
+#ifdef _WIN32
+ UStringVector driveStrings;
+ MyGetLogicalDriveStrings(driveStrings);
+ for (int i = 0; i < driveStrings.Size(); i++)
+ {
+ CDriveInfo di;
+
+ const UString &driveName = driveStrings[i];
+
+ di.FullSystemName = driveName;
+
+ di.Name = di.FullSystemName.Left(di.FullSystemName.Length() - 1);
+ di.ClusterSize = 0;
+ di.DriveSize = 0;
+ di.FreeSpace = 0;
+ di.DriveType = NFile::NSystem::MyGetDriveType(driveName);
+ bool needRead = true;
+ if (di.DriveType == DRIVE_CDROM || di.DriveType == DRIVE_REMOVABLE)
+ {
+ /*
+ DWORD dwSerialNumber;`
+ if (!::GetVolumeInformation(di.FullSystemName,
+ NULL, 0, &dwSerialNumber, NULL, NULL, NULL, 0))
+ */
+ di.KnownSizes = false;
+ {
+ needRead = false;
+ }
+ }
+ if (needRead)
+ {
+ UString volumeName, fileSystemName;
+ DWORD volumeSerialNumber, maximumComponentLength, fileSystemFlags;
+ NFile::NSystem::MyGetVolumeInformation(driveName,
+ volumeName,
+ &volumeSerialNumber, &maximumComponentLength, &fileSystemFlags,
+ fileSystemName);
+ di.VolumeName = volumeName;
+ di.FileSystemName = fileSystemName;
+
+ NFile::NSystem::MyGetDiskFreeSpace(driveName,
+ di.ClusterSize, di.DriveSize, di.FreeSpace);
+ di.KnownSizes = true;
+ }
+ _drives.Add(di);
+ }
+#else
+ CDriveInfo di;
+ // Root
+ di.FullSystemName = L"/";
+ di.VolumeName = L"/";
+ di.FileSystemName = L"img";
+ di.Name = L"/"; // di.FullSystemName.Left(di.FullSystemName.Length() - 1);
+ di.ClusterSize = 0;
+ di.DriveSize = 0;
+ di.FreeSpace = 0;
+ di.DriveType = 0; // FIXME NFile::NSystem::MyGetDriveType(driveName);
+ di.KnownSizes = false;
+ _drives.Add(di);
+
+ // Home Directory
+ const char * home = getenv("HOME");
+ if (home) {
+ UString ustr = GetUnicodeString(home);
+ di.FullSystemName = ustr + L"/";
+ di.VolumeName = ustr;
+ di.FileSystemName = L"img";
+ di.Name = ustr;
+ _drives.Add(di);
+ }
+#endif
+ return S_OK;
+}
+
+STDMETHODIMP CFSDrives::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = _drives.Size();
+ return S_OK;
+}
+
+STDMETHODIMP CFSDrives::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT *value)
+{
+ if (itemIndex >= (UInt32)_drives.Size())
+ return E_INVALIDARG;
+ NCOM::CPropVariant prop;
+ const CDriveInfo &di = _drives[itemIndex];
+ switch(propID)
+ {
+ case kpidIsDir: prop = !_volumeMode; break;
+ case kpidName: prop = di.Name; break;
+ case kpidTotalSize: if (di.KnownSizes) prop = di.DriveSize; break;
+ case kpidFreeSpace: if (di.KnownSizes) prop = di.FreeSpace; break;
+ case kpidClusterSize: if (di.KnownSizes) prop = di.ClusterSize; break;
+ case kpidType:
+ if (di.DriveType < sizeof(kDriveTypes) / sizeof(kDriveTypes[0]))
+ prop = kDriveTypes[di.DriveType];
+ break;
+ case kpidVolumeName: prop = di.VolumeName; break;
+ case kpidFileSystem: prop = di.FileSystemName; break;
+ }
+ prop.Detach(value);
+ return S_OK;
+}
+
+HRESULT CFSDrives::BindToFolderSpec(const wchar_t *name, IFolderFolder **resultFolder)
+{
+ *resultFolder = 0;
+ if (_volumeMode)
+ return S_OK;
+ NFsFolder::CFSFolder *fsFolderSpec = new NFsFolder::CFSFolder;
+ CMyComPtr<IFolderFolder> subFolder = fsFolderSpec;
+ RINOK(fsFolderSpec->Init(name, 0));
+ *resultFolder = subFolder.Detach();
+ return S_OK;
+}
+
+STDMETHODIMP CFSDrives::BindToFolder(UInt32 index, IFolderFolder **resultFolder)
+{
+ *resultFolder = 0;
+ if (index >= (UInt32)_drives.Size())
+ return E_INVALIDARG;
+ const CDriveInfo &di = _drives[index];
+ /*
+ if (_volumeMode)
+ {
+ *resultFolder = 0;
+ CPhysDriveFolder *folderSpec = new CPhysDriveFolder;
+ CMyComPtr<IFolderFolder> subFolder = folderSpec;
+ RINOK(folderSpec->Init(di.Name));
+ *resultFolder = subFolder.Detach();
+ return S_OK;
+ }
+ */
+ return BindToFolderSpec(di.FullSystemName, resultFolder);
+}
+
+STDMETHODIMP CFSDrives::BindToFolder(const wchar_t *name, IFolderFolder **resultFolder)
+{
+ return BindToFolderSpec(name, resultFolder);
+}
+
+STDMETHODIMP CFSDrives::BindToParentFolder(IFolderFolder **resultFolder)
+{
+ *resultFolder = 0;
+ return S_OK;
+}
+
+IMP_IFolderFolder_Props(CFSDrives)
+
+STDMETHODIMP CFSDrives::GetFolderProperty(PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidType: prop = L"FSDrives"; break;
+ case kpidPath:
+ if (_volumeMode)
+ prop = kVolPrefix;
+ else
+ prop = LangString(IDS_COMPUTER, 0x03020300) + UString(WCHAR_PATH_SEPARATOR);
+ break;
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+
+STDMETHODIMP CFSDrives::GetSystemIconIndex(UInt32 index, Int32 *iconIndex)
+{
+ *iconIndex = 0;
+ const CDriveInfo &di = _drives[index];
+ int iconIndexTemp;
+ if (GetRealIconIndex(di.FullSystemName, 0, iconIndexTemp) != 0)
+ {
+ *iconIndex = iconIndexTemp;
+ return S_OK;
+ }
+ return GetLastError();
+}
+
+UString CFSDrives::GetExt(int index) const
+{
+ const wchar_t *ext = NULL;
+#ifdef _WIN32
+ const CDriveInfo &di = _drives[index];
+ if (di.DriveType == DRIVE_CDROM)
+ ext = L"iso";
+ else if (di.FileSystemName.Find(L"NTFS") >= 0)
+ ext = L"ntfs";
+ else if (di.FileSystemName.Find(L"FAT") >= 0)
+ ext = L"fat";
+ else
+#endif
+ ext = L"img";
+ return (UString)L'.' + ext;
+}
+
+HRESULT CFSDrives::GetLength(int index, UInt64 &length) const
+{
+#ifdef _WIN32
+ NFile::NIO::CInFile inFile;
+ if (!inFile.Open(_drives[index].GetDeviceFileIoName()))
+ return GetLastError();
+ if (!inFile.LengthDefined)
+ return E_FAIL;
+ length = inFile.Length;
+#else
+ length = 0;
+#endif
+ return S_OK;
+}
+
+STDMETHODIMP CFSDrives::CopyTo(const UInt32 *indices, UInt32 numItems,
+ const wchar_t *path, IFolderOperationsExtractCallback *callback)
+{
+ if (numItems == 0)
+ return S_OK;
+
+ if (!_volumeMode)
+ return E_NOTIMPL;
+
+ UInt64 totalSize = 0;
+ UInt32 i;
+ for (i = 0; i < numItems; i++)
+ {
+ const CDriveInfo &di = _drives[indices[i]];
+ if (di.KnownSizes)
+ totalSize += di.DriveSize;
+ }
+ RINOK(callback->SetTotal(totalSize));
+ RINOK(callback->SetNumFiles(numItems));
+
+ UString destPath = path;
+ if (destPath.IsEmpty())
+ return E_INVALIDARG;
+ bool directName = (destPath[destPath.Length() - 1] != WCHAR_PATH_SEPARATOR);
+ if (directName)
+ {
+ if (numItems > 1)
+ return E_INVALIDARG;
+ }
+
+ UInt64 completedSize = 0;
+ RINOK(callback->SetCompleted(&completedSize));
+ for (i = 0; i < numItems; i++)
+ {
+ int index = indices[i];
+ const CDriveInfo &di = _drives[index];
+ UString destPath2 = destPath;
+ UString name = di.Name;
+ if (!directName)
+ {
+ UString destName = name;
+ if (!destName.IsEmpty() && destName[destName.Length() - 1] == L':')
+ {
+ destName.Delete(destName.Length() - 1);
+ destName += GetExt(index);
+ }
+ destPath2 += destName;
+ }
+ UString srcPath = di.GetDeviceFileIoName();
+
+ UInt64 fileSize = 0;
+ if (GetLength(index, fileSize) != S_OK)
+ {
+ return E_FAIL;
+ }
+ if (!di.KnownSizes)
+ totalSize += fileSize;
+ RINOK(callback->SetTotal(totalSize));
+
+ Int32 writeAskResult;
+ CMyComBSTR destPathResult;
+ RINOK(callback->AskWrite(srcPath, BoolToInt(false), NULL, &fileSize,
+ destPath2, &destPathResult, &writeAskResult));
+ if (!IntToBool(writeAskResult))
+ continue;
+
+ RINOK(callback->SetCurrentFilePath(srcPath));
+
+ static const UInt32 kBufferSize = (4 << 20);
+#ifdef _WIN32
+ UInt32 bufferSize = (di.DriveType == DRIVE_REMOVABLE) ? (18 << 10) * 4 : kBufferSize;
+#else
+ UInt32 bufferSize = kBufferSize;
+#endif
+
+ RINOK(CopyFileSpec(srcPath, destPathResult, false, fileSize, bufferSize, completedSize, callback));
+ completedSize += fileSize;
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CFSDrives::MoveTo(
+ const UInt32 * /* indices */,
+ UInt32 /* numItems */,
+ const wchar_t * /* path */,
+ IFolderOperationsExtractCallback * /* callback */)
+{
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP CFSDrives::CopyFrom(const wchar_t * /* fromFolderPath */,
+ const wchar_t ** /* itemsPaths */, UInt32 /* numItems */, IProgress * /* progress */)
+{
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP CFSDrives::CreateFolder(const wchar_t * /* name */, IProgress * /* progress */)
+{
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP CFSDrives::CreateFile(const wchar_t * /* name */, IProgress * /* progress */)
+{
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP CFSDrives::Rename(UInt32 /* index */, const wchar_t * /* newName */, IProgress * /* progress */)
+{
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP CFSDrives::Delete(const UInt32 * /* indices */, UInt32 /* numItems */, IProgress * /* progress */)
+{
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP CFSDrives::SetProperty(UInt32 /* index */, PROPID /* propID */,
+ const PROPVARIANT * /* value */, IProgress * /* progress */)
+{
+ return E_NOTIMPL;
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/FSDrives.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/FSDrives.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/FSDrives.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/FSDrives.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,53 @@
+// FSDrives.h
+
+#ifndef __FS_DRIVES_H
+#define __FS_DRIVES_H
+
+#include "Common/MyCom.h"
+#include "Common/MyString.h"
+
+#include "IFolder.h"
+
+struct CDriveInfo
+{
+ UString Name;
+ UString FullSystemName;
+ bool KnownSizes;
+ UInt64 DriveSize;
+ UInt64 FreeSpace;
+ UInt64 ClusterSize;
+ // UString Type;
+ UString VolumeName;
+ UString FileSystemName;
+ UINT DriveType;
+
+ UString GetDeviceFileIoName() const;
+};
+
+class CFSDrives:
+ public IFolderFolder,
+ public IFolderOperations,
+ public IFolderGetSystemIconIndex,
+ public CMyUnknownImp
+{
+ CObjectVector<CDriveInfo> _drives;
+ bool _volumeMode;
+
+ HRESULT BindToFolderSpec(const wchar_t *name, IFolderFolder **resultFolder);
+ UString GetExt(int index) const;
+ HRESULT GetLength(int index, UInt64 &length) const;
+public:
+ MY_UNKNOWN_IMP2(IFolderGetSystemIconIndex, IFolderOperations)
+
+ INTERFACE_FolderFolder(;)
+ INTERFACE_FolderOperations(;)
+
+ STDMETHOD(GetSystemIconIndex)(UInt32 index, Int32 *iconIndex);
+
+ void Init(bool volMode = false)
+ {
+ _volumeMode = volMode;
+ }
+};
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/FSFolder.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/FSFolder.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/FSFolder.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/FSFolder.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,685 @@
+// FSFolder.cpp
+
+#include "StdAfx.h"
+
+#include "Common/ComTry.h"
+#include "Common/StringConvert.h"
+#include "Common/UTFConvert.h"
+
+#include "Windows/FileDir.h"
+#include "Windows/FileIO.h"
+#include "Windows/PropVariant.h"
+
+#include "../../PropID.h"
+
+#include "FSDrives.h"
+#include "FSFolder.h"
+
+#ifdef _WIN32
+#include "NetFolder.h"
+#endif
+
+#include "SysIconUtils.h"
+
+namespace NWindows {
+namespace NFile {
+
+bool GetLongPath(LPCWSTR path, UString &longPath);
+
+}}
+
+using namespace NWindows;
+using namespace NFile;
+using namespace NFind;
+
+namespace NFsFolder {
+
+static STATPROPSTG kProps[] =
+{
+ { NULL, kpidName, VT_BSTR},
+ { NULL, kpidSize, VT_UI8},
+ { NULL, kpidMTime, VT_FILETIME},
+ { NULL, kpidCTime, VT_FILETIME},
+ { NULL, kpidATime, VT_FILETIME},
+ { NULL, kpidAttrib, VT_UI4},
+ { NULL, kpidPackSize, VT_UI8},
+ { NULL, kpidComment, VT_BSTR},
+ { NULL, kpidPrefix, VT_BSTR}
+};
+
+HRESULT CFSFolder::Init(const UString &path, IFolderFolder *parentFolder)
+{
+ _parentFolder = parentFolder;
+ _path = path;
+
+#ifdef _WIN32
+ _findChangeNotification.FindFirst(_path, false,
+ FILE_NOTIFY_CHANGE_FILE_NAME |
+ FILE_NOTIFY_CHANGE_DIR_NAME |
+ FILE_NOTIFY_CHANGE_ATTRIBUTES |
+ FILE_NOTIFY_CHANGE_SIZE |
+ FILE_NOTIFY_CHANGE_LAST_WRITE /*|
+ FILE_NOTIFY_CHANGE_LAST_ACCESS |
+ FILE_NOTIFY_CHANGE_CREATION |
+ FILE_NOTIFY_CHANGE_SECURITY */);
+ if (!_findChangeNotification.IsHandleAllocated())
+ {
+ DWORD lastError = GetLastError();
+ CFindFile findFile;
+ CFileInfoW fi;
+ if (!findFile.FindFirst(_path + UString(L"*"), fi))
+ return lastError;
+ }
+#endif
+ return S_OK;
+}
+
+HRESULT GetFolderSize(const UString &path, UInt64 &numFolders, UInt64 &numFiles, UInt64 &size, IProgress *progress)
+{
+ RINOK(progress->SetCompleted(NULL));
+ numFiles = numFolders = size = 0;
+ CEnumeratorW enumerator(path + UString(WSTRING_PATH_SEPARATOR L"*"));
+ CFileInfoW fi;
+ while (enumerator.Next(fi))
+ {
+ if (fi.IsDir())
+ {
+ UInt64 subFolders, subFiles, subSize;
+ RINOK(GetFolderSize(path + UString(WSTRING_PATH_SEPARATOR) + fi.Name, subFolders, subFiles, subSize, progress));
+ numFolders += subFolders;
+ numFolders++;
+ numFiles += subFiles;
+ size += subSize;
+ }
+ else
+ {
+ numFiles++;
+ size += fi.Size;
+ }
+ }
+ return S_OK;
+}
+
+HRESULT CFSFolder::LoadSubItems(CDirItem &dirItem, const UString &path)
+{
+ {
+ CEnumeratorW enumerator(path + L"*");
+ CDirItem fi;
+ while (enumerator.Next(fi))
+ {
+ fi.CompressedSizeIsDefined = false;
+ /*
+ if (!GetCompressedFileSize(_path + fi.Name,
+ fi.CompressedSize))
+ fi.CompressedSize = fi.Size;
+ */
+ if (fi.IsDir())
+ {
+ // fi.Size = GetFolderSize(_path + fi.Name);
+ fi.Size = 0;
+ }
+ dirItem.Files.Add(fi);
+ }
+ }
+ if (!_flatMode)
+ return S_OK;
+
+ for (int i = 0; i < dirItem.Files.Size(); i++)
+ {
+ CDirItem &item = dirItem.Files[i];
+ if (item.IsDir())
+ LoadSubItems(item, path + item.Name + WCHAR_PATH_SEPARATOR);
+ }
+ return S_OK;
+}
+
+void CFSFolder::AddRefs(CDirItem &dirItem)
+{
+ int i;
+ for (i = 0; i < dirItem.Files.Size(); i++)
+ {
+ CDirItem &item = dirItem.Files[i];
+ item.Parent = &dirItem;
+ _refs.Add(&item);
+ }
+ if (!_flatMode)
+ return;
+ for (i = 0; i < dirItem.Files.Size(); i++)
+ {
+ CDirItem &item = dirItem.Files[i];
+ if (item.IsDir())
+ AddRefs(item);
+ }
+}
+
+STDMETHODIMP CFSFolder::LoadItems()
+{
+ // OutputDebugString(TEXT("Start\n"));
+ Int32 dummy;
+ WasChanged(&dummy);
+ Clear();
+ RINOK(LoadSubItems(_root, _path));
+ AddRefs(_root);
+
+ // OutputDebugString(TEXT("Finish\n"));
+ _commentsAreLoaded = false;
+ return S_OK;
+}
+
+static const wchar_t *kDescriptionFileName = L"descript.ion";
+
+bool CFSFolder::LoadComments()
+{
+ if (_commentsAreLoaded)
+ return true;
+ _comments.Clear();
+ _commentsAreLoaded = true;
+ NIO::CInFile file;
+ if (!file.Open(_path + kDescriptionFileName))
+ return false;
+ UInt64 length;
+ if (!file.GetLength(length))
+ return false;
+ if (length >= (1 << 28))
+ return false;
+ AString s;
+ char *p = s.GetBuffer((int)((size_t)length + 1));
+ UInt32 processedSize;
+ file.Read(p, (UInt32)length, processedSize);
+ p[length] = 0;
+ s.ReleaseBuffer();
+ if (processedSize != length)
+ return false;
+ file.Close();
+ UString unicodeString;
+ if (!ConvertUTF8ToUnicode(s, unicodeString))
+ return false;
+ return _comments.ReadFromString(unicodeString);
+}
+
+static bool IsAscii(const UString &testString)
+{
+ for (int i = 0; i < testString.Length(); i++)
+ if (testString[i] >= 0x80)
+ return false;
+ return true;
+}
+
+bool CFSFolder::SaveComments()
+{
+ NIO::COutFile file;
+ if (!file.Create(_path + kDescriptionFileName, true))
+ return false;
+ UString unicodeString;
+ _comments.SaveToString(unicodeString);
+ AString utfString;
+ ConvertUnicodeToUTF8(unicodeString, utfString);
+ UInt32 processedSize;
+ if (!IsAscii(unicodeString))
+ {
+ Byte bom [] = { 0xEF, 0xBB, 0xBF, 0x0D, 0x0A };
+ file.Write(bom , sizeof(bom), processedSize);
+ }
+ file.Write(utfString, utfString.Length(), processedSize);
+ _commentsAreLoaded = false;
+ return true;
+}
+
+STDMETHODIMP CFSFolder::GetNumberOfItems(UInt32 *numItems)
+{
+ *numItems = _refs.Size();
+ return S_OK;
+}
+
+/*
+STDMETHODIMP CFSFolder::GetNumberOfSubFolders(UInt32 *numSubFolders)
+{
+ UInt32 numSubFoldersLoc = 0;
+ for (int i = 0; i < _files.Size(); i++)
+ if (_files[i].IsDir())
+ numSubFoldersLoc++;
+ *numSubFolders = numSubFoldersLoc;
+ return S_OK;
+}
+*/
+
+#ifdef _WIN32
+static bool MyGetCompressedFileSizeW(LPCWSTR fileName, UInt64 &size)
+{
+ DWORD highPart;
+ DWORD lowPart = ::GetCompressedFileSizeW(fileName, &highPart);
+ if (lowPart == INVALID_FILE_SIZE && ::GetLastError() != NO_ERROR)
+ {
+ #ifdef WIN_LONG_PATH
+ {
+ UString longPath;
+ if (GetLongPath(fileName, longPath))
+ lowPart = ::GetCompressedFileSizeW(longPath, &highPart);
+ }
+ #endif
+ if (lowPart == INVALID_FILE_SIZE && ::GetLastError() != NO_ERROR)
+ return false;
+ }
+ size = (UInt64(highPart) << 32) | lowPart;
+ return true;
+}
+#endif
+
+STDMETHODIMP CFSFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT *value)
+{
+ NCOM::CPropVariant prop;
+ if (itemIndex >= (UInt32)_refs.Size())
+ return E_INVALIDARG;
+ CDirItem &fi = *_refs[itemIndex];
+ switch(propID)
+ {
+ case kpidIsDir: prop = fi.IsDir(); break;
+ case kpidName: prop = fi.Name; break;
+ case kpidSize: if (!fi.IsDir()) prop = fi.Size; break;
+ case kpidPackSize:
+ if (!fi.CompressedSizeIsDefined)
+ {
+ fi.CompressedSizeIsDefined = true;
+#ifdef _WIN32
+ if (fi.IsDir () ||
+ !MyGetCompressedFileSizeW(_path + GetRelPath(fi), fi.CompressedSize))
+#endif
+ fi.CompressedSize = fi.Size;
+ }
+ prop = fi.CompressedSize;
+ break;
+ case kpidAttrib: prop = (UInt32)fi.Attrib; break;
+ case kpidCTime: prop = fi.CTime; break;
+ case kpidATime: prop = fi.ATime; break;
+ case kpidMTime: prop = fi.MTime; break;
+ case kpidComment:
+ {
+ LoadComments();
+ UString comment;
+ if (_comments.GetValue(GetRelPath(fi), comment))
+ prop = comment;
+ break;
+ }
+ case kpidPrefix:
+ {
+ if (_flatMode)
+ prop = GetPrefix(fi);
+ break;
+ }
+ }
+ prop.Detach(value);
+ return S_OK;
+}
+
+HRESULT CFSFolder::BindToFolderSpec(const wchar_t *name, IFolderFolder **resultFolder)
+{
+ *resultFolder = 0;
+ CFSFolder *folderSpec = new CFSFolder;
+ CMyComPtr<IFolderFolder> subFolder = folderSpec;
+ RINOK(folderSpec->Init(_path + name + UString(WCHAR_PATH_SEPARATOR), 0));
+ *resultFolder = subFolder.Detach();
+ return S_OK;
+}
+
+UString CFSFolder::GetPrefix(const CDirItem &item) const
+{
+ UString path;
+ CDirItem *cur = item.Parent;
+ while (cur->Parent != 0)
+ {
+ path = cur->Name + UString(WCHAR_PATH_SEPARATOR) + path;
+ cur = cur->Parent;
+ }
+ return path;
+}
+
+UString CFSFolder::GetRelPath(const CDirItem &item) const
+{
+ return GetPrefix(item) + item.Name;
+}
+
+STDMETHODIMP CFSFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder)
+{
+ *resultFolder = 0;
+ const CDirItem &fi = *_refs[index];
+ if (!fi.IsDir())
+ return E_INVALIDARG;
+ return BindToFolderSpec(GetRelPath(fi), resultFolder);
+}
+
+STDMETHODIMP CFSFolder::BindToFolder(const wchar_t *name, IFolderFolder **resultFolder)
+{
+ return BindToFolderSpec(name, resultFolder);
+}
+
+STDMETHODIMP CFSFolder::BindToParentFolder(IFolderFolder **resultFolder)
+{
+ *resultFolder = 0;
+ if (_parentFolder)
+ {
+ CMyComPtr<IFolderFolder> parentFolder = _parentFolder;
+ *resultFolder = parentFolder.Detach();
+ return S_OK;
+ }
+ if (_path.IsEmpty())
+ return E_INVALIDARG;
+ printf("CFSFolder::BindToParentFolder path='%ls'\n",(const wchar_t *)_path);
+ int pos = _path.ReverseFind(WCHAR_PATH_SEPARATOR);
+ if (pos < 0 || pos != _path.Length() - 1)
+ return E_FAIL;
+ UString parentPath = _path.Left(pos);
+ printf("CFSFolder::BindToParentFolder parentPath='%ls'\n",(const wchar_t *)parentPath);
+ pos = parentPath.ReverseFind(WCHAR_PATH_SEPARATOR);
+ if (pos < 0)
+ {
+#ifdef _WIN32
+ parentPath.Empty();
+ CFSDrives *drivesFolderSpec = new CFSDrives;
+ CMyComPtr<IFolderFolder> drivesFolder = drivesFolderSpec;
+ drivesFolderSpec->Init();
+ *resultFolder = drivesFolder.Detach();
+#else
+ parentPath = WSTRING_PATH_SEPARATOR;
+ CFSFolder *parentFolderSpec = new CFSFolder;
+ CMyComPtr<IFolderFolder> parentFolder = parentFolderSpec;
+ printf("CFSFolder::BindToParentFolder Init-0 with parentPath='%ls'\n",(const wchar_t *)parentPath);
+ RINOK(parentFolderSpec->Init(parentPath, 0));
+ *resultFolder = parentFolder.Detach();
+#endif
+ return S_OK;
+ }
+ UString parentPathReduced = parentPath.Left(pos);
+ parentPath = parentPath.Left(pos + 1);
+ pos = parentPathReduced.ReverseFind(WCHAR_PATH_SEPARATOR);
+ if (pos == 1)
+ {
+#ifdef _WIN32
+ if (parentPath[0] != WCHAR_PATH_SEPARATOR)
+ return E_FAIL;
+ CNetFolder *netFolderSpec = new CNetFolder;
+ CMyComPtr<IFolderFolder> netFolder = netFolderSpec;
+ netFolderSpec->Init(parentPath);
+ *resultFolder = netFolder.Detach();
+#else
+ parentPath = WSTRING_PATH_SEPARATOR;
+ CFSFolder *parentFolderSpec = new CFSFolder;
+ CMyComPtr<IFolderFolder> parentFolder = parentFolderSpec;
+ printf("CFSFolder::BindToParentFolder Init-1 with parentPath='%ls'\n",(const wchar_t *)parentPath);
+ RINOK(parentFolderSpec->Init(parentPath, 0));
+ *resultFolder = parentFolder.Detach();
+#endif // ifdef _WIN32
+ return S_OK;
+ }
+ CFSFolder *parentFolderSpec = new CFSFolder;
+ CMyComPtr<IFolderFolder> parentFolder = parentFolderSpec;
+ printf("CFSFolder::BindToParentFolder Init-2 with parentPath='%ls'\n",(const wchar_t *)parentPath);
+ RINOK(parentFolderSpec->Init(parentPath, 0));
+ *resultFolder = parentFolder.Detach();
+ return S_OK;
+}
+
+STDMETHODIMP CFSFolder::GetNumberOfProperties(UInt32 *numProperties)
+{
+ *numProperties = sizeof(kProps) / sizeof(kProps[0]);
+ if (!_flatMode)
+ (*numProperties)--;
+ return S_OK;
+}
+
+STDMETHODIMP CFSFolder::GetPropertyInfo IMP_IFolderFolder_GetProp(kProps)
+
+STDMETHODIMP CFSFolder::GetFolderProperty(PROPID propID, PROPVARIANT *value)
+{
+ COM_TRY_BEGIN
+ NWindows::NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidType: prop = L"FSFolder"; break;
+ case kpidPath: prop = _path; break;
+ }
+ prop.Detach(value);
+ return S_OK;
+ COM_TRY_END
+}
+
+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;
+ }
+#endif
+ *wasChanged = BoolToInt(wasChangedMain);
+ return S_OK;
+}
+
+STDMETHODIMP CFSFolder::Clone(IFolderFolder **resultFolder)
+{
+ CFSFolder *fsFolderSpec = new CFSFolder;
+ CMyComPtr<IFolderFolder> folderNew = fsFolderSpec;
+ fsFolderSpec->Init(_path, 0);
+ *resultFolder = folderNew.Detach();
+ return S_OK;
+}
+
+HRESULT CFSFolder::GetItemsFullSize(const UInt32 *indices, UInt32 numItems,
+ UInt64 &numFolders, UInt64 &numFiles, UInt64 &size, IProgress *progress)
+{
+ numFiles = numFolders = size = 0;
+ UInt32 i;
+ for (i = 0; i < numItems; i++)
+ {
+ int index = indices[i];
+ if (index >= _refs.Size())
+ return E_INVALIDARG;
+ const CDirItem &fi = *_refs[index];
+ if (fi.IsDir())
+ {
+ UInt64 subFolders, subFiles, subSize;
+ RINOK(GetFolderSize(_path + GetRelPath(fi), subFolders, subFiles, subSize, progress));
+ numFolders += subFolders;
+ numFolders++;
+ numFiles += subFiles;
+ size += subSize;
+ }
+ else
+ {
+ numFiles++;
+ size += fi.Size;
+ }
+ }
+ return S_OK;
+}
+
+HRESULT CFSFolder::GetItemFullSize(int index, UInt64 &size, IProgress *progress)
+{
+ const CDirItem &fi = *_refs[index];
+ if (fi.IsDir())
+ {
+ /*
+ CMyComPtr<IFolderFolder> subFolder;
+ RINOK(BindToFolder(index, &subFolder));
+ CMyComPtr<IFolderReload> aFolderReload;
+ subFolder.QueryInterface(&aFolderReload);
+ aFolderReload->Reload();
+ UInt32 numItems;
+ RINOK(subFolder->GetNumberOfItems(&numItems));
+ CMyComPtr<IFolderGetItemFullSize> aGetItemFullSize;
+ subFolder.QueryInterface(&aGetItemFullSize);
+ for (UInt32 i = 0; i < numItems; i++)
+ {
+ UInt64 size;
+ RINOK(aGetItemFullSize->GetItemFullSize(i, &size));
+ *totalSize += size;
+ }
+ */
+ UInt64 numFolders, numFiles;
+ return GetFolderSize(_path + GetRelPath(fi), numFolders, numFiles, size, progress);
+ }
+ size = fi.Size;
+ return S_OK;
+}
+
+STDMETHODIMP CFSFolder::GetItemFullSize(UInt32 index, PROPVARIANT *value, IProgress *progress)
+{
+ NCOM::CPropVariant prop;
+ if (index >= (UInt32)_refs.Size())
+ return E_INVALIDARG;
+ UInt64 size = 0;
+ HRESULT result = GetItemFullSize(index, size, progress);
+ prop = size;
+ prop.Detach(value);
+ return result;
+}
+
+HRESULT CFSFolder::GetComplexName(const wchar_t *name, UString &resultPath)
+{
+ UString newName = name;
+ resultPath = _path + newName;
+ if (newName.Length() < 1)
+ return S_OK;
+ if (newName[0] == WCHAR_PATH_SEPARATOR)
+ {
+ resultPath = newName;
+ return S_OK;
+ }
+ if (newName.Length() < 2)
+ return S_OK;
+ if (newName[1] == L':')
+ resultPath = newName;
+ return S_OK;
+}
+
+STDMETHODIMP CFSFolder::CreateFolder(const wchar_t *name, IProgress * /* progress */)
+{
+ UString processedName;
+ RINOK(GetComplexName(name, processedName));
+ if(NDirectory::MyCreateDirectory(processedName))
+ return S_OK;
+ if(::GetLastError() == ERROR_ALREADY_EXISTS)
+ return ::GetLastError();
+ if (!NDirectory::CreateComplexDirectory(processedName))
+ return ::GetLastError();
+ return S_OK;
+}
+
+STDMETHODIMP CFSFolder::CreateFile(const wchar_t *name, IProgress * /* progress */)
+{
+ UString processedName;
+ RINOK(GetComplexName(name, processedName));
+ NIO::COutFile outFile;
+ if (!outFile.Create(processedName, false))
+ return ::GetLastError();
+ return S_OK;
+}
+
+STDMETHODIMP CFSFolder::Rename(UInt32 index, const wchar_t *newName, IProgress * /* progress */)
+{
+ const CDirItem &fi = *_refs[index];
+ const UString fullPrefix = _path + GetPrefix(fi);
+ if (!NDirectory::MyMoveFile(fullPrefix + fi.Name, fullPrefix + newName))
+ return GetLastError();
+ return S_OK;
+}
+
+STDMETHODIMP CFSFolder::Delete(const UInt32 *indices, UInt32 numItems,IProgress *progress)
+{
+ RINOK(progress->SetTotal(numItems));
+ for (UInt32 i = 0; i < numItems; i++)
+ {
+ const CDirItem &fi = *_refs[indices[i]];
+ const UString fullPath = _path + GetRelPath(fi);
+ bool result;
+ if (fi.IsDir())
+ result = NDirectory::RemoveDirectoryWithSubItems(fullPath);
+ else
+ result = NDirectory::DeleteFileAlways(fullPath);
+ if (!result)
+ return GetLastError();
+ UInt64 completed = i;
+ RINOK(progress->SetCompleted(&completed));
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CFSFolder::SetProperty(UInt32 index, PROPID propID,
+ const PROPVARIANT *value, IProgress * /* progress */)
+{
+ if (index >= (UInt32)_refs.Size())
+ return E_INVALIDARG;
+ CDirItem &fi = *_refs[index];
+ if (fi.Parent->Parent != 0)
+ return E_NOTIMPL;
+ switch(propID)
+ {
+ case kpidComment:
+ {
+ UString filename = fi.Name;
+ filename.Trim();
+ if (value->vt == VT_EMPTY)
+ _comments.DeletePair(filename);
+ else if (value->vt == VT_BSTR)
+ {
+ CTextPair pair;
+ pair.ID = filename;
+ pair.ID.Trim();
+ pair.Value = value->bstrVal;
+ pair.Value.Trim();
+ if (pair.Value.IsEmpty())
+ _comments.DeletePair(filename);
+ else
+ _comments.AddPair(pair);
+ }
+ else
+ return E_INVALIDARG;
+ SaveComments();
+ break;
+ }
+ default:
+ return E_NOTIMPL;
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CFSFolder::GetSystemIconIndex(UInt32 index, Int32 *iconIndex)
+{
+#ifdef _WIN32
+ if (index >= (UInt32)_refs.Size())
+ return E_INVALIDARG;
+ const CDirItem &fi = *_refs[index];
+ *iconIndex = 0;
+ int iconIndexTemp;
+ if (GetRealIconIndex(_path + GetRelPath(fi), fi.Attributes, iconIndexTemp) != 0)
+ {
+ *iconIndex = iconIndexTemp;
+ return S_OK;
+ }
+ return GetLastError();
+#endif
+ *iconIndex = 0;
+ return S_OK;
+}
+
+STDMETHODIMP CFSFolder::SetFlatMode(Int32 flatMode)
+{
+ _flatMode = IntToBool(flatMode);
+ return S_OK;
+}
+
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/FSFolder.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/FSFolder.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/FSFolder.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/FSFolder.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,123 @@
+// FSFolder.h
+
+#ifndef __FSFOLDER_H
+#define __FSFOLDER_H
+
+#include "Common/MyCom.h"
+
+#include "Windows/FileFind.h"
+
+#include "IFolder.h"
+#include "TextPairs.h"
+
+namespace NFsFolder {
+
+class CFSFolder;
+
+struct CFileInfoEx: public NWindows::NFile::NFind::CFileInfoW
+{
+ #ifndef UNDER_CE
+ bool CompressedSizeIsDefined;
+ UInt64 CompressedSize;
+ #endif
+};
+
+struct CDirItem;
+
+struct CDirItem: public CFileInfoEx
+{
+ CDirItem *Parent;
+ CObjectVector<CDirItem> Files;
+
+ CDirItem(): Parent(0) {}
+ void Clear()
+ {
+ Files.Clear();
+ Parent = 0;
+ }
+};
+
+class CFSFolder:
+ public IFolderFolder,
+ public IFolderWasChanged,
+ public IFolderOperations,
+ // public IFolderOperationsDeleteToRecycleBin,
+ public IFolderGetItemFullSize,
+ public IFolderClone,
+ public IFolderGetSystemIconIndex,
+ public IFolderSetFlatMode,
+ public CMyUnknownImp
+{
+ UInt64 GetSizeOfItem(int anIndex) const;
+public:
+ MY_QUERYINTERFACE_BEGIN2(IFolderFolder)
+ MY_QUERYINTERFACE_ENTRY(IFolderWasChanged)
+ // MY_QUERYINTERFACE_ENTRY(IFolderOperationsDeleteToRecycleBin)
+ MY_QUERYINTERFACE_ENTRY(IFolderOperations)
+ MY_QUERYINTERFACE_ENTRY(IFolderGetItemFullSize)
+ MY_QUERYINTERFACE_ENTRY(IFolderClone)
+ MY_QUERYINTERFACE_ENTRY(IFolderGetSystemIconIndex)
+ MY_QUERYINTERFACE_ENTRY(IFolderSetFlatMode)
+ MY_QUERYINTERFACE_END
+ MY_ADDREF_RELEASE
+
+
+ INTERFACE_FolderFolder(;)
+ INTERFACE_FolderOperations(;)
+
+ STDMETHOD(WasChanged)(Int32 *wasChanged);
+ STDMETHOD(Clone)(IFolderFolder **resultFolder);
+ STDMETHOD(GetItemFullSize)(UInt32 index, PROPVARIANT *value, IProgress *progress);
+
+ STDMETHOD(SetFlatMode)(Int32 flatMode);
+
+ STDMETHOD(GetSystemIconIndex)(UInt32 index, Int32 *iconIndex);
+
+private:
+ UString _path;
+ CDirItem _root;
+ CRecordVector<CDirItem *> _refs;
+
+ CMyComPtr<IFolderFolder> _parentFolder;
+
+ bool _commentsAreLoaded;
+ CPairsStorage _comments;
+
+ bool _flatMode;
+
+ // FIXME NWindows::NFile::NFind::CFindChangeNotification _findChangeNotification;
+
+ HRESULT GetItemsFullSize(const UInt32 *indices, UInt32 numItems,
+ UInt64 &numFolders, UInt64 &numFiles, UInt64 &size, IProgress *progress);
+ HRESULT GetItemFullSize(int index, UInt64 &size, IProgress *progress);
+ HRESULT GetComplexName(const wchar_t *name, UString &resultPath);
+ HRESULT BindToFolderSpec(const wchar_t *name, IFolderFolder **resultFolder);
+
+ bool LoadComments();
+ bool SaveComments();
+ HRESULT LoadSubItems(CDirItem &dirItem, const UString &path);
+ void AddRefs(CDirItem &dirItem);
+public:
+ HRESULT Init(const UString &path, IFolderFolder *parentFolder);
+ #ifdef UNDER_CE
+ HRESULT InitToRoot() { return Init(L"\\", NULL); }
+ #endif
+
+ CFSFolder() : _flatMode(false) {}
+
+ UString GetPrefix(const CDirItem &item) const;
+ UString GetRelPath(const CDirItem &item) const;
+ UString GetRelPath(UInt32 index) const { return GetRelPath(*_refs[index]); }
+
+ void Clear()
+ {
+ _root.Clear();
+ _refs.Clear();
+ }
+};
+
+HRESULT GetFolderSize(const UString &path, UInt64 &numFolders, UInt64 &numFiles, UInt64 &size, IProgress *progress);
+
+}
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/FSFolderCopy.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/FSFolderCopy.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/FSFolderCopy.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/FSFolderCopy.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,523 @@
+// FSFolderCopy.cpp
+
+#include "StdAfx.h"
+
+// FIXME #include <Winbase.h>
+
+#include "FSFolder.h"
+#include "Windows/FileDir.h"
+#include "Windows/Error.h"
+
+#include "Common/StringConvert.h"
+
+#include "../../Common/FilePathAutoRename.h"
+
+using namespace NWindows;
+using namespace NFile;
+using namespace NFind;
+
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
+
+namespace NFsFolder {
+
+/*
+static bool IsItWindows2000orHigher()
+{
+ OSVERSIONINFO versionInfo;
+ versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
+ if (!::GetVersionEx(&versionInfo))
+ return false;
+ return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) &&
+ (versionInfo.dwMajorVersion >= 5);
+}
+*/
+
+struct CProgressInfo
+{
+ UInt64 StartPos;
+ IProgress *Progress;
+};
+
+#ifdef _WIN32
+
+static DWORD CALLBACK CopyProgressRoutine(
+ LARGE_INTEGER /* TotalFileSize */, // file size
+ LARGE_INTEGER TotalBytesTransferred, // bytes transferred
+ LARGE_INTEGER /* StreamSize */, // bytes in stream
+ LARGE_INTEGER /* StreamBytesTransferred */, // bytes transferred for stream
+ DWORD /* dwStreamNumber */, // current stream
+ DWORD /* dwCallbackReason */, // callback reason
+ HANDLE /* hSourceFile */, // handle to source file
+ HANDLE /* hDestinationFile */, // handle to destination file
+ LPVOID lpData // from CopyFileEx
+)
+{
+ CProgressInfo &progressInfo = *(CProgressInfo *)lpData;
+ UInt64 completed = progressInfo.StartPos + TotalBytesTransferred.QuadPart;
+ if (progressInfo.Progress->SetCompleted(&completed) != S_OK)
+ return PROGRESS_CANCEL;
+ return PROGRESS_CONTINUE;
+}
+
+typedef BOOL (WINAPI * CopyFileExPointer)(
+ IN LPCSTR lpExistingFileName,
+ IN LPCSTR lpNewFileName,
+ IN LPPROGRESS_ROUTINE lpProgressRoutine OPTIONAL,
+ IN LPVOID lpData OPTIONAL,
+ IN LPBOOL pbCancel OPTIONAL,
+ IN DWORD dwCopyFlags
+ );
+
+typedef BOOL (WINAPI * CopyFileExPointerW)(
+ IN LPCWSTR lpExistingFileName,
+ IN LPCWSTR lpNewFileName,
+ IN LPPROGRESS_ROUTINE lpProgressRoutine OPTIONAL,
+ IN LPVOID lpData OPTIONAL,
+ IN LPBOOL pbCancel OPTIONAL,
+ IN DWORD dwCopyFlags
+ );
+
+#ifndef _UNICODE
+static inline UINT GetCurrentCodePage() { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
+static CSysString GetSysPath(LPCWSTR sysPath)
+ { return UnicodeStringToMultiByte(sysPath, GetCurrentCodePage()); }
+#endif
+
+#endif
+
+static bool MyCopyFile(LPCWSTR existingFile, LPCWSTR newFile, IProgress *progress, UInt64 &completedSize)
+{
+#ifdef _WIN32
+ CProgressInfo progressInfo;
+ progressInfo.Progress = progress;
+ progressInfo.StartPos = completedSize;
+ BOOL CancelFlag = FALSE;
+ #ifndef _UNICODE
+ if (g_IsNT)
+ #endif
+ {
+ CopyFileExPointerW copyFunctionW = (CopyFileExPointerW)
+ ::GetProcAddress(::GetModuleHandleW(L"kernel32.dll"),
+ "CopyFileExW");
+ if (copyFunctionW == 0)
+ return false;
+ if (copyFunctionW(existingFile, newFile, CopyProgressRoutine,
+ &progressInfo, &CancelFlag, COPY_FILE_FAIL_IF_EXISTS))
+ return true;
+ #ifdef WIN_LONG_PATH
+ UString longPathExisting, longPathNew;
+ if (!NDirectory::GetLongPaths(existingFile, newFile, longPathExisting, longPathNew))
+ return false;
+ if (copyFunctionW(longPathExisting, longPathNew, CopyProgressRoutine,
+ &progressInfo, &CancelFlag, COPY_FILE_FAIL_IF_EXISTS))
+ return true;
+ #endif
+ return false;
+ }
+ #ifndef _UNICODE
+ else
+ {
+ CopyFileExPointer copyFunction = (CopyFileExPointer)
+ ::GetProcAddress(::GetModuleHandleA("kernel32.dll"),
+ "CopyFileExA");
+ if (copyFunction != 0)
+ {
+ if (copyFunction(GetSysPath(existingFile), GetSysPath(newFile),
+ CopyProgressRoutine,&progressInfo, &CancelFlag, COPY_FILE_FAIL_IF_EXISTS))
+ return true;
+ if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
+ return false;
+ }
+ return BOOLToBool(::CopyFile(GetSysPath(existingFile), GetSysPath(newFile), TRUE));
+ }
+ #endif
+#else
+ extern bool wxw_CopyFile(LPCWSTR existingFile, LPCWSTR newFile, bool overwrite);
+ return wxw_CopyFile(existingFile, newFile, true);
+#endif
+}
+
+#ifdef _WIN32
+typedef BOOL (WINAPI * MoveFileWithProgressPointer)(
+ IN LPCWSTR lpExistingFileName,
+ IN LPCWSTR lpNewFileName,
+ IN LPPROGRESS_ROUTINE lpProgressRoutine OPTIONAL,
+ IN LPVOID lpData OPTIONAL,
+ IN DWORD dwFlags
+ );
+#endif
+
+static bool MyMoveFile(LPCWSTR existingFile, LPCWSTR newFile, IProgress *progress, UInt64 &completedSize)
+{
+#ifdef _WIN32
+ // if (IsItWindows2000orHigher())
+ // {
+ CProgressInfo progressInfo;
+ progressInfo.Progress = progress;
+ progressInfo.StartPos = completedSize;
+
+ MoveFileWithProgressPointer moveFunction = (MoveFileWithProgressPointer)
+ ::GetProcAddress(::GetModuleHandle(TEXT("kernel32.dll")),
+ "MoveFileWithProgressW");
+ if (moveFunction != 0)
+ {
+ if (moveFunction(
+ existingFile, newFile, CopyProgressRoutine,
+ &progressInfo, MOVEFILE_COPY_ALLOWED))
+ return true;
+ if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
+ {
+ #ifdef WIN_LONG_PATH
+ UString longPathExisting, longPathNew;
+ if (!NDirectory::GetLongPaths(existingFile, newFile, longPathExisting, longPathNew))
+ return false;
+ if (moveFunction(longPathExisting, longPathNew, CopyProgressRoutine,
+ &progressInfo, MOVEFILE_COPY_ALLOWED))
+ return true;
+ #endif
+ if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
+ return false;
+ }
+ }
+ // }
+ // else
+#endif
+ return NDirectory::MyMoveFile(existingFile, newFile);
+}
+
+static HRESULT MyCopyFile(
+ const UString &srcPath,
+ const CFileInfoW &srcFileInfo,
+ const UString &destPathSpec,
+ IFolderOperationsExtractCallback *callback,
+ UInt64 &completedSize)
+{
+ UString destPath = destPathSpec;
+ if (destPath.CompareNoCase(srcPath) == 0)
+ {
+ UString message = UString(L"can not move file \'") + destPath + UString(L"\' onto itself");
+ RINOK(callback->ShowMessage(message));
+ return E_ABORT;
+ }
+
+ INT32 writeAskResult;
+ CMyComBSTR destPathResult;
+ RINOK(callback->AskWrite(
+ srcPath,
+ BoolToInt(false),
+ &srcFileInfo.MTime, &srcFileInfo.Size,
+ destPath,
+ &destPathResult,
+ &writeAskResult));
+ if (IntToBool(writeAskResult))
+ {
+ UString destPathNew = UString(destPathResult);
+ RINOK(callback->SetCurrentFilePath(srcPath));
+ if (!MyCopyFile(srcPath, destPathNew, callback, completedSize))
+ {
+ UString message = NError::MyFormatMessageW(GetLastError()) +
+ UString(L" \'") +
+ UString(destPathNew) +
+ UString(L"\'");
+ RINOK(callback->ShowMessage(message));
+ return E_ABORT;
+ }
+ }
+ completedSize += srcFileInfo.Size;
+ return callback->SetCompleted(&completedSize);
+}
+
+static HRESULT CopyFolder(
+ const UString &srcPath,
+ const UString &destPathSpec,
+ IFolderOperationsExtractCallback *callback,
+ UInt64 &completedSize)
+{
+ RINOK(callback->SetCompleted(&completedSize));
+
+ UString destPath = destPathSpec;
+ int len = srcPath.Length();
+ if (destPath.Length() >= len && srcPath.CompareNoCase(destPath.Left(len)) == 0)
+ {
+ if (destPath.Length() == len || destPath[len] == WCHAR_PATH_SEPARATOR)
+ {
+ UString message = UString(L"can not copy folder \'") +
+ destPath + UString(L"\' onto itself");
+ RINOK(callback->ShowMessage(message));
+ return E_ABORT;
+ }
+ }
+
+ if (!NDirectory::CreateComplexDirectory(destPath))
+ {
+ UString message = UString(L"can not create folder ") + destPath;
+ RINOK(callback->ShowMessage(message));
+ return E_ABORT;
+ }
+ CEnumeratorW enumerator(srcPath + UString(WSTRING_PATH_SEPARATOR L"*"));
+ CFileInfoEx fileInfo;
+ while (enumerator.Next(fileInfo))
+ {
+ const UString srcPath2 = srcPath + UString(WSTRING_PATH_SEPARATOR) + fileInfo.Name;
+ const UString destPath2 = destPath + UString(WSTRING_PATH_SEPARATOR) + fileInfo.Name;
+ if (fileInfo.IsDir())
+ {
+ RINOK(CopyFolder(srcPath2, destPath2, callback, completedSize));
+ }
+ else
+ {
+ RINOK(MyCopyFile(srcPath2, fileInfo, destPath2, callback, completedSize));
+ }
+ }
+ return S_OK;
+}
+
+
+STDMETHODIMP CFSFolder::CopyTo(const UInt32 *indices, UInt32 numItems,
+ const wchar_t *path, IFolderOperationsExtractCallback *callback)
+{
+ if (numItems == 0)
+ return S_OK;
+
+ UInt64 numFolders, numFiles, totalSize;
+ GetItemsFullSize(indices, numItems, numFolders, numFiles, totalSize, callback);
+ RINOK(callback->SetTotal(totalSize));
+ RINOK(callback->SetNumFiles(numFiles));
+
+ UString destPath = path;
+ if (destPath.IsEmpty())
+ return E_INVALIDARG;
+ bool directName = (destPath[destPath.Length() - 1] != WCHAR_PATH_SEPARATOR);
+ if (directName)
+ {
+ if (numItems > 1)
+ return E_INVALIDARG;
+ }
+ /*
+ // doesn't work in network
+ else
+ if (!NDirectory::CreateComplexDirectory(destPath)))
+ {
+ DWORD lastError = ::GetLastError();
+ UString message = UString(L"can not create folder ") +
+ destPath;
+ RINOK(callback->ShowMessage(message));
+ return E_ABORT;
+ }
+ */
+
+ UInt64 completedSize = 0;
+ RINOK(callback->SetCompleted(&completedSize));
+ for (UInt32 i = 0; i < numItems; i++)
+ {
+ const CDirItem &fileInfo = *_refs[indices[i]];
+ UString destPath2 = destPath;
+ if (!directName)
+ destPath2 += fileInfo.Name;
+ UString srcPath = _path + GetPrefix(fileInfo) + fileInfo.Name;
+ if (fileInfo.IsDir())
+ {
+ RINOK(CopyFolder(srcPath, destPath2, callback, completedSize));
+ }
+ else
+ {
+ RINOK(MyCopyFile(srcPath, fileInfo, destPath2, callback, completedSize));
+ }
+ }
+ return S_OK;
+}
+
+/////////////////////////////////////////////////
+// Move Operations
+
+HRESULT MyMoveFile(
+ const UString &srcPath,
+ const CFileInfoW &srcFileInfo,
+ const UString &destPathSpec,
+ IFolderOperationsExtractCallback *callback,
+ UInt64 &completedSize)
+{
+ UString destPath = destPathSpec;
+ if (destPath.CompareNoCase(srcPath) == 0)
+ {
+ UString message = UString(L"can not move file \'")
+ + destPath +
+ UString(L"\' onto itself");
+ RINOK(callback->ShowMessage(message));
+ return E_ABORT;
+ }
+
+ INT32 writeAskResult;
+ CMyComBSTR destPathResult;
+ RINOK(callback->AskWrite(
+ srcPath,
+ BoolToInt(false),
+ &srcFileInfo.MTime, &srcFileInfo.Size,
+ destPath,
+ &destPathResult,
+ &writeAskResult));
+ if (IntToBool(writeAskResult))
+ {
+ UString destPathNew = UString(destPathResult);
+ RINOK(callback->SetCurrentFilePath(srcPath));
+ if (!MyMoveFile(srcPath, destPathNew, callback, completedSize))
+ {
+ UString message = UString(L"can not move to file ") + destPathNew;
+ RINOK(callback->ShowMessage(message));
+ }
+ }
+ completedSize += srcFileInfo.Size;
+ RINOK(callback->SetCompleted(&completedSize));
+ return S_OK;
+}
+
+HRESULT MyMoveFolder(
+ const UString &srcPath,
+ const UString &destPathSpec,
+ IFolderOperationsExtractCallback *callback,
+ UInt64 &completedSize)
+{
+ UString destPath = destPathSpec;
+ int len = srcPath.Length();
+ if (destPath.Length() >= len && srcPath.CompareNoCase(destPath.Left(len)) == 0)
+ {
+ if (destPath.Length() == len || destPath[len] == WCHAR_PATH_SEPARATOR)
+ {
+ UString message = UString(L"can not move folder \'") +
+ destPath + UString(L"\' onto itself");
+ RINOK(callback->ShowMessage(message));
+ return E_ABORT;
+ }
+ }
+
+ if (MyMoveFile(srcPath, destPath, callback, completedSize))
+ return S_OK;
+
+ if (!NDirectory::CreateComplexDirectory(destPath))
+ {
+ UString message = UString(L"can not create folder ") + destPath;
+ RINOK(callback->ShowMessage(message));
+ return E_ABORT;
+ }
+ {
+ CEnumeratorW enumerator(srcPath + UString(WSTRING_PATH_SEPARATOR L"*"));
+ CFileInfoEx fileInfo;
+ while (enumerator.Next(fileInfo))
+ {
+ const UString srcPath2 = srcPath + UString(WSTRING_PATH_SEPARATOR) + fileInfo.Name;
+ const UString destPath2 = destPath + UString(WSTRING_PATH_SEPARATOR) + fileInfo.Name;
+ if (fileInfo.IsDir())
+ {
+ RINOK(MyMoveFolder(srcPath2, destPath2, callback, completedSize));
+ }
+ else
+ {
+ RINOK(MyMoveFile(srcPath2, fileInfo, destPath2, callback, completedSize));
+ }
+ }
+ }
+ if (!NDirectory::MyRemoveDirectory(srcPath))
+ {
+ UString message = UString(L"can not remove folder") + srcPath;
+ RINOK(callback->ShowMessage(message));
+ return E_ABORT;
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CFSFolder::MoveTo(
+ const UInt32 *indices,
+ UInt32 numItems,
+ const wchar_t *path,
+ IFolderOperationsExtractCallback *callback)
+{
+ if (numItems == 0)
+ return S_OK;
+
+ UInt64 numFolders, numFiles, totalSize;
+ GetItemsFullSize(indices, numItems, numFolders, numFiles, totalSize, callback);
+ RINOK(callback->SetTotal(totalSize));
+ RINOK(callback->SetNumFiles(numFiles));
+
+ UString destPath = path;
+ if (destPath.IsEmpty())
+ return E_INVALIDARG;
+ bool directName = (destPath[destPath.Length() - 1] != WCHAR_PATH_SEPARATOR);
+ if (directName)
+ {
+ if (numItems > 1)
+ return E_INVALIDARG;
+ }
+ else
+ if (!NDirectory::CreateComplexDirectory(destPath))
+ {
+ UString message = UString(L"can not create folder ") +
+ destPath;
+ RINOK(callback->ShowMessage(message));
+ return E_ABORT;
+ }
+
+ UInt64 completedSize = 0;
+ RINOK(callback->SetCompleted(&completedSize));
+ for (UInt32 i = 0; i < numItems; i++)
+ {
+ const CDirItem &fileInfo = *_refs[indices[i]];
+ UString destPath2 = destPath;
+ if (!directName)
+ destPath2 += fileInfo.Name;
+ UString srcPath = _path + GetPrefix(fileInfo) + fileInfo.Name;
+ if (fileInfo.IsDir())
+ {
+ RINOK(MyMoveFolder(srcPath, destPath2, callback, completedSize));
+ }
+ else
+ {
+ RINOK(MyMoveFile(srcPath, fileInfo, destPath2, callback, completedSize));
+ }
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CFSFolder::CopyFrom(const wchar_t * /* fromFolderPath */,
+ const wchar_t ** /* itemsPaths */, UInt32 /* numItems */, IProgress * /* progress */)
+{
+ /*
+ UInt64 numFolders, numFiles, totalSize;
+ numFiles = numFolders = totalSize = 0;
+ UInt32 i;
+ for (i = 0; i < numItems; i++)
+ {
+ UString path = (UString)fromFolderPath + itemsPaths[i];
+
+ CFileInfoW fileInfo;
+ if (!FindFile(path, fileInfo))
+ return ::GetLastError();
+ if (fileInfo.IsDir())
+ {
+ UInt64 subFolders, subFiles, subSize;
+ RINOK(GetFolderSize(path + UString(WSTRING_PATH_SEPARATOR) + fileInfo.Name, subFolders, subFiles, subSize, progress));
+ numFolders += subFolders;
+ numFolders++;
+ numFiles += subFiles;
+ totalSize += subSize;
+ }
+ else
+ {
+ numFiles++;
+ totalSize += fileInfo.Size;
+ }
+ }
+ RINOK(progress->SetTotal(totalSize));
+ RINOK(callback->SetNumFiles(numFiles));
+ for (i = 0; i < numItems; i++)
+ {
+ UString path = (UString)fromFolderPath + itemsPaths[i];
+ }
+ return S_OK;
+ */
+ return E_NOTIMPL;
+}
+
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,176 @@
+// FileFolderPluginOpen.cpp
+
+#include "StdAfx.h"
+
+#include "resource.h"
+
+#include "Windows/Thread.h"
+
+#include "../Agent/Agent.h"
+
+#include "LangUtils.h"
+#include "OpenCallback.h"
+#include "PluginLoader.h"
+#include "RegistryAssociations.h"
+#include "RegistryPlugins.h"
+
+using namespace NWindows;
+using namespace NRegistryAssociations;
+
+struct CThreadArchiveOpen
+{
+ UString Path;
+ UString ArcFormat;
+ CMyComPtr<IInStream> InStream;
+ CMyComPtr<IFolderManager> FolderManager;
+ CMyComPtr<IProgress> OpenCallback;
+ COpenArchiveCallback *OpenCallbackSpec;
+
+ CMyComPtr<IFolderFolder> Folder;
+ HRESULT Result;
+
+ void Process()
+ {
+ try
+ {
+ CProgressCloser closer(OpenCallbackSpec->ProgressDialog);
+ Result = FolderManager->OpenFolderFile(InStream, Path, ArcFormat, &Folder, OpenCallback);
+ }
+ catch(...) { Result = E_FAIL; }
+ }
+
+ static THREAD_FUNC_DECL MyThreadFunction(void *param)
+ {
+ ((CThreadArchiveOpen *)param)->Process();
+ return 0;
+ }
+};
+
+/*
+static int FindPlugin(const CObjectVector<CPluginInfo> &plugins, const UString &pluginName)
+{
+ for (int i = 0; i < plugins.Size(); i++)
+ if (plugins[i].Name.CompareNoCase(pluginName) == 0)
+ return i;
+ return -1;
+}
+*/
+
+HRESULT OpenFileFolderPlugin(
+ IInStream *inStream,
+ const UString &path,
+ const UString &arcFormat,
+ HMODULE *module,
+ IFolderFolder **resultFolder,
+ HWND parentWindow,
+ bool &encrypted, UString &password)
+{
+#ifdef _WIN32
+ CObjectVector<CPluginInfo> plugins;
+ ReadFileFolderPluginInfoList(plugins);
+#endif
+
+ UString extension, name, pureName, dot;
+
+ int slashPos = path.ReverseFind(WCHAR_PATH_SEPARATOR);
+ UString dirPrefix;
+ UString fileName;
+ if (slashPos >= 0)
+ {
+ dirPrefix = path.Left(slashPos + 1);
+ fileName = path.Mid(slashPos + 1);
+ }
+ else
+ fileName = path;
+
+ NFile::NName::SplitNameToPureNameAndExtension(fileName, pureName, dot, extension);
+
+ /*
+ if (!extension.IsEmpty())
+ {
+ CExtInfo extInfo;
+ if (ReadInternalAssociation(extension, extInfo))
+ {
+ for (int i = extInfo.Plugins.Size() - 1; i >= 0; i--)
+ {
+ int pluginIndex = FindPlugin(plugins, extInfo.Plugins[i]);
+ if (pluginIndex >= 0)
+ {
+ const CPluginInfo plugin = plugins[pluginIndex];
+ plugins.Delete(pluginIndex);
+ plugins.Insert(0, plugin);
+ }
+ }
+ }
+ }
+ */
+
+#ifdef _WIN32
+ for (int i = 0; i < plugins.Size(); i++)
+ {
+ const CPluginInfo &plugin = plugins[i];
+ if (!plugin.ClassIDDefined)
+ continue;
+#endif
+ CPluginLibrary library;
+
+ CThreadArchiveOpen t;
+
+#ifdef _WIN32
+ if (plugin.FilePath.IsEmpty())
+ t.FolderManager = new CArchiveFolderManager;
+ else if (library.LoadAndCreateManager(plugin.FilePath, plugin.ClassID, &t.FolderManager) != S_OK)
+ continue;
+#else
+ t.FolderManager = new CArchiveFolderManager;
+#endif
+
+ t.OpenCallbackSpec = new COpenArchiveCallback;
+ t.OpenCallback = t.OpenCallbackSpec;
+ t.OpenCallbackSpec->PasswordIsDefined = encrypted;
+ t.OpenCallbackSpec->Password = password;
+ t.OpenCallbackSpec->ParentWindow = parentWindow;
+
+ if (inStream)
+ t.OpenCallbackSpec->SetSubArchiveName(fileName);
+ else
+ t.OpenCallbackSpec->LoadFileInfo(dirPrefix, fileName);
+
+ t.InStream = inStream;
+ t.Path = path;
+ t.ArcFormat = arcFormat;
+
+ UString progressTitle = LangString(IDS_OPENNING, 0x03020283);
+ t.OpenCallbackSpec->ProgressDialog.MainWindow = parentWindow;
+ t.OpenCallbackSpec->ProgressDialog.MainTitle = LangString(IDS_APP_TITLE, 0x03000000);
+ t.OpenCallbackSpec->ProgressDialog.MainAddTitle = progressTitle + UString(L" ");
+ // FIXME t.OpenCallbackSpec->ProgressDialog.WaitMode = true;
+
+ {
+ NWindows::CThread thread;
+ RINOK(thread.Create(CThreadArchiveOpen::MyThreadFunction, &t));
+ t.OpenCallbackSpec->StartProgressDialog(progressTitle, thread);
+ }
+
+ if (t.Result == E_ABORT)
+ return t.Result;
+
+ if (t.Result == S_OK)
+ {
+ // if (openCallbackSpec->PasswordWasAsked)
+ {
+ encrypted = t.OpenCallbackSpec->PasswordIsDefined;
+ password = t.OpenCallbackSpec->Password;
+ }
+ *module = library.Detach();
+ *resultFolder = t.Folder.Detach();
+ return S_OK;
+ }
+
+ if (t.Result != S_FALSE)
+ return t.Result;
+#ifdef _WIN32
+ }
+#endif
+ return S_FALSE;
+}
\ No newline at end of file
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/FileFolderPluginOpen.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/FileFolderPluginOpen.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/FileFolderPluginOpen.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/FileFolderPluginOpen.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,9 @@
+// FileFolderPluginOpen.h
+
+#ifndef __FILE_FOLDER_PLUGIN_OPEN_H
+#define __FILE_FOLDER_PLUGIN_OPEN_H
+
+HRESULT OpenFileFolderPlugin(IInStream *inStream, const UString &path, const UString &arcFormat,
+ HMODULE *module, IFolderFolder **resultFolder, HWND parentWindow, bool &encrypted, UString &password);
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/FormatUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/FormatUtils.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/FormatUtils.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/FormatUtils.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,40 @@
+// FormatUtils.cpp
+
+#include "StdAfx.h"
+
+#include "FormatUtils.h"
+#include "Common/IntToString.h"
+#include "Windows/ResourceString.h"
+
+#ifdef LANG
+#include "LangUtils.h"
+#endif
+
+UString NumberToString(UInt64 number)
+{
+ wchar_t numberString[32];
+ ConvertUInt64ToString(number, numberString);
+ return numberString;
+}
+
+UString MyFormatNew(const UString &format, const UString &argument)
+{
+ UString result = format;
+ result.Replace(L"{0}", argument);
+ return result;
+}
+
+UString MyFormatNew(UINT resourceID,
+ #ifdef LANG
+ UInt32 langID,
+ #endif
+ const UString &argument)
+{
+ return MyFormatNew(
+ #ifdef LANG
+ LangString(resourceID, langID),
+ #else
+ NWindows::MyLoadStringW(resourceID),
+ #endif
+ argument);
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/FormatUtils.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/FormatUtils.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/FormatUtils.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/FormatUtils.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,18 @@
+// FormatUtils.h
+
+#ifndef __FORMATUTILS_H
+#define __FORMATUTILS_H
+
+#include "Common/Types.h"
+#include "Common/MyString.h"
+
+UString NumberToString(UInt64 number);
+
+UString MyFormatNew(const UString &format, const UString &argument);
+UString MyFormatNew(UINT resourceID,
+ #ifdef LANG
+ UInt32 langID,
+ #endif
+ const UString &argument);
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/HelpUtils.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/HelpUtils.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/HelpUtils.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/HelpUtils.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,10 @@
+// HelpUtils.h
+
+#ifndef __HELPUTILS_H
+#define __HELPUTILS_H
+
+#include "Common/MyString.h"
+
+void ShowHelpWindow(HWND hwnd, LPCWSTR topicFile);
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/IFolder.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/IFolder.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/IFolder.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/IFolder.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,161 @@
+// IFolder.h
+
+#ifndef __IFOLDER_H
+#define __IFOLDER_H
+
+#include "../../IProgress.h"
+#include "../../IStream.h"
+
+#define FOLDER_INTERFACE_SUB(i, b, x) DECL_INTERFACE_SUB(i, b, 8, x)
+#define FOLDER_INTERFACE(i, x) FOLDER_INTERFACE_SUB(i, IUnknown, x)
+
+namespace NPlugin
+{
+ enum
+ {
+ kName = 0,
+ kType,
+ kClassID,
+ kOptionsClassID
+ };
+}
+
+#define INTERFACE_FolderFolder(x) \
+ STDMETHOD(LoadItems)() x; \
+ STDMETHOD(GetNumberOfItems)(UInt32 *numItems) x; \
+ STDMETHOD(GetProperty)(UInt32 itemIndex, PROPID propID, PROPVARIANT *value) x; \
+ STDMETHOD(BindToFolder)(UInt32 index, IFolderFolder **resultFolder) x; \
+ STDMETHOD(BindToFolder)(const wchar_t *name, IFolderFolder **resultFolder) x; \
+ STDMETHOD(BindToParentFolder)(IFolderFolder **resultFolder) x; \
+ STDMETHOD(GetNumberOfProperties)(UInt32 *numProperties) x; \
+ STDMETHOD(GetPropertyInfo)(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) x; \
+ STDMETHOD(GetFolderProperty)(PROPID propID, PROPVARIANT *value) x; \
+
+FOLDER_INTERFACE(IFolderFolder, 0x00)
+{
+ INTERFACE_FolderFolder(PURE)
+};
+
+FOLDER_INTERFACE(IFolderWasChanged, 0x04)
+{
+ STDMETHOD(WasChanged)(Int32 *wasChanged) PURE;
+};
+
+FOLDER_INTERFACE_SUB(IFolderOperationsExtractCallback, IProgress, 0x0B)
+{
+ // STDMETHOD(SetTotalFiles)(UInt64 total) PURE;
+ // STDMETHOD(SetCompletedFiles)(const UInt64 *completedValue) PURE;
+ STDMETHOD(AskWrite)(
+ const wchar_t *srcPath,
+ Int32 srcIsFolder,
+ const FILETIME *srcTime,
+ const UInt64 *srcSize,
+ const wchar_t *destPathRequest,
+ BSTR *destPathResult,
+ Int32 *writeAnswer) PURE;
+ STDMETHOD(ShowMessage)(const wchar_t *message) PURE;
+ STDMETHOD(SetCurrentFilePath)(const wchar_t *filePath) PURE;
+ STDMETHOD(SetNumFiles)(UInt64 numFiles) PURE;
+};
+
+#define INTERFACE_FolderOperations(x) \
+ STDMETHOD(CreateFolder)(const wchar_t *name, IProgress *progress) x; \
+ STDMETHOD(CreateFile)(const wchar_t *name, IProgress *progress) x; \
+ STDMETHOD(Rename)(UInt32 index, const wchar_t *newName, IProgress *progress) x; \
+ STDMETHOD(Delete)(const UInt32 *indices, UInt32 numItems, IProgress *progress) x; \
+ STDMETHOD(CopyTo)(const UInt32 *indices, UInt32 numItems, \
+ const wchar_t *path, IFolderOperationsExtractCallback *callback) x; \
+ STDMETHOD(MoveTo)(const UInt32 *indices, UInt32 numItems, \
+ const wchar_t *path, IFolderOperationsExtractCallback *callback) x; \
+ STDMETHOD(CopyFrom)(const wchar_t *fromFolderPath, \
+ const wchar_t **itemsPaths, UInt32 numItems, IProgress *progress) x; \
+ STDMETHOD(SetProperty)(UInt32 index, PROPID propID, const PROPVARIANT *value, IProgress *progress) x; \
+
+FOLDER_INTERFACE(IFolderOperations, 0x06)
+{
+ INTERFACE_FolderOperations(PURE)
+};
+
+/*
+FOLDER_INTERFACE2(IFolderOperationsDeleteToRecycleBin, 0x06, 0x03)
+{
+ STDMETHOD(DeleteToRecycleBin)(const UInt32 *indices, UInt32 numItems, IProgress *progress) PURE;
+};
+*/
+
+FOLDER_INTERFACE(IFolderGetSystemIconIndex, 0x07)
+{
+ STDMETHOD(GetSystemIconIndex)(UInt32 index, Int32 *iconIndex) PURE;
+};
+
+FOLDER_INTERFACE(IFolderGetItemFullSize, 0x08)
+{
+ STDMETHOD(GetItemFullSize)(UInt32 index, PROPVARIANT *value, IProgress *progress) PURE;
+};
+
+FOLDER_INTERFACE(IFolderClone, 0x09)
+{
+ STDMETHOD(Clone)(IFolderFolder **resultFolder) PURE;
+};
+
+FOLDER_INTERFACE(IFolderSetFlatMode, 0x0A)
+{
+ STDMETHOD(SetFlatMode)(Int32 flatMode) PURE;
+};
+
+#define INTERFACE_FolderProperties(x) \
+ STDMETHOD(GetNumberOfFolderProperties)(UInt32 *numProperties) x; \
+ STDMETHOD(GetFolderPropertyInfo)(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) x; \
+
+FOLDER_INTERFACE(IFolderProperties, 0x0E)
+{
+ INTERFACE_FolderProperties(PURE)
+};
+
+#define INTERFACE_IFolderArcProps(x) \
+ STDMETHOD(GetArcNumLevels)(UInt32 *numLevels) x; \
+ STDMETHOD(GetArcProp)(UInt32 level, PROPID propID, PROPVARIANT *value) x; \
+ STDMETHOD(GetArcNumProps)(UInt32 level, UInt32 *numProps) x; \
+ STDMETHOD(GetArcPropInfo)(UInt32 level, UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) x; \
+ STDMETHOD(GetArcProp2)(UInt32 level, PROPID propID, PROPVARIANT *value) x; \
+ STDMETHOD(GetArcNumProps2)(UInt32 level, UInt32 *numProps) x; \
+ STDMETHOD(GetArcPropInfo2)(UInt32 level, UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) x; \
+
+FOLDER_INTERFACE(IFolderArcProps, 0x10)
+{
+ INTERFACE_IFolderArcProps(PURE)
+};
+
+FOLDER_INTERFACE(IGetFolderArcProps, 0x11)
+{
+ STDMETHOD(GetFolderArcProps)(IFolderArcProps **object) PURE;
+};
+
+#define FOLDER_MANAGER_INTERFACE(i, x) DECL_INTERFACE(i, 9, x)
+
+#define INTERFACE_IFolderManager(x) \
+ STDMETHOD(OpenFolderFile)(IInStream *inStream, const wchar_t *filePath, const wchar_t *arcFormat, IFolderFolder **resultFolder, IProgress *progress) x; \
+ STDMETHOD(GetExtensions)(BSTR *extensions) x; \
+ STDMETHOD(GetIconPath)(const wchar_t *ext, BSTR *iconPath, Int32 *iconIndex) x; \
+
+ // STDMETHOD(GetTypes)(BSTR *types) PURE;
+ // STDMETHOD(CreateFolderFile)(const wchar_t *type, const wchar_t *filePath, IProgress *progress) PURE;
+
+FOLDER_MANAGER_INTERFACE(IFolderManager, 0x05)
+{
+ INTERFACE_IFolderManager(PURE);
+};
+
+
+#define IMP_IFolderFolder_GetProp(k) \
+ (UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) \
+ { if(index >= sizeof(k) / sizeof(k[0])) return E_INVALIDARG; \
+ const STATPROPSTG &srcItem = k[index]; \
+ *propID = srcItem.propid; *varType = srcItem.vt; *name = 0; return S_OK; } \
+
+#define IMP_IFolderFolder_Props(c) \
+ STDMETHODIMP c::GetNumberOfProperties(UInt32 *numProperties) \
+ { *numProperties = sizeof(kProps) / sizeof(kProps[0]); return S_OK; } \
+ STDMETHODIMP c::GetPropertyInfo IMP_IFolderFolder_GetProp(kProps)
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/LangUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/LangUtils.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/LangUtils.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/LangUtils.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,208 @@
+// LangUtils.cpp
+
+#include "StdAfx.h"
+
+#include "LangUtils.h"
+#include "Common/StringConvert.h"
+#include "Common/StringToInt.h"
+#include "Windows/Synchronization.h"
+#include "Windows/Window.h"
+#include "Windows/FileFind.h"
+#include "RegistryUtils.h"
+#include "ProgramLocation.h"
+
+using namespace NWindows;
+
+static CLang g_Lang;
+UString g_LangID;
+
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
+
+void ReloadLang()
+{
+ ReadRegLang(g_LangID);
+ g_Lang.Clear();
+ if (!g_LangID.IsEmpty() && g_LangID != L"-")
+ {
+ UString langPath = g_LangID;
+ if (langPath.Find(WCHAR_PATH_SEPARATOR) < 0)
+ {
+ if (langPath.Find(L'.') < 0)
+ langPath += L".txt";
+ UString folderPath;
+ if (GetProgramFolderPath(folderPath))
+ langPath = folderPath + UString(L"Lang" WSTRING_PATH_SEPARATOR) + langPath;
+ }
+ g_Lang.Open(langPath);
+ }
+}
+
+static bool g_Loaded = false;
+static NSynchronization::CCriticalSection g_CriticalSection;
+
+void LoadLangOneTime()
+{
+ NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
+ if (g_Loaded)
+ return;
+ g_Loaded = true;
+ ReloadLang();
+}
+
+void LangSetDlgItemsText(HWND dialogWindow, CIDLangPair *idLangPairs, int numItems)
+{
+ for (int i = 0; i < numItems; i++)
+ {
+ const CIDLangPair &idLangPair = idLangPairs[i];
+ UString message;
+ if (g_Lang.GetMessage(idLangPair.LangID, message))
+ {
+ NWindows::CWindow window(GetDlgItem(dialogWindow, idLangPair.ControlID));
+ window.SetText(message);
+ }
+ }
+}
+
+void LangSetWindowText(HWND window, UInt32 langID)
+{
+ UString message;
+ if (g_Lang.GetMessage(langID, message))
+ MySetWindowText(window, message);
+}
+
+UString LangString(UInt32 langID)
+{
+ UString message;
+ if (g_Lang.GetMessage(langID, message))
+ return message;
+ return UString();
+}
+
+UString LangString(UINT resourceID, UInt32 langID)
+{
+ UString message;
+ if (g_Lang.GetMessage(langID, message))
+ return message;
+ return NWindows::MyLoadStringW(resourceID);
+}
+
+void LoadLangs(CObjectVector<CLangEx> &langs)
+{
+ langs.Clear();
+ UString folderPath;
+ if (!::GetProgramFolderPath(folderPath))
+ return;
+ folderPath += L"Lang" WSTRING_PATH_SEPARATOR;
+ NWindows::NFile::NFind::CEnumeratorW enumerator(folderPath + L"*.txt");
+ NWindows::NFile::NFind::CFileInfoW fileInfo;
+ while (enumerator.Next(fileInfo))
+ {
+ if (fileInfo.IsDir())
+ continue;
+ CLangEx lang;
+ UString filePath = folderPath + fileInfo.Name;
+ const int kExtSize = 4;
+ const UString ext = fileInfo.Name.Right(kExtSize);
+ if (ext.CompareNoCase(L".txt") != 0)
+ continue;
+ lang.ShortName = fileInfo.Name.Left(fileInfo.Name.Length() - kExtSize);
+ if (lang.Lang.Open(filePath))
+ langs.Add(lang);
+ }
+}
+
+bool SplidID(const UString &id, WORD &primID, WORD &subID)
+{
+ primID = 0;
+ subID = 0;
+ const wchar_t *start = id;
+ const wchar_t *end;
+ UInt64 value = ConvertStringToUInt64(start, &end);
+ if (start == end)
+ return false;
+ primID = (WORD)value;
+ if (*end == 0)
+ return true;
+ if (*end != L'-')
+ return false;
+ start = end + 1;
+ value = ConvertStringToUInt64(start, &end);
+ if (start == end)
+ return false;
+ subID = (WORD)value;
+ return (*end == 0);
+}
+
+typedef LANGID (WINAPI *GetUserDefaultUILanguageP)();
+
+void FindMatchLang(UString &shortName)
+{
+ shortName.Empty();
+
+ LANGID SystemDefaultLangID = GetSystemDefaultLangID(); // Lang for non-Unicode in XP64
+ LANGID UserDefaultLangID = GetUserDefaultLangID(); // Standarts and formats in XP64
+
+ if (SystemDefaultLangID != UserDefaultLangID)
+ return;
+ LANGID langID = UserDefaultLangID;
+ /*
+ LANGID SystemDefaultUILanguage; // english in XP64
+ LANGID UserDefaultUILanguage; // english in XP64
+
+ GetUserDefaultUILanguageP fn = (GetUserDefaultUILanguageP)GetProcAddress(
+ GetModuleHandle("kernel32"), "GetUserDefaultUILanguage");
+ if (fn != NULL)
+ UserDefaultUILanguage = fn();
+ fn = (GetUserDefaultUILanguageP)GetProcAddress(
+ GetModuleHandle("kernel32"), "GetSystemDefaultUILanguage");
+ if (fn != NULL)
+ SystemDefaultUILanguage = fn();
+ */
+
+ WORD primLang = (WORD)(PRIMARYLANGID(langID));
+ WORD subLang = (WORD)(SUBLANGID(langID));
+ CObjectVector<CLangEx> langs;
+ LoadLangs(langs);
+ for (int i = 0; i < langs.Size(); i++)
+ {
+ const CLangEx &lang = langs[i];
+ UString id;
+ if (lang.Lang.GetMessage(0x00000002, id))
+ {
+ WORD primID;
+ WORD subID;
+ if (SplidID(id, primID, subID))
+ if (primID == primLang)
+ {
+ if (subID == 0)
+ shortName = lang.ShortName;
+ if (subLang == subID)
+ {
+ shortName = lang.ShortName;
+ return;
+ }
+ }
+ }
+ }
+}
+
+void ReloadLangSmart()
+{
+ #ifndef _UNICODE
+ if (g_IsNT)
+ #endif
+ {
+ ReadRegLang(g_LangID);
+ if (g_LangID.IsEmpty())
+ {
+ UString shortName;
+ FindMatchLang(shortName);
+ if (shortName.IsEmpty())
+ shortName = L"-";
+ SaveRegLang(shortName);
+ }
+ }
+ ReloadLang();
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/LangUtils.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/LangUtils.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/LangUtils.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/LangUtils.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,41 @@
+// LangUtils.h
+
+#ifndef __LANGUTILS_H
+#define __LANGUTILS_H
+
+#include "Common/Lang.h"
+#include "Windows/ResourceString.h"
+
+extern UString g_LangID;
+
+struct CIDLangPair
+{
+ int ControlID;
+ UInt32 LangID;
+};
+
+void ReloadLang();
+void LoadLangOneTime();
+void ReloadLangSmart();
+
+struct CLangEx
+{
+ CLang Lang;
+ UString ShortName;
+};
+
+void LoadLangs(CObjectVector<CLangEx> &langs);
+
+void LangSetDlgItemsText(HWND dialogWindow, CIDLangPair *idLangPairs, int numItems);
+void LangSetWindowText(HWND window, UInt32 langID);
+
+UString LangString(UInt32 langID);
+UString LangString(UINT resourceID, UInt32 langID);
+
+#ifdef LANG
+#define LangStringSpec(resourceID, langID) LangString(resourceID, langID)
+#else
+#define LangStringSpec(resourceID, langID) NWindows::MyLoadStringW(resourceID)
+#endif
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ListViewDialog.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ListViewDialog.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ListViewDialog.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ListViewDialog.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,119 @@
+// ListViewDialog.cpp
+
+#include "StdAfx.h"
+
+#include "ListViewDialog.h"
+#include "RegistryUtils.h"
+
+#ifdef LANG
+#include "LangUtils.h"
+static CIDLangPair kIDLangPairs[] =
+{
+ { IDOK, 0x02000702 },
+ { IDCANCEL, 0x02000710 }
+};
+#endif
+
+bool CListViewDialog::OnInit()
+{
+ #ifdef LANG
+ LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
+ #endif
+ _listView.Attach(GetItem(IDC_LISTVIEW_LIST));
+
+//FIXME if (ReadSingleClick())
+//FIXME _listView.SetExtendedListViewStyle(LVS_EX_ONECLICKACTIVATE | LVS_EX_TRACKSELECT);
+
+ SetText(Title);
+
+ LVCOLUMN columnInfo;
+ columnInfo.mask = LVCF_FMT | LVCF_WIDTH | LVCF_SUBITEM;
+ columnInfo.fmt = LVCFMT_LEFT;
+ columnInfo.iSubItem = 0;
+ columnInfo.cx = 200;
+
+ _listView.InsertColumn(0, &columnInfo);
+
+ for (int i = 0; i < Strings.Size(); i++)
+ _listView.InsertItem(i, Strings[i]);
+
+ if (Strings.Size() > 0)
+ _listView.SetItemState_FocusedSelected(0);
+
+ _listView.SetColumnWidthAuto(0);
+ StringsWereChanged = false;
+
+ NormalizeSize();
+ return CModalDialog::OnInit();
+}
+
+#ifdef _WIN32 // FIXME
+bool CListViewDialog::OnNotify(UINT /* controlID */, LPNMHDR header)
+{
+ if (header->hwndFrom != _listView)
+ return false;
+ switch(header->code)
+ {
+ case LVN_ITEMACTIVATE:
+ if (g_LVN_ITEMACTIVATE_Support)
+ {
+ OnOK();
+ return true;
+ }
+ break;
+ case NM_DBLCLK:
+ case NM_RETURN: // probabably it's unused
+ if (!g_LVN_ITEMACTIVATE_Support)
+ {
+ OnOK();
+ return true;
+ }
+ break;
+
+ case LVN_KEYDOWN:
+ {
+ LPNMLVKEYDOWN keyDownInfo = LPNMLVKEYDOWN(header);
+ switch(keyDownInfo->wVKey)
+ {
+ case VK_DELETE:
+ {
+ if (!DeleteIsAllowed)
+ return false;
+ for (;;)
+ {
+ int index = _listView.GetNextSelectedItem(-1);
+ if (index < 0)
+ break;
+ StringsWereChanged = true;
+ _listView.DeleteItem(index);
+ Strings.Delete(index);
+ }
+ int focusedIndex = _listView.GetFocusedItem();
+ if (focusedIndex >= 0)
+ _listView.SetItemState_FocusedSelected(focusedIndex);
+ _listView.SetColumnWidthAuto(0);
+ return true;
+ }
+ case 'A':
+ {
+ bool ctrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0;
+ if (ctrl)
+ {
+ int numItems = _listView.GetItemCount();
+ for (int i = 0; i < numItems; i++)
+ _listView.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
+ return true;
+ }
+ }
+ }
+ }
+ }
+ return false;
+}
+#endif
+
+void CListViewDialog::OnOK()
+{
+ FocusedItemIndex = _listView.GetFocusedItem();
+ CModalDialog::OnOK();
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ListViewDialog.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ListViewDialog.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ListViewDialog.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ListViewDialog.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,32 @@
+// ListViewDialog.h
+
+#ifndef __LISTVIEW_DIALOG_H
+#define __LISTVIEW_DIALOG_H
+
+#include "Windows/Control/Dialog.h"
+#include "Windows/Control/ListView.h"
+
+#include "ListViewDialogRes.h"
+
+class CListViewDialog: public NWindows::NControl::CModalDialog
+{
+ NWindows::NControl::CListView _listView;
+ virtual void OnOK();
+ virtual bool OnInit();
+#ifdef _WIN32 // FIXME
+ virtual bool OnNotify(UINT controlID, LPNMHDR header);
+#endif
+
+public:
+ UString Title;
+ bool DeleteIsAllowed;
+ bool StringsWereChanged;
+ UStringVector Strings;
+ int FocusedItemIndex;
+
+ INT_PTR Create(HWND wndParent = 0) { return CModalDialog::Create(IDD_DIALOG_LISTVIEW, wndParent); }
+
+ CListViewDialog(): DeleteIsAllowed(false) {}
+};
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ListViewDialogRes.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ListViewDialogRes.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ListViewDialogRes.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ListViewDialogRes.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,2 @@
+#define IDD_DIALOG_LISTVIEW 508
+#define IDC_LISTVIEW_LIST 1000
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ListViewDialog_rc.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ListViewDialog_rc.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ListViewDialog_rc.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ListViewDialog_rc.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,60 @@
+// PasswordDialog.cpp
+
+#include "StdAfx.h"
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+// for all others, include the necessary headers (this file is usually all you
+// need because it includes almost all "standard" wxWidgets headers)
+#ifndef WX_PRECOMP
+ #include "wx/wx.h"
+#endif
+
+#include <wx/listctrl.h>
+
+#undef _WIN32
+
+#include "Windows/Control/DialogImpl.h"
+
+#include "ListViewDialogRes.h"
+
+class CListViewDialogImpl : public NWindows::NControl::CModalDialogImpl
+{
+ public:
+ CListViewDialogImpl(NWindows::NControl::CModalDialog *dialog,wxWindow * parent,int id) :
+ CModalDialogImpl(dialog,parent, id, wxT("ListView"), wxDefaultPosition, wxDefaultSize,
+ wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX | wxMINIMIZE_BOX)
+
+ {
+
+ wxBoxSizer* topsizer = new wxBoxSizer(wxVERTICAL);
+
+ wxListCtrl *list = new wxListCtrl(this, IDC_LISTVIEW_LIST, wxDefaultPosition, wxSize(645,195), wxLC_REPORT | wxLC_NO_HEADER);
+
+ topsizer->Add(list, 1, wxALL|wxEXPAND, 5);
+
+ topsizer->Add(CreateButtonSizer(wxOK|wxCANCEL), 0, wxALL|wxEXPAND, 5);
+
+ this->OnInit();
+
+ SetSizer(topsizer); // use the sizer for layout
+ topsizer->SetSizeHints(this); // set size hints to honour minimum size
+ }
+private:
+ // Any class wishing to process wxWindows events must use this macro
+ DECLARE_EVENT_TABLE()
+};
+
+REGISTER_DIALOG(IDD_DIALOG_LISTVIEW,CListViewDialog,0)
+
+BEGIN_EVENT_TABLE(CListViewDialogImpl, wxDialog)
+ EVT_BUTTON(wxID_ANY, CModalDialogImpl::OnAnyButton)
+ EVT_CHECKBOX(wxID_ANY, CModalDialogImpl::OnAnyButton)
+ EVT_MENU(WORKER_EVENT, CModalDialogImpl::OnWorkerEvent)
+END_EVENT_TABLE()
+
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/MessagesDialog.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/MessagesDialog.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/MessagesDialog.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/MessagesDialog.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,77 @@
+// MessagesDialog.cpp
+
+#include "StdAfx.h"
+
+#include "Common/IntToString.h"
+
+#include "Windows/ResourceString.h"
+
+#include "MessagesDialog.h"
+
+#ifdef LANG
+#include "LangUtils.h"
+#endif
+
+using namespace NWindows;
+
+#ifdef LANG
+static CIDLangPair kIDLangPairs[] =
+{
+ { IDOK, 0x02000713 }
+};
+#endif
+
+void CMessagesDialog::AddMessageDirect(LPCWSTR message)
+{
+ int itemIndex = _messageList.GetItemCount();
+ wchar_t sz[32];
+ ConvertInt64ToString(itemIndex, sz);
+ _messageList.InsertItem(itemIndex, sz);
+ _messageList.SetSubItem(itemIndex, 1, message);
+}
+
+void CMessagesDialog::AddMessage(LPCWSTR message)
+{
+ UString s = message;
+ while (!s.IsEmpty())
+ {
+ int pos = s.Find(L'\n');
+ if (pos < 0)
+ break;
+ AddMessageDirect(s.Left(pos));
+ s.Delete(0, pos + 1);
+ }
+ AddMessageDirect(s);
+}
+
+bool CMessagesDialog::OnInit()
+{
+ #ifdef LANG
+ LangSetWindowText(HWND(*this), 0x02000A00);
+ LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
+ #endif
+ _messageList.Attach(GetItem(IDC_MESSAGE_LIST));
+
+ #ifndef UNDER_CE
+ _messageList.SetUnicodeFormat(true);
+ #endif
+
+ _messageList.InsertColumn(0, L"", 30);
+
+ const UString s =
+ #ifdef LANG
+ LangString(IDS_MESSAGES_DIALOG_MESSAGE_COLUMN, 0x02000A80);
+ #else
+ MyLoadStringW(IDS_MESSAGES_DIALOG_MESSAGE_COLUMN);
+ #endif
+
+ _messageList.InsertColumn(1, s, 600);
+
+ for (int i = 0; i < Messages->Size(); i++)
+ AddMessage((*Messages)[i]);
+
+ _messageList.SetColumnWidthAuto(0);
+ _messageList.SetColumnWidthAuto(1);
+ NormalizeSize();
+ return CModalDialog::OnInit();
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/MessagesDialog.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/MessagesDialog.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/MessagesDialog.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/MessagesDialog.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,22 @@
+// MessagesDialog.h
+
+#ifndef __MESSAGES_DIALOG_H
+#define __MESSAGES_DIALOG_H
+
+#include "Windows/Control/Dialog.h"
+#include "Windows/Control/ListView.h"
+
+#include "MessagesDialogRes.h"
+
+class CMessagesDialog: public NWindows::NControl::CModalDialog
+{
+ NWindows::NControl::CListView _messageList;
+ void AddMessageDirect(LPCWSTR message);
+ void AddMessage(LPCWSTR message);
+ virtual bool OnInit();
+public:
+ const UStringVector *Messages;
+ INT_PTR Create(HWND parent = 0) { return CModalDialog::Create(IDD_DIALOG_MESSAGES, parent); }
+};
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/MessagesDialogRes.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/MessagesDialogRes.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/MessagesDialogRes.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/MessagesDialogRes.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,3 @@
+#define IDS_MESSAGES_DIALOG_MESSAGE_COLUMN 503
+#define IDD_DIALOG_MESSAGES 503
+#define IDC_MESSAGE_LIST 1000
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/MessagesDialog_rc.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/MessagesDialog_rc.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/MessagesDialog_rc.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/MessagesDialog_rc.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,89 @@
+// MessagesDialog_rc.cpp
+
+#include "StdAfx.h"
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+// for all others, include the necessary headers (this file is usually all you
+// need because it includes almost all "standard" wxWidgets headers)
+#ifndef WX_PRECOMP
+ #include "wx/wx.h"
+#endif
+
+#include <wx/listctrl.h>
+
+#undef _WIN32
+
+#include "Windows/Control/DialogImpl.h"
+#include "MessagesDialogRes.h"
+
+/*
+IDD_DIALOG_MESSAGES DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE
+CAPTION "7-Zip: Diagnostic messages"
+MY_FONT
+BEGIN
+ DEFPUSHBUTTON "&Close", IDOK, bXPos, bYPos, bXSize, bYSize
+ CONTROL "List1",IDC_MESSAGE_LIST,"SysListView32",
+ LVS_REPORT | LVS_SHOWSELALWAYS | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,
+ marg, marg, xSize2, ySize2 - bYSize - 6
+END
+
+STRINGTABLE
+BEGIN
+ IDS_MESSAGES_DIALOG_MESSAGE_COLUMN "Message"
+END
+*/
+
+class CMessagesDialogImpl : public NWindows::NControl::CModalDialogImpl
+{
+ public:
+ CMessagesDialogImpl(NWindows::NControl::CModalDialog *dialog,wxWindow * parent , int id) :
+ CModalDialogImpl(dialog,parent, id, wxT("7-Zip: Diagnostic messages"), wxDefaultPosition, wxDefaultSize,
+ wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX | wxMINIMIZE_BOX)
+ {
+ wxBoxSizer* topsizer = new wxBoxSizer(wxVERTICAL);
+
+
+ wxListCtrl *list = new wxListCtrl(this, IDC_MESSAGE_LIST, wxDefaultPosition, wxSize(645,195), wxLC_REPORT );
+
+#if 0
+ list->InsertColumn(0, wxT("Col1"), wxLIST_FORMAT_LEFT);
+ list->InsertColumn(1, wxT("Col2"), wxLIST_FORMAT_RIGHT);
+ list->InsertItem(0, wxT("#1"));
+ list->SetItem(0, 1, L"message 1");
+ list->InsertItem(1, wxT("#2"));
+ list->SetItem(1, 1, L"message 2");
+#endif
+ topsizer->Add(list , 1, wxALL|wxEXPAND, 5);
+
+
+ topsizer->Add(new wxButton(this, wxID_OK, _T("&Close")) , 0, wxALL | wxALIGN_RIGHT, 5);
+
+ this->OnInit();
+
+ SetSizer(topsizer); // use the sizer for layout
+ topsizer->SetSizeHints(this); // set size hints to honour minimum size
+ }
+private:
+ // Any class wishing to process wxWindows events must use this macro
+ DECLARE_EVENT_TABLE()
+};
+
+static CStringTable g_stringTable[] =
+{
+ { IDS_MESSAGES_DIALOG_MESSAGE_COLUMN, L"Message" },
+ { 0 , 0 }
+};
+
+REGISTER_DIALOG(IDD_DIALOG_MESSAGES,CMessagesDialog,g_stringTable)
+
+BEGIN_EVENT_TABLE(CMessagesDialogImpl, wxDialog)
+ EVT_BUTTON(wxID_ANY, CModalDialogImpl::OnAnyButton)
+ EVT_MENU(WORKER_EVENT, CModalDialogImpl::OnWorkerEvent)
+END_EVENT_TABLE()
+
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/MyLoadMenu.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/MyLoadMenu.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/MyLoadMenu.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/MyLoadMenu.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,765 @@
+// MyLoadMenu
+
+#include "StdAfx.h"
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx/wx.h"
+#endif
+
+#undef _WIN32
+
+#include <wx/aboutdlg.h>
+
+typedef wxMenuBar * HMENU;
+
+#include "Common/StringConvert.h"
+
+#include "Windows/Menu.h"
+#include "Windows/Error.h"
+// FIXME #include "Windows/Clipboard.h"
+
+#include "../../PropID.h"
+
+#include "resource.h"
+#include "App.h"
+// FIXME #include "AboutDialog.h"
+#include "../Common/CompressCall.h"
+
+#include "HelpUtils.h"
+#include "LangUtils.h"
+#include "PluginInterface.h"
+
+#include "../../MyVersion.h"
+
+static const UINT kOpenBookmarkMenuID = 730;
+static const UINT kSetBookmarkMenuID = 740;
+
+extern HINSTANCE g_hInstance;
+
+static LPCWSTR kFMHelpTopic = L"fm/index.htm";
+
+extern void OptionsDialog(HWND hwndOwner, HINSTANCE hInstance);
+
+using namespace NWindows;
+
+static const int kFileMenuIndex = 0;
+static const int kEditMenuIndex = 1;
+static const int kViewMenuIndex = 2;
+static const int kBookmarksMenuIndex = kViewMenuIndex + 1;
+
+struct CStringLangPair
+{
+ wchar_t *String;
+ UINT32 LangID;
+};
+
+static CStringLangPair kStringLangPairs[] =
+{
+ { L"&File", 0x03000102 },
+ { L"&Edit", 0x03000103 },
+ { L"&View", 0x03000104 },
+ { L"&Bookmarks", 0x03000107 },
+ { L"&Tools", 0x03000105 },
+ { L"&Help", 0x03000106 },
+};
+
+UINT32 kAddToFavoritesLangID = 0x03000710;
+UINT32 kToolbarsLangID = 0x03000451;
+
+/*
+static int FindStringLangItem(const UString &anItem)
+{
+ for (int i = 0; i < sizeof(kStringLangPairs) /
+ sizeof(kStringLangPairs[0]); i++)
+ if (anItem.CompareNoCase(kStringLangPairs[i].String) == 0)
+ return i;
+ return -1;
+}
+*/
+
+static CIDLangPair kIDLangPairs[] =
+{
+ // File
+ { IDM_FILE_OPEN, 0x03000210 },
+ { IDM_FILE_OPEN_INSIDE, 0x03000211 },
+ { IDM_FILE_OPEN_OUTSIDE, 0x03000212 },
+ // { IDM_FILE_VIEW, 0x03000220 }, // FIXME : does not exist !
+ { IDM_FILE_EDIT, 0x03000221 },
+ { IDM_RENAME, 0x03000230 },
+ { IDM_COPY_TO, 0x03000231 },
+ { IDM_MOVE_TO, 0x03000232 },
+ { IDM_DELETE, 0x03000233 },
+ { IDM_FILE_PROPERTIES, 0x03000240 },
+ { IDM_FILE_COMMENT, 0x03000241 },
+ { IDM_FILE_CRC, 0x03000242 },
+ { IDM_FILE_DIFF, 0x03000243 },
+ { IDM_FILE_SPLIT, 0x03000270 },
+ { IDM_FILE_COMBINE, 0x03000271 },
+ { IDM_CREATE_FOLDER, 0x03000250 },
+ { IDM_CREATE_FILE, 0x03000251 },
+ // FIXME { IDCLOSE, 0x03000260 },
+
+ // Edit
+ { IDM_EDIT_CUT, 0x03000320 },
+ { IDM_EDIT_COPY, 0x03000321 },
+ { IDM_EDIT_PASTE, 0x03000322 },
+
+ { IDM_SELECT_ALL, 0x03000330 },
+ { IDM_DESELECT_ALL, 0x03000331 },
+ { IDM_INVERT_SELECTION, 0x03000332 },
+ { IDM_SELECT, 0x03000333 },
+ { IDM_DESELECT, 0x03000334 },
+ { IDM_SELECT_BY_TYPE, 0x03000335 },
+ { IDM_DESELECT_BY_TYPE, 0x03000336 },
+
+ { IDM_VIEW_LARGE_ICONS, 0x03000410 },
+ { IDM_VIEW_SMALL_ICONS, 0x03000411 },
+ { IDM_VIEW_LIST, 0x03000412 },
+ { IDM_VIEW_DETAILS, 0x03000413 },
+
+ { IDM_VIEW_ARANGE_BY_NAME, 0x02000204 },
+ { IDM_VIEW_ARANGE_BY_TYPE, 0x02000214 },
+ { IDM_VIEW_ARANGE_BY_DATE, 0x0200020C },
+ { IDM_VIEW_ARANGE_BY_SIZE, 0x02000207 },
+ { IDM_VIEW_ARANGE_NO_SORT, 0x03000420 },
+
+ { IDM_OPEN_ROOT_FOLDER, 0x03000430 },
+ { IDM_OPEN_PARENT_FOLDER, 0x03000431 },
+ { IDM_FOLDERS_HISTORY, 0x03000432 },
+
+ { IDM_VIEW_REFRESH, 0x03000440 },
+
+ { IDM_VIEW_FLAT_VIEW, 0x03000449 },
+ { IDM_VIEW_TWO_PANELS, 0x03000450 },
+ { IDM_VIEW_ARCHIVE_TOOLBAR, 0x03000460 },
+ { IDM_VIEW_STANDARD_TOOLBAR, 0x03000461 },
+ { IDM_VIEW_TOOLBARS_LARGE_BUTTONS, 0x03000462 },
+ { IDM_VIEW_TOOLBARS_SHOW_BUTTONS_TEXT, 0x03000463 },
+
+ { IDM_OPTIONS, 0x03000510 },
+ { IDM_BENCHMARK, 0x03000511 },
+
+ { IDM_HELP_CONTENTS, 0x03000610 },
+ { IDM_ABOUT, 0x03000620 },
+
+ { 12111 , 0x03000710 }, // FIXME kAddToFavoritesLangID
+ { 12112 , 0x03000451 } // FIXME kToolbarsLangID
+};
+
+
+#ifdef _WIN32
+static int FindLangItem(int ControlID)
+{
+ for (int i = 0; i < sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]); i++)
+ if (kIDLangPairs[i].ControlID == ControlID)
+ return i;
+ return -1;
+}
+#endif
+
+
+/*
+static bool g_IsNew_fMask = true;
+
+class CInit_fMask
+{
+public:
+ CInit_fMask()
+ {
+ g_IsNew_fMask = false;
+ OSVERSIONINFO vi;
+ vi.dwOSVersionInfoSize = sizeof(vi);
+ if (::GetVersionEx(&vi))
+ {
+ g_IsNew_fMask = (vi.dwMajorVersion > 4 ||
+ (vi.dwMajorVersion == 4 && vi.dwMinorVersion > 0));
+ }
+ g_IsNew_fMask = false;
+ }
+} g_Init_fMask;
+
+// it's hack for supporting Windows NT
+// constants are from WinUser.h
+
+#if(WINVER < 0x0500)
+#define MIIM_STRING 0x00000040
+#define MIIM_BITMAP 0x00000080
+#define MIIM_FTYPE 0x00000100
+#endif
+
+static UINT Get_fMaskForString()
+{
+ return g_IsNew_fMask ? MIIM_STRING : MIIM_TYPE;
+}
+
+static UINT Get_fMaskForFTypeAndString()
+{
+ return g_IsNew_fMask ? (MIIM_STRING | MIIM_FTYPE) : MIIM_TYPE;
+}
+*/
+
+#ifdef _WIN32
+static UINT Get_fMaskForString()
+{
+ return MIIM_TYPE;
+}
+
+static UINT Get_fMaskForFTypeAndString()
+{
+ return MIIM_TYPE;
+}
+#endif
+
+
+static void MyChangeItem(wxMenuItem * mi,int LangID)
+{
+ UString newString = LangString(LangID);
+ if (newString.IsEmpty())
+ return;
+ wxString ss = mi->GetItemLabel();
+ UString shorcutString((const wchar_t *)ss); // = item.StringValue;
+ int tabPos = shorcutString.ReverseFind(wchar_t('\t'));
+ if (tabPos >= 0)
+ newString += shorcutString.Mid(tabPos);
+ // printf("Change Menu : %ls => %ls\n",(const wchar_t *)ss,(const wchar_t *)newString);
+ mi->SetItemLabel((const wchar_t *)newString);
+
+}
+
+static void MyChangeMenu(HMENU menuLoc, int level, int menuIndex)
+{
+ // Sets the label of the top-level menus
+ for (int i1= 0; i1< sizeof(kStringLangPairs) / sizeof(kStringLangPairs[0]); i1++)
+ {
+ UString newString = LangString(kStringLangPairs[i1].LangID);
+ if (! newString.IsEmpty()) menuLoc->SetMenuLabel(i1, (const TCHAR *)newString);
+ }
+
+ // sub-menu items
+ for (int i = 0; i < sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]); i++)
+ {
+ wxMenuItem * mi = menuLoc->FindItem(kIDLangPairs[i].ControlID);
+ if (mi)
+ {
+ MyChangeItem(mi,kIDLangPairs[i].LangID);
+ }
+// else
+// printf("Change Menu : id=%d index=%d<>\n",kIDLangPairs[i].ControlID,i);
+ }
+}
+
+#ifdef _WIN32
+CMenu g_FileMenu;
+
+class CFileMenuDestroyer
+{
+public:
+ ~CFileMenuDestroyer()
+ {
+ if ((HMENU)g_FileMenu != 0)
+ g_FileMenu.Destroy();
+ }
+} g_FileMenuDestroyer;
+#endif
+
+
+void MyLoadMenu(HWND hWnd)
+{
+#ifdef _WIN32
+ if ((HMENU)g_FileMenu != 0)
+ g_FileMenu.Destroy();
+ HMENU oldMenu = ::GetMenu(hWnd);
+ HMENU baseMenu = ::LoadMenu(g_hInstance, MAKEINTRESOURCE(IDM_MENU));
+ ::SetMenu(hWnd, baseMenu);
+ ::DestroyMenu(oldMenu);
+ if (!g_LangID.IsEmpty())
+ {
+ HMENU menuOld = ::GetMenu(hWnd);
+ MyChangeMenu(menuOld, 0, 0);
+ }
+ ::DrawMenuBar(hWnd);
+#else
+ extern void rc_MyLoadMenu(HWND hWnd);
+ rc_MyLoadMenu(hWnd);
+ if (!g_LangID.IsEmpty())
+ {
+ HMENU menuOld = ((wxFrame *)hWnd)->GetMenuBar(); // ::GetMenu(hWnd);
+ MyChangeMenu(menuOld, 0, 0);
+ }
+#endif
+}
+
+#ifdef _WIN32
+extern HWND g_HWND;
+void MyLoadMenu()
+{
+ MyLoadMenu(g_HWND);
+}
+
+static void CopyMenu(HMENU srcMenuSpec, HMENU destMenuSpec)
+{
+ CMenu srcMenu;
+ srcMenu.Attach(srcMenuSpec);
+ CMenu destMenu;
+ destMenu.Attach(destMenuSpec);
+ int startPos = 0;
+ for (int i = 0; i < srcMenu.GetItemCount(); i++)
+ {
+ CMenuItem item;
+ item.fMask = MIIM_STATE | MIIM_ID | Get_fMaskForFTypeAndString();
+ item.fType = MFT_STRING;
+ if (srcMenu.GetItem(i, true, item))
+ if (destMenu.InsertItem(startPos, true, item))
+ startPos++;
+ }
+}
+
+void OnMenuActivating(HWND /* hWnd */, HMENU hMenu, int position)
+{
+ if (::GetSubMenu(::GetMenu(g_HWND), position) != hMenu)
+ return;
+ if (position == kFileMenuIndex)
+ {
+ if ((HMENU)g_FileMenu == 0)
+ {
+ g_FileMenu.CreatePopup();
+ CopyMenu(hMenu, g_FileMenu);
+ }
+ CMenu menu;
+ menu.Attach(hMenu);
+ while (menu.GetItemCount() > 0)
+ {
+ if (!menu.RemoveItem(0, MF_BYPOSITION))
+ break;
+ }
+ // CopyMenu(g_FileMenu, hMenu);
+ g_App.GetFocusedPanel().CreateFileMenu(hMenu);
+ }
+ else if (position == kEditMenuIndex)
+ {
+ /*
+ CMenu menu;
+ menu.Attach(hMenu);
+ menu.EnableItem(IDM_EDIT_CUT, MF_ENABLED);
+ menu.EnableItem(IDM_EDIT_COPY, MF_ENABLED);
+ menu.EnableItem(IDM_EDIT_PASTE, IsClipboardFormatAvailableHDROP() ? MF_ENABLED : MF_GRAYED);
+ */
+ }
+ else if (position == kViewMenuIndex)
+ {
+ // View;
+ CMenu menu;
+ menu.Attach(hMenu);
+ menu.CheckRadioItem(IDM_VIEW_LARGE_ICONS, IDM_VIEW_DETAILS,
+ IDM_VIEW_LARGE_ICONS + g_App.GetListViewMode(), MF_BYCOMMAND);
+ menu.CheckItem(IDM_VIEW_TWO_PANELS, MF_BYCOMMAND |
+ ((g_App.NumPanels == 2) ? MF_CHECKED : MF_UNCHECKED));
+ menu.CheckItem(IDM_VIEW_FLAT_VIEW, MF_BYCOMMAND |
+ ((g_App.GetFlatMode()) ? MF_CHECKED : MF_UNCHECKED));
+ menu.CheckItem(IDM_VIEW_ARCHIVE_TOOLBAR, MF_BYCOMMAND |
+ (g_App.ShowArchiveToolbar ? MF_CHECKED : MF_UNCHECKED));
+ menu.CheckItem(IDM_VIEW_STANDARD_TOOLBAR, MF_BYCOMMAND |
+ (g_App.ShowStandardToolbar ? MF_CHECKED : MF_UNCHECKED));
+ menu.CheckItem(IDM_VIEW_TOOLBARS_LARGE_BUTTONS, MF_BYCOMMAND |
+ (g_App.LargeButtons ? MF_CHECKED : MF_UNCHECKED));
+ menu.CheckItem(IDM_VIEW_TOOLBARS_SHOW_BUTTONS_TEXT, MF_BYCOMMAND |
+ (g_App.ShowButtonsLables ? MF_CHECKED : MF_UNCHECKED));
+ }
+ else if (position == kBookmarksMenuIndex)
+ {
+ CMenu menu;
+ menu.Attach(hMenu);
+
+ CMenu subMenu;
+ subMenu.Attach(menu.GetSubMenu(0));
+ while (subMenu.GetItemCount() > 0)
+ subMenu.RemoveItem(subMenu.GetItemCount() - 1, MF_BYPOSITION);
+ int i;
+ for (i = 0; i < 10; i++)
+ {
+ UString s = LangString(IDS_BOOKMARK, 0x03000720);
+ s += L" ";
+ wchar_t c = (wchar_t)(L'0' + i);
+ s += c;
+ s += L"\tAlt+Shift+";
+ s += c;
+ subMenu.AppendItem(MF_STRING, kSetBookmarkMenuID + i, s);
+ }
+
+ while (menu.GetItemCount() > 2)
+ menu.RemoveItem(menu.GetItemCount() - 1, MF_BYPOSITION);
+
+ for (i = 0; i < 10; i++)
+ {
+ UString path = g_App.AppState.FastFolders.GetString(i);
+ const int kMaxSize = 100;
+ const int kFirstPartSize = kMaxSize / 2;
+ if (path.Length() > kMaxSize)
+ {
+ path = path.Left(kFirstPartSize) + UString(L" ... ") +
+ path.Right(kMaxSize - kFirstPartSize);
+ }
+ UString s = path;
+ if (s.IsEmpty())
+ s = L"-";
+ s += L"\tAlt+";
+ s += (wchar_t)(L'0' + i);
+ menu.AppendItem(MF_STRING, kOpenBookmarkMenuID + i, s);
+ }
+ }
+}
+
+/*
+It doesn't help
+void OnMenuUnActivating(HWND hWnd, HMENU hMenu, int id)
+{
+ if (::GetSubMenu(::GetMenu(g_HWND), 0) != hMenu)
+ return;
+ // g_App.GetFocusedPanel()._contextMenu.Release();
+}
+
+void OnMenuUnActivating(HWND hWnd)
+{
+}
+*/
+
+
+void LoadFileMenu(HMENU hMenu, int startPos, bool /* forFileMode */, bool programMenu)
+{
+ {
+ CMenu srcMenu;
+ srcMenu.Attach(::GetSubMenu(::GetMenu(g_HWND), 0));
+ if ((HMENU)g_FileMenu == 0)
+ {
+ g_FileMenu.CreatePopup();
+ CopyMenu(srcMenu, g_FileMenu);
+ }
+ }
+
+ CMenu destMenu;
+ destMenu.Attach(hMenu);
+
+ for (int i = 0; i < g_FileMenu.GetItemCount(); i++)
+ {
+ CMenuItem item;
+
+ item.fMask = MIIM_STATE | MIIM_ID | Get_fMaskForFTypeAndString();
+ item.fType = MFT_STRING;
+ if (g_FileMenu.GetItem(i, true, item))
+ {
+ if (!programMenu)
+ if (item.wID == IDCLOSE)
+ continue;
+ /*
+ bool createItem = (item.wID == IDM_CREATE_FOLDER || item.wID == IDM_CREATE_FILE);
+ if (forFileMode)
+ {
+ if (createItem)
+ continue;
+ }
+ else
+ {
+ if (!createItem)
+ continue;
+ }
+ */
+ if (destMenu.InsertItem(startPos, true, item))
+ startPos++;
+ }
+ }
+ while (destMenu.GetItemCount() > 0)
+ {
+ CMenuItem item;
+ item.fMask = MIIM_TYPE;
+ item.fType = 0;
+ // item.dwTypeData = 0;
+ int lastIndex = destMenu.GetItemCount() - 1;
+ if (!destMenu.GetItem(lastIndex, true, item))
+ break;
+ if(item.fType != MFT_SEPARATOR)
+ break;
+ if (!destMenu.RemoveItem(lastIndex, MF_BYPOSITION))
+ break;
+ }
+}
+#endif
+
+bool ExecuteFileCommand(int id)
+{
+ if (id >= kPluginMenuStartID)
+ {
+#ifdef _WIN32
+ g_App.GetFocusedPanel().InvokePluginCommand(id);
+ g_App.GetFocusedPanel()._sevenZipContextMenu.Release();
+ g_App.GetFocusedPanel()._systemContextMenu.Release();
+#endif
+ return true;
+ }
+
+ switch (id)
+ {
+ // File
+ case IDM_FILE_OPEN:
+ g_App.OpenItem();
+ break;
+ case IDM_FILE_OPEN_INSIDE:
+ g_App.OpenItemInside();
+ break;
+ case IDM_FILE_OPEN_OUTSIDE:
+ g_App.OpenItemOutside();
+ break;
+ case IDM_FILE_VIEW:
+ break;
+ case IDM_FILE_EDIT:
+ g_App.EditItem();
+ break;
+ case IDM_RENAME:
+ g_App.Rename();
+ break;
+ case IDM_COPY_TO:
+ g_App.CopyTo();
+ break;
+ case IDM_MOVE_TO:
+ g_App.MoveTo();
+ break;
+ case IDM_DELETE:
+ {
+#ifdef _WIN32 // FIXME
+ bool shift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0;
+ g_App.Delete(!shift);
+#else
+ g_App.Delete(true);
+#endif
+ break;
+ }
+ case IDM_FILE_CRC:
+ g_App.CalculateCrc();
+ break;
+ case IDM_FILE_DIFF:
+ g_App.DiffFiles();
+ break;
+ case IDM_FILE_SPLIT:
+ g_App.Split();
+ break;
+ case IDM_FILE_COMBINE:
+ g_App.Combine();
+ break;
+ case IDM_FILE_PROPERTIES:
+ g_App.Properties();
+ break;
+ case IDM_FILE_COMMENT:
+ g_App.Comment();
+ break;
+
+ case IDM_CREATE_FOLDER:
+ g_App.CreateFolder();
+ break;
+ case IDM_CREATE_FILE:
+ g_App.CreateFile();
+ break;
+ default:
+ return false;
+ }
+ return true;
+}
+
+void createAboutDialog(void)
+{
+ wxAboutDialogInfo info;
+
+ UString msg;
+
+ msg = LangString(0x01000103); // IDC_ABOUT_STATIC_REGISTER_INFO
+ if (msg == L"") msg = L"7-Zip is free software. However, you can support development of 7-Zip by registering.";
+ info.SetDescription((const wchar_t *)msg);
+
+
+ info.SetName(_("P7ZIP"));
+ info.SetVersion(wxString(MY_7ZIP_VERSION, wxConvUTF8));
+ info.SetCopyright(wxString(MY_COPYRIGHT, wxConvUTF8));
+ info.SetWebSite(_T("www.7-zip.org"));
+
+ wxAboutBox(info);
+}
+
+bool OnMenuCommand(HWND hWnd, int id)
+{
+ printf("DEBUG : OnMenuCommand(%p,id=%d)-0\n",hWnd,id);
+
+ if (ExecuteFileCommand(id))
+ return true;
+
+ printf("DEBUG : OnMenuCommand(%p,id=%d)-1\n",hWnd,id);
+
+ switch (id)
+ {
+ // File
+ case IDCLOSE:
+ /* FIXME
+ SendMessage(hWnd, WM_ACTIVATE, MAKEWPARAM(WA_INACTIVE, 0), (LPARAM)hWnd);
+ SendMessage (hWnd, WM_CLOSE, 0, 0);
+ */
+ hWnd->Close(true);
+ break;
+
+ // Edit
+ case IDM_EDIT_CUT:
+ g_App.EditCut();
+ break;
+ case IDM_EDIT_COPY:
+ g_App.EditCopy();
+ break;
+ case IDM_EDIT_PASTE:
+ g_App.EditPaste();
+ break;
+ case IDM_SELECT_ALL:
+ g_App.SelectAll(true);
+ g_App.RefreshStatusBar();
+ break;
+ case IDM_DESELECT_ALL:
+ g_App.SelectAll(false);
+ g_App.RefreshStatusBar();
+ break;
+ case IDM_INVERT_SELECTION:
+ g_App.InvertSelection();
+ g_App.RefreshStatusBar();
+ break;
+ case IDM_SELECT:
+ g_App.SelectSpec(true);
+ g_App.RefreshStatusBar();
+ break;
+ case IDM_DESELECT:
+ g_App.SelectSpec(false);
+ g_App.RefreshStatusBar();
+ break;
+ case IDM_SELECT_BY_TYPE:
+ g_App.SelectByType(true);
+ g_App.RefreshStatusBar();
+ break;
+ case IDM_DESELECT_BY_TYPE:
+ g_App.SelectByType(false);
+ g_App.RefreshStatusBar();
+ break;
+
+ //View
+ case IDM_VIEW_LARGE_ICONS:
+ case IDM_VIEW_SMALL_ICONS:
+ case IDM_VIEW_LIST:
+ case IDM_VIEW_DETAILS:
+ {
+ UINT index = id - IDM_VIEW_LARGE_ICONS;
+ if (index < 4)
+ {
+ g_App.SetListViewMode(index);
+ /*
+ CMenu menu;
+ menu.Attach(::GetSubMenu(::GetMenu(hWnd), kViewMenuIndex));
+ menu.CheckRadioItem(IDM_VIEW_LARGE_ICONS, IDM_VIEW_DETAILS,
+ id, MF_BYCOMMAND);
+ */
+ }
+ break;
+ }
+ case IDM_VIEW_ARANGE_BY_NAME:
+ {
+ g_App.SortItemsWithPropID(kpidName);
+ break;
+ }
+ case IDM_VIEW_ARANGE_BY_TYPE:
+ {
+ g_App.SortItemsWithPropID(kpidExtension);
+ break;
+ }
+ case IDM_VIEW_ARANGE_BY_DATE:
+ {
+ g_App.SortItemsWithPropID(kpidMTime);
+ break;
+ }
+ case IDM_VIEW_ARANGE_BY_SIZE:
+ {
+ g_App.SortItemsWithPropID(kpidSize);
+ break;
+ }
+ case IDM_VIEW_ARANGE_NO_SORT:
+ {
+ g_App.SortItemsWithPropID(kpidNoProperty);
+ break;
+ }
+
+ case IDM_OPEN_ROOT_FOLDER:
+ g_App.OpenRootFolder();
+ break;
+ case IDM_OPEN_PARENT_FOLDER:
+ g_App.OpenParentFolder();
+ break;
+ case IDM_FOLDERS_HISTORY:
+ g_App.FoldersHistory();
+ break;
+ case IDM_VIEW_REFRESH:
+ g_App.RefreshView();
+ break;
+ case IDM_VIEW_FLAT_VIEW:
+ g_App.ChangeFlatMode();
+ break;
+ case IDM_VIEW_TWO_PANELS:
+ g_App.SwitchOnOffOnePanel();
+ break;
+ case IDM_VIEW_STANDARD_TOOLBAR:
+ g_App.SwitchStandardToolbar();
+ break;
+ case IDM_VIEW_ARCHIVE_TOOLBAR:
+ g_App.SwitchArchiveToolbar();
+ break;
+ case IDM_VIEW_TOOLBARS_SHOW_BUTTONS_TEXT:
+ g_App.SwitchButtonsLables();
+ break;
+ case IDM_VIEW_TOOLBARS_LARGE_BUTTONS:
+ g_App.SwitchLargeButtons();
+ break;
+
+ // Tools
+ case IDM_OPTIONS:
+ // FIXME OptionsDialog(hWnd, g_hInstance);
+ break;
+
+ case IDM_BENCHMARK:
+ Benchmark();
+ break;
+ // Help
+ case IDM_HELP_CONTENTS:
+ ShowHelpWindow(NULL, kFMHelpTopic);
+ break;
+ case IDM_ABOUT:
+ {
+ /* FIXME
+ CAboutDialog dialog;
+ dialog.Create(hWnd);
+ */
+ createAboutDialog();
+ break;
+ }
+ default:
+ {
+ if (id >= kOpenBookmarkMenuID && id <= kOpenBookmarkMenuID + 9)
+ {
+ g_App.OpenBookmark(id - kOpenBookmarkMenuID);
+ return true;
+ }
+ else if (id >= kSetBookmarkMenuID && id <= kSetBookmarkMenuID + 9)
+ {
+ g_App.SetBookmark(id - kSetBookmarkMenuID);
+ return true;
+ }
+ return false;
+ }
+ }
+ return true;
+}
+
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/MyLoadMenu.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/MyLoadMenu.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/MyLoadMenu.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/MyLoadMenu.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,20 @@
+// MyLoadMenu.h
+
+#ifndef __MYLOADMENU_H
+#define __MYLOADMENU_H
+
+class myHMENU; // FIXME
+typedef myHMENU * HMENU; // FIXME
+
+void OnMenuActivating(HWND hWnd, HMENU hMenu, int position);
+// void OnMenuUnActivating(HWND hWnd, HMENU hMenu, int id);
+// void OnMenuUnActivating(HWND hWnd);
+
+void MyLoadMenu(HWND hWnd);
+bool OnMenuCommand(HWND hWnd, int id);
+void MyLoadMenu();
+void LoadFileMenu(HMENU hMenu, int startPos, bool programMenu,
+ bool isFsFolder, int numItems, bool allAreFiles);
+bool ExecuteFileCommand(int id);
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/NetFolder.h.OUT
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/NetFolder.h.OUT?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/NetFolder.h.OUT (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/NetFolder.h.OUT Sun Dec 16 23:23:25 2012
@@ -0,0 +1,56 @@
+// NetFolder.h
+
+#ifndef __NETFOLDER_H
+#define __NETFOLDER_H
+
+#include "Common/MyString.h"
+#include "Common/Buffer.h"
+#include "Common/MyCom.h"
+#include "Windows/PropVariant.h"
+// FIXME #include "Windows/Net.h"
+
+#include "IFolder.h"
+
+struct CResourceEx // FIXME : public NWindows::NNet::CResourceW
+{
+ UString Name;
+};
+
+class CNetFolder:
+ public IFolderFolder,
+ public IFolderGetSystemIconIndex,
+ public CMyUnknownImp
+{
+public:
+ MY_UNKNOWN_IMP1(
+ IFolderGetSystemIconIndex
+ )
+
+ INTERFACE_FolderFolder(;)
+
+ STDMETHOD(GetSystemIconIndex)(UInt32 index, INT32 *iconIndex);
+
+private:
+#ifdef _WIN32
+ NWindows::NNet::CResourceW _netResource;
+ NWindows::NNet::CResourceW *_netResourcePointer;
+#else
+ int _netResource;
+ int *_netResourcePointer;
+#endif
+
+ CObjectVector<CResourceEx> _items;
+
+ CMyComPtr<IFolderFolder> _parentFolder;
+ UString _path;
+
+public:
+ void Init(const UString &path);
+#ifdef _WIN32
+ void Init(const NWindows::NNet::CResourceW *netResource,
+ IFolderFolder *parentFolder, const UString &path);
+ CNetFolder(): _netResourcePointer(0) {}
+#endif
+};
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/OpenCallback.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/OpenCallback.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/OpenCallback.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/OpenCallback.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,123 @@
+// OpenCallback.cpp
+
+#include "StdAfx.h"
+
+#include "Common/StringConvert.h"
+
+#include "Windows/PropVariant.h"
+
+#include "../../Common/FileStreams.h"
+
+#include "OpenCallback.h"
+#include "PasswordDialog.h"
+
+using namespace NWindows;
+
+STDMETHODIMP COpenArchiveCallback::SetTotal(const UInt64 *numFiles, const UInt64 *numBytes)
+{
+ RINOK(ProgressDialog.Sync.ProcessStopAndPause());
+ {
+ NSynchronization::CCriticalSectionLock lock(_criticalSection);
+ if (numFiles != NULL)
+ {
+ ProgressDialog.Sync.SetNumFilesTotal(*numFiles);
+ ProgressDialog.Sync.SetBytesProgressMode(false);
+ }
+ if (numBytes != NULL)
+ ProgressDialog.Sync.SetNumBytesTotal(*numBytes);
+ }
+ return S_OK;
+}
+
+STDMETHODIMP COpenArchiveCallback::SetCompleted(const UInt64 *numFiles, const UInt64 *numBytes)
+{
+ RINOK(ProgressDialog.Sync.ProcessStopAndPause());
+ NSynchronization::CCriticalSectionLock lock(_criticalSection);
+ if (numFiles != NULL)
+ ProgressDialog.Sync.SetNumFilesCur(*numFiles);
+ if (numBytes != NULL)
+ ProgressDialog.Sync.SetPos(*numBytes);
+ return S_OK;
+}
+
+STDMETHODIMP COpenArchiveCallback::SetTotal(const UInt64 total)
+{
+ RINOK(ProgressDialog.Sync.ProcessStopAndPause());
+ ProgressDialog.Sync.SetNumBytesTotal(total);
+ return S_OK;
+}
+
+STDMETHODIMP COpenArchiveCallback::SetCompleted(const UInt64 *completed)
+{
+ RINOK(ProgressDialog.Sync.ProcessStopAndPause());
+ if (completed != NULL)
+ ProgressDialog.Sync.SetPos(*completed);
+ return S_OK;
+}
+
+STDMETHODIMP COpenArchiveCallback::GetProperty(PROPID propID, PROPVARIANT *value)
+{
+ NCOM::CPropVariant prop;
+ if (_subArchiveMode)
+ {
+ switch(propID)
+ {
+ case kpidName: prop = _subArchiveName; break;
+ }
+ }
+ else
+ {
+ switch(propID)
+ {
+ case kpidName: prop = _fileInfo.Name; break;
+ case kpidIsDir: prop = _fileInfo.IsDir(); break;
+ case kpidSize: prop = _fileInfo.Size; break;
+ case kpidAttrib: prop = (UInt32)_fileInfo.Attrib; break;
+ case kpidCTime: prop = _fileInfo.CTime; break;
+ case kpidATime: prop = _fileInfo.ATime; break;
+ case kpidMTime: prop = _fileInfo.MTime; break;
+ }
+ }
+ prop.Detach(value);
+ return S_OK;
+}
+
+STDMETHODIMP COpenArchiveCallback::GetStream(const wchar_t *name,
+ IInStream **inStream)
+{
+ *inStream = NULL;
+ if (_subArchiveMode)
+ return S_FALSE;
+
+ NFile::NFind::CFileInfoW fileInfo;
+
+ UString fullPath = _folderPrefix + name;
+ if (!fileInfo.Find(fullPath))
+ return S_FALSE;
+ _fileInfo = fileInfo;
+ if (_fileInfo.IsDir())
+ return S_FALSE;
+ CInFileStream *inFile = new CInFileStream;
+ CMyComPtr<IInStream> inStreamTemp = inFile;
+ if (!inFile->Open(fullPath))
+ return ::GetLastError();
+ *inStream = inStreamTemp.Detach();
+ return S_OK;
+}
+
+STDMETHODIMP COpenArchiveCallback::CryptoGetTextPassword(BSTR *password)
+{
+ PasswordWasAsked = true;
+ if (!PasswordIsDefined)
+ {
+ CPasswordDialog dialog;
+
+ ProgressDialog.WaitCreating();
+ if (dialog.Create(ProgressDialog) == IDCANCEL)
+ return E_ABORT;
+
+ Password = dialog.Password;
+ PasswordIsDefined = true;
+ }
+ return StringToBstr(Password, password);
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/OpenCallback.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/OpenCallback.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/OpenCallback.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/OpenCallback.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,92 @@
+// OpenCallback.h
+
+#ifndef __OPENCALLBACK_H
+#define __OPENCALLBACK_H
+
+#include "Common/MyCom.h"
+#include "Common/MyString.h"
+
+#include "Windows/FileFind.h"
+
+#include "../../IPassword.h"
+
+#include "../../Archive/IArchive.h"
+
+#ifdef _SFX
+#include "ProgressDialog.h"
+#else
+#include "ProgressDialog2.h"
+#endif
+
+
+class COpenArchiveCallback:
+ public IArchiveOpenCallback,
+ public IArchiveOpenVolumeCallback,
+ public IArchiveOpenSetSubArchiveName,
+ public IProgress,
+ public ICryptoGetTextPassword,
+ public CMyUnknownImp
+{
+ UString _folderPrefix;
+ NWindows::NFile::NFind::CFileInfoW _fileInfo;
+ NWindows::NSynchronization::CCriticalSection _criticalSection;
+ bool _subArchiveMode;
+ UString _subArchiveName;
+
+public:
+ bool PasswordIsDefined;
+ bool PasswordWasAsked;
+ UString Password;
+ HWND ParentWindow;
+ CProgressDialog ProgressDialog;
+
+ MY_UNKNOWN_IMP5(
+ IArchiveOpenCallback,
+ IArchiveOpenVolumeCallback,
+ IArchiveOpenSetSubArchiveName,
+ IProgress,
+ ICryptoGetTextPassword)
+
+ INTERFACE_IProgress(;)
+ INTERFACE_IArchiveOpenCallback(;)
+ INTERFACE_IArchiveOpenVolumeCallback(;)
+
+ // ICryptoGetTextPassword
+ STDMETHOD(CryptoGetTextPassword)(BSTR *password);
+
+ STDMETHOD(SetSubArchiveName(const wchar_t *name))
+ {
+ _subArchiveMode = true;
+ _subArchiveName = name;
+ return S_OK;
+ }
+
+ COpenArchiveCallback():
+ ParentWindow(0)
+ {
+ _subArchiveMode = false;
+ PasswordIsDefined = false;
+ PasswordWasAsked = false;
+ }
+ /*
+ void Init()
+ {
+ PasswordIsDefined = false;
+ _subArchiveMode = false;
+ }
+ */
+ void LoadFileInfo(const UString &folderPrefix, const UString &fileName)
+ {
+ _folderPrefix = folderPrefix;
+ if (!_fileInfo.Find(_folderPrefix + fileName))
+ throw 1;
+ }
+ void ShowMessage(const UInt64 *completed);
+
+ INT_PTR StartProgressDialog(const UString &title, NWindows::CThread &thread)
+ {
+ return ProgressDialog.Create(title, thread, ParentWindow);
+ }
+};
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/OverwriteDialog.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/OverwriteDialog.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/OverwriteDialog.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/OverwriteDialog.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,139 @@
+// OverwriteDialog.cpp
+
+#include "StdAfx.h"
+
+#include "Common/StringConvert.h"
+
+#include "Windows/FileName.h"
+#include "Windows/Defs.h"
+#include "Windows/ResourceString.h"
+#include "Windows/Control/Static.h"
+#include "Windows/PropVariantConversions.h"
+
+#include "FormatUtils.h"
+#include "OverwriteDialog.h"
+
+// #include "../resource.h"
+
+#ifdef LANG
+#include "LangUtils.h"
+#endif
+
+using namespace NWindows;
+
+#ifdef LANG
+static CIDLangPair kIDLangPairs[] =
+{
+ { IDC_STATIC_OVERWRITE_HEADER, 0x02000901},
+ { IDC_STATIC_OVERWRITE_QUESTION_BEGIN, 0x02000902 },
+ { IDC_STATIC_OVERWRITE_QUESTION_END, 0x02000903 },
+ { IDYES, 0x02000705 },
+ { IDC_BUTTON_OVERWRITE_YES_TO_ALL, 0x02000707 },
+ { IDNO, 0x02000709 },
+ { IDC_BUTTON_OVERWRITE_NO_TO_ALL,0x0200070B },
+ { IDC_BUTTON_OVERWRITE_AUTO_RENAME, 0x02000911 },
+ { IDCANCEL, 0x02000711 }
+};
+#endif
+
+static const int kCurrentFileNameSizeLimit = 82;
+static const int kCurrentFileNameSizeLimit2 = 30;
+
+void COverwriteDialog::ReduceString(UString &s)
+{
+ int size = _isBig ? kCurrentFileNameSizeLimit : kCurrentFileNameSizeLimit2;
+ if (s.Length() > size)
+ s = s.Left(size / 2) + UString(L" ... ") + s.Right(size / 2);
+}
+
+void COverwriteDialog::SetFileInfoControl(int textID, int iconID,
+ const NOverwriteDialog::CFileInfo &fileInfo)
+{
+ UString sizeString;
+ if (fileInfo.SizeIsDefined)
+ sizeString = MyFormatNew(IDS_FILE_SIZE,
+ #ifdef LANG
+ 0x02000982,
+ #endif
+ NumberToString(fileInfo.Size));
+
+ const UString &fileName = fileInfo.Name;
+ int slashPos = fileName.ReverseFind(WCHAR_PATH_SEPARATOR);
+ UString s1, s2;
+ if (slashPos >= 0)
+ {
+ s1 = fileName.Left(slashPos + 1);
+ s2 = fileName.Mid(slashPos + 1);
+ }
+ else
+ s2 = fileName;
+ ReduceString(s1);
+ ReduceString(s2);
+
+ UString fullString = s1 + L'\n' + s2;
+ fullString += L'\n';
+ fullString += sizeString;
+ fullString += L'\n';
+
+ if (fileInfo.TimeIsDefined)
+ {
+ UString timeString;
+ FILETIME localFileTime;
+ if (!FileTimeToLocalFileTime(&fileInfo.Time, &localFileTime))
+ throw 4190402;
+ timeString = ConvertFileTimeToString(localFileTime);
+
+ fullString +=
+ #ifdef LANG
+ LangString(IDS_FILE_MODIFIED, 0x02000983);
+ #else
+ MyLoadStringW(IDS_FILE_MODIFIED);
+ #endif
+
+ fullString += L" ";
+ fullString += timeString;
+ }
+
+ NWindows::NControl::CDialogChildControl control;
+ control.Init(*this, textID);
+ control.SetText(fullString);
+
+#if _WIN32
+ SHFILEINFO shellFileInfo;
+ if (::SHGetFileInfo(
+ GetSystemString(fileInfo.Name), FILE_ATTRIBUTE_NORMAL, &shellFileInfo,
+ sizeof(shellFileInfo), SHGFI_ICON | SHGFI_USEFILEATTRIBUTES | SHGFI_LARGEICON))
+ {
+ NControl::CStatic staticContol;
+ staticContol.Attach(GetItem(iconID));
+ staticContol.SetIcon(shellFileInfo.hIcon);
+ }
+#endif
+}
+
+bool COverwriteDialog::OnInit()
+{
+ #ifdef LANG
+ LangSetWindowText(HWND(*this), 0x02000900);
+ LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
+ #endif
+ SetFileInfoControl(IDC_STATIC_OVERWRITE_OLD_FILE_SIZE_TIME, IDC_STATIC_OVERWRITE_OLD_FILE_ICON, OldFileInfo);
+ SetFileInfoControl(IDC_STATIC_OVERWRITE_NEW_FILE_SIZE_TIME, IDC_STATIC_OVERWRITE_NEW_FILE_ICON, NewFileInfo);
+ NormalizePosition();
+ return CModalDialog::OnInit();
+}
+
+bool COverwriteDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
+{
+ switch(buttonID)
+ {
+ case IDYES:
+ case IDC_BUTTON_OVERWRITE_YES_TO_ALL:
+ case IDNO:
+ case IDC_BUTTON_OVERWRITE_NO_TO_ALL:
+ case IDC_BUTTON_OVERWRITE_AUTO_RENAME:
+ End(buttonID);
+ return true;
+ }
+ return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/OverwriteDialog.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/OverwriteDialog.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/OverwriteDialog.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/OverwriteDialog.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,71 @@
+// OverwriteDialog.h
+
+#ifndef __OVERWRITE_DIALOG_H
+#define __OVERWRITE_DIALOG_H
+
+#include "Common/Types.h"
+
+#include "Windows/Control/Dialog.h"
+
+#include "DialogSize.h"
+#include "OverwriteDialogRes.h"
+
+namespace NOverwriteDialog
+{
+ struct CFileInfo
+ {
+ bool SizeIsDefined;
+ bool TimeIsDefined;
+ UInt64 Size;
+ FILETIME Time;
+ UString Name;
+
+ void SetTime(const FILETIME *t)
+ {
+ if (t == 0)
+ TimeIsDefined = false;
+ else
+ {
+ TimeIsDefined = true;
+ Time = *t;
+ }
+ }
+ void SetSize(const UInt64 *size)
+ {
+ if (size == 0)
+ SizeIsDefined = false;
+ else
+ {
+ SizeIsDefined = true;
+ Size = *size;
+ }
+ }
+ };
+}
+
+class COverwriteDialog: public NWindows::NControl::CModalDialog
+{
+ bool _isBig;
+
+ void SetFileInfoControl(int textID, int iconID, const NOverwriteDialog::CFileInfo &fileInfo);
+ virtual bool OnInit();
+ bool OnButtonClicked(int buttonID, HWND buttonHWND);
+ void ReduceString(UString &s);
+
+public:
+ INT_PTR Create(HWND parent = 0)
+ {
+ BIG_DIALOG_SIZE(280, 200);
+ #ifdef UNDER_CE
+ _isBig = isBig;
+ #else
+ _isBig = true;
+ #endif
+ return CModalDialog::Create(SIZED_DIALOG(IDD_DIALOG_OVERWRITE), parent);
+ }
+
+ NOverwriteDialog::CFileInfo OldFileInfo;
+ NOverwriteDialog::CFileInfo NewFileInfo;
+};
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/OverwriteDialogRes.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/OverwriteDialogRes.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/OverwriteDialogRes.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/OverwriteDialogRes.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,20 @@
+#define IDD_DIALOG_OVERWRITE 502
+#define IDD_DIALOG_OVERWRITE_2 602
+
+#define IDS_FILE_MODIFIED 600
+#define IDS_FILE_SIZE 601
+
+#define IDC_STATIC_OVERWRITE_HEADER 1000
+
+#define IDC_STATIC_OVERWRITE_QUESTION_BEGIN 1001
+#define IDC_STATIC_OVERWRITE_QUESTION_END 1002
+
+#define IDC_STATIC_OVERWRITE_OLD_FILE_ICON 1003
+#define IDC_STATIC_OVERWRITE_NEW_FILE_ICON 1004
+
+#define IDC_STATIC_OVERWRITE_OLD_FILE_SIZE_TIME 1005
+#define IDC_STATIC_OVERWRITE_NEW_FILE_SIZE_TIME 1006
+
+#define IDC_BUTTON_OVERWRITE_YES_TO_ALL 1010
+#define IDC_BUTTON_OVERWRITE_NO_TO_ALL 1011
+#define IDC_BUTTON_OVERWRITE_AUTO_RENAME 1012
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/OverwriteDialog_rc.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/OverwriteDialog_rc.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/OverwriteDialog_rc.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/OverwriteDialog_rc.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,99 @@
+// OverwriteDialog_rc.cpp
+
+#include "StdAfx.h"
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+// for all others, include the necessary headers (this file is usually all you
+// need because it includes almost all "standard" wxWidgets headers)
+#ifndef WX_PRECOMP
+ #include "wx/wx.h"
+#endif
+
+#undef _WIN32
+
+#include "OverwriteDialogRes.h"
+#include "Windows/Control/DialogImpl.h"
+
+/*
+IDD_DIALOG_OVERWRITE DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE
+CAPTION "Confirm File Replace"
+MY_FONT
+BEGIN
+ LTEXT "Destination folder already contains processed file.", IDC_STATIC_OVERWRITE_HEADER, marg, 7, xSize2, 8
+ LTEXT "Would you like to replace the existing file", IDC_STATIC_OVERWRITE_QUESTION_BEGIN, marg, 28, xSize2, 8
+ ICON "", IDC_STATIC_OVERWRITE_OLD_FILE_ICON, marg, 44, iconSize, iconSize
+ LTEXT "", IDC_STATIC_OVERWRITE_OLD_FILE_SIZE_TIME, fiXPos, 44, fiXSize, fiYSize, SS_NOPREFIX
+ LTEXT "with this one?",IDC_STATIC_OVERWRITE_QUESTION_END, marg, 98, xSize2, 8
+ ICON "",IDC_STATIC_OVERWRITE_NEW_FILE_ICON, marg, 114, iconSize, iconSize
+ LTEXT "",IDC_STATIC_OVERWRITE_NEW_FILE_SIZE_TIME, fiXPos, 114, fiXSize, fiYSize, SS_NOPREFIX
+ PUSHBUTTON "&Yes", IDYES, 78, b2YPos, bXSize, bYSize
+ PUSHBUTTON "Yes to &All", IDC_BUTTON_OVERWRITE_YES_TO_ALL, 152, b2YPos, bXSize, bYSize
+ PUSHBUTTON "&No", IDNO, 226, b2YPos, bXSize, bYSize
+ PUSHBUTTON "No to A&ll", IDC_BUTTON_OVERWRITE_NO_TO_ALL, 300, b2YPos, bXSize, bYSize
+ PUSHBUTTON "A&uto Rename", IDC_BUTTON_OVERWRITE_AUTO_RENAME, 181, b1YPos, 109, bYSize
+ PUSHBUTTON "&Cancel", IDCANCEL, 300, b1YPos, bXSize, bYSize
+END
+*/
+
+class COverwriteDialogImpl : public NWindows::NControl::CModalDialogImpl
+{
+ public:
+ COverwriteDialogImpl(NWindows::NControl::CModalDialog *dialog,wxWindow * parent , int id) : CModalDialogImpl(dialog,parent, id, wxT("Confirm File Replace"))
+ {
+ ///Sizer for adding the controls created by users
+ wxBoxSizer* topsizer = new wxBoxSizer(wxVERTICAL);
+
+ topsizer->Add(new wxStaticText(this, IDC_STATIC_OVERWRITE_HEADER, _T("Destination folder already contains processed file.")) , 0 ,wxALL | wxALIGN_LEFT, 5 );
+ topsizer->Add(new wxStaticText(this, IDC_STATIC_OVERWRITE_QUESTION_BEGIN, _T("Would you like to replace the existing file")) , 0 ,wxALL | wxALIGN_LEFT, 5 );
+
+ // FIXME ICON "", IDC_STATIC_OVERWRITE_OLD_FILE_ICON, marg, 44, iconSize, iconSize
+ topsizer->Add(new wxStaticText(this, IDC_STATIC_OVERWRITE_OLD_FILE_SIZE_TIME, _T(""),
+ wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT) , 0 ,wxALL | wxALIGN_LEFT, 15 );
+ topsizer->Add(new wxStaticText(this, IDC_STATIC_OVERWRITE_QUESTION_END, _T("with this one?")) , 0 ,wxALL | wxALIGN_LEFT, 5 );
+
+ // FIXME ICON "",IDC_STATIC_OVERWRITE_NEW_FILE_ICON, marg, 114, iconSize, iconSize
+ topsizer->Add(new wxStaticText(this, IDC_STATIC_OVERWRITE_NEW_FILE_SIZE_TIME, _T(""),
+ wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT) , 0 ,wxALL | wxALIGN_LEFT, 15 );
+
+ wxBoxSizer* Sizer1 = new wxBoxSizer(wxHORIZONTAL);
+ Sizer1->Add(new wxButton(this, wxID_YES, _T("&Yes")) , 0, wxALL | wxALIGN_RIGHT, 5);
+ Sizer1->Add(new wxButton(this, IDC_BUTTON_OVERWRITE_YES_TO_ALL, _T("Yes to &All")) , 0, wxALL | wxALIGN_RIGHT, 5);
+ Sizer1->Add(new wxButton(this, wxID_NO, _T("&No")) , 0, wxALL | wxALIGN_RIGHT, 5);
+ Sizer1->Add(new wxButton(this, IDC_BUTTON_OVERWRITE_NO_TO_ALL, _T("No to A&ll")) , 0, wxALL | wxALIGN_RIGHT, 5);
+ topsizer->Add(Sizer1 , 0, wxALL | wxALIGN_RIGHT, 5);
+
+ wxBoxSizer* Sizer2 = new wxBoxSizer(wxHORIZONTAL);
+ Sizer2->Add(new wxButton(this, IDC_BUTTON_OVERWRITE_AUTO_RENAME, _T("A&uto Rename")) , 0, wxALL | wxALIGN_RIGHT, 5);
+ Sizer2->Add(new wxButton(this, wxID_CANCEL, _T("&Cancel")) , 0, wxALL | wxALIGN_RIGHT, 5);
+ topsizer->Add(Sizer2 , 1, wxALL | wxALIGN_RIGHT, 5);
+
+ this->OnInit();
+
+ SetSizer(topsizer); // use the sizer for layout
+ topsizer->SetSizeHints(this); // set size hints to honour minimum size
+ }
+private:
+ // Any class wishing to process wxWindows events must use this macro
+ DECLARE_EVENT_TABLE()
+};
+
+static CStringTable g_stringTable[] =
+{
+ { IDS_FILE_MODIFIED, L"modified on" },
+ { IDS_FILE_SIZE, L"{0} bytes" },
+ { 0 , 0 }
+};
+
+REGISTER_DIALOG(IDD_DIALOG_OVERWRITE,COverwriteDialog,g_stringTable)
+
+BEGIN_EVENT_TABLE(COverwriteDialogImpl, wxDialog)
+ EVT_BUTTON(wxID_ANY, CModalDialogImpl::OnAnyButton)
+ EVT_MENU(WORKER_EVENT, CModalDialogImpl::OnWorkerEvent)
+END_EVENT_TABLE()
+
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/Panel.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/Panel.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/Panel.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/Panel.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,1089 @@
+// Panel.cpp
+
+#include "StdAfx.h"
+
+#ifdef _WIN32
+#include <Windowsx.h>
+#endif
+
+#include "Common/Defs.h"
+#include "Common/StringConvert.h"
+#include "Common/IntToString.h"
+#include "Windows/Error.h"
+#include "Windows/PropVariant.h"
+#include "Windows/Thread.h"
+
+#include "../../PropID.h"
+
+#include "Panel.h"
+#include "RootFolder.h"
+#include "FSFolder.h"
+#include "FormatUtils.h"
+#include "App.h"
+#include "ExtractCallback.h"
+
+#include "resource.h"
+#include "../GUI/ExtractRes.h"
+
+#include "../Agent/IFolderArchive.h"
+
+#include "../Common/CompressCall.h"
+#include "../Common/ArchiveName.h"
+
+using namespace NWindows;
+using namespace NControl;
+
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
+
+static const UINT_PTR kTimerID = 1;
+static const UINT kTimerElapse = 1000;
+
+#ifdef _WIN32
+static DWORD kStyles[4] = { LVS_ICON, LVS_SMALLICON, LVS_LIST, LVS_REPORT };
+#endif
+
+// static const int kCreateFolderID = 101;
+// static const UINT kFileChangeNotifyMessage = WM_APP;
+
+extern HINSTANCE g_hInstance;
+extern DWORD g_ComCtl32Version;
+
+void CPanel::Release()
+{
+ // It's for unloading COM dll's: don't change it.
+ CloseOpenFolders();
+#ifdef _WIN32
+ _sevenZipContextMenu.Release();
+ _systemContextMenu.Release();
+#endif
+}
+
+CPanel::~CPanel()
+{
+ CloseOpenFolders();
+}
+
+#ifdef _WIN32 // FIXME
+HWND CPanel::GetParent()
+{
+ HWND h = CWindow2::GetParent();
+ return (h == 0) ? _mainWindow : h;
+}
+#endif
+
+static LPCWSTR kClassName = L"7-Zip::Panel";
+
+
+HRESULT CPanel::Create(HWND mainWindow, HWND parentWindow, UINT id,
+ const UString ¤tFolderPrefix,
+ const UString &arcFormat,
+ CPanelCallback *panelCallback, CAppState *appState,
+ bool &archiveIsOpened, bool &encrypted)
+{
+ _mainWindow = mainWindow;
+ _processTimer = true;
+ _processNotify = true;
+
+ _panelCallback = panelCallback;
+ _appState = appState;
+ // _index = index;
+ _baseID = id;
+ _comboBoxID = _baseID + 3;
+ _statusBarID = _comboBoxID + 1;
+
+ UString cfp = currentFolderPrefix;
+
+ if (!currentFolderPrefix.IsEmpty())
+ if (currentFolderPrefix[0] == L'.')
+ if (!NFile::NDirectory::MyGetFullPathName(currentFolderPrefix, cfp))
+ cfp = currentFolderPrefix;
+ RINOK(BindToPath(cfp, arcFormat, archiveIsOpened, encrypted));
+
+#ifdef _WIN32
+ if (!CreateEx(0, kClassName, 0, WS_CHILD | WS_VISIBLE,
+ 0, 0, _xSize, 260,
+ parentWindow, (HMENU)(UINT_PTR)id, g_hInstance))
+ return E_FAIL;
+#else
+ {
+ // printf("WARNING CPanel::Create => CreateEx\n");
+ // this->OnCreate(0);
+ extern void registerWindow2(int baseID,NWindows::NControl::CWindow2 *w);
+ registerWindow2(_baseID,this);
+ }
+#endif
+
+ return S_OK;
+}
+
+LRESULT CPanel::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
+{
+ switch(message)
+ {
+ case kShiftSelectMessage:
+ OnShiftSelectMessage();
+ return 0;
+ case kReLoadMessage:
+ RefreshListCtrl(_selectedState);
+ return 0;
+ case kSetFocusToListView:
+ _listView.SetFocus();
+ return 0;
+ case kOpenItemChanged:
+ return OnOpenItemChanged(lParam);
+ case kRefreshStatusBar:
+ OnRefreshStatusBar();
+ return 0;
+#ifdef _WIN32
+ case WM_TIMER:
+ OnTimer();
+ return 0;
+ case WM_CONTEXTMENU:
+ if (OnContextMenu(HANDLE(wParam), GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)))
+ return 0;
+ break;
+ /*
+ case WM_DROPFILES:
+ CompressDropFiles(HDROP(wParam));
+ return 0;
+ */
+#endif
+ }
+ return CWindow2::OnMessage(message, wParam, lParam);
+}
+
+#ifdef _WIN32
+static LRESULT APIENTRY ListViewSubclassProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ CWindow tempDialog(hwnd);
+ CMyListView *w = (CMyListView *)(tempDialog.GetUserDataLongPtr());
+ if (w == NULL)
+ return 0;
+ return w->OnMessage(message, wParam, lParam);
+}
+
+LRESULT CMyListView::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
+{
+ if (message == WM_CHAR)
+ {
+ UINT scanCode = (UINT)((lParam >> 16) & 0xFF);
+ bool extended = ((lParam & 0x1000000) != 0);
+ UINT virtualKey = MapVirtualKey(scanCode, 1);
+ if (virtualKey == VK_MULTIPLY || virtualKey == VK_ADD ||
+ virtualKey == VK_SUBTRACT)
+ return 0;
+ if ((wParam == '/' && extended)
+ || wParam == CHAR_PATH_SEPARATOR || wParam == '/')
+ {
+ _panel->OpenDrivesFolder();
+ return 0;
+ }
+ }
+ else if (message == WM_SYSCHAR)
+ {
+ // For Alt+Enter Beep disabling
+ UINT scanCode = (UINT)(lParam >> 16) & 0xFF;
+ UINT virtualKey = MapVirtualKey(scanCode, 1);
+ if (virtualKey == VK_RETURN || virtualKey == VK_MULTIPLY ||
+ virtualKey == VK_ADD || virtualKey == VK_SUBTRACT)
+ return 0;
+ }
+ /*
+ else if (message == WM_SYSKEYDOWN)
+ {
+ // return 0;
+ }
+ */
+ else if (message == WM_KEYDOWN)
+ {
+ bool alt = (::GetKeyState(VK_MENU) & 0x8000) != 0;
+ bool ctrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0;
+ // bool leftCtrl = (::GetKeyState(VK_LCONTROL) & 0x8000) != 0;
+ // bool RightCtrl = (::GetKeyState(VK_RCONTROL) & 0x8000) != 0;
+ bool shift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0;
+ switch(wParam)
+ {
+ case VK_RETURN:
+ {
+ if (shift && !alt && !ctrl)
+ {
+ _panel->OpenSelectedItems(false);
+ return 0;
+ }
+ break;
+ }
+ case VK_NEXT:
+ {
+ if (ctrl && !alt && !shift)
+ {
+ _panel->OpenFocusedItemAsInternal();
+ return 0;
+ }
+ break;
+ }
+ case VK_PRIOR:
+ if (ctrl && !alt && !shift)
+ {
+ _panel->OpenParentFolder();
+ return 0;
+ }
+ }
+ }
+ else if (message == WM_SETFOCUS)
+ {
+ _panel->_lastFocusedIsList = true;
+ _panel->_panelCallback->PanelWasFocused();
+ }
+ #ifndef _UNICODE
+ if (g_IsNT)
+ return CallWindowProcW(_origWindowProc, *this, message, wParam, lParam);
+ else
+ #endif
+ return CallWindowProc(_origWindowProc, *this, message, wParam, lParam);
+}
+
+/*
+static LRESULT APIENTRY ComboBoxSubclassProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ CWindow tempDialog(hwnd);
+ CMyComboBox *w = (CMyComboBox *)(tempDialog.GetUserDataLongPtr());
+ if (w == NULL)
+ return 0;
+ return w->OnMessage(message, wParam, lParam);
+}
+
+LRESULT CMyComboBox::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
+{
+ return CallWindowProc(_origWindowProc, *this, message, wParam, lParam);
+}
+*/
+static LRESULT APIENTRY ComboBoxEditSubclassProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ CWindow tempDialog(hwnd);
+ CMyComboBoxEdit *w = (CMyComboBoxEdit *)(tempDialog.GetUserDataLongPtr());
+ if (w == NULL)
+ return 0;
+ return w->OnMessage(message, wParam, lParam);
+}
+
+LRESULT CMyComboBoxEdit::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
+{
+ // See MSDN / Subclassing a Combo Box / Creating a Combo-box Toolbar
+ switch (message)
+ {
+ case WM_SYSKEYDOWN:
+ switch (wParam)
+ {
+ case VK_F1:
+ case VK_F2:
+ {
+ // check ALT
+ if ((lParam & (1<<29)) == 0)
+ break;
+ bool alt = (::GetKeyState(VK_MENU) & 0x8000) != 0;
+ bool ctrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0;
+ bool shift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0;
+ if (alt && !ctrl && !shift)
+ {
+ _panel->_panelCallback->SetFocusToPath(wParam == VK_F1 ? 0 : 1);
+ return 0;
+ }
+ break;
+ }
+ }
+ break;
+ case WM_KEYDOWN:
+ switch (wParam)
+ {
+ case VK_TAB:
+ // SendMessage(hwndMain, WM_ENTER, 0, 0);
+ _panel->SetFocusToList();
+ return 0;
+ case VK_F9:
+ {
+ bool alt = (::GetKeyState(VK_MENU) & 0x8000) != 0;
+ bool ctrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0;
+ bool shift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0;
+ if (!alt && !ctrl && !shift)
+ {
+ g_App.SwitchOnOffOnePanel();;
+ return 0;
+ }
+ break;
+ }
+ }
+ break;
+ case WM_CHAR:
+ switch (wParam)
+ {
+ case VK_TAB:
+ case VK_ESCAPE:
+ return 0;
+ }
+ }
+ #ifndef _UNICODE
+ if (g_IsNT)
+ return CallWindowProcW(_origWindowProc, *this, message, wParam, lParam);
+ else
+ #endif
+ return CallWindowProc(_origWindowProc, *this, message, wParam, lParam);
+}
+
+static HIMAGELIST GetSysImageList(bool smallIcons)
+{
+ SHFILEINFO shellInfo;
+ return (HIMAGELIST)SHGetFileInfo(TEXT(""),
+ FILE_ATTRIBUTE_NORMAL |FILE_ATTRIBUTE_DIRECTORY,
+ &shellInfo, sizeof(shellInfo),
+ SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX | (smallIcons ? SHGFI_SMALLICON : SHGFI_ICON));
+}
+
+bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */)
+{
+ // _virtualMode = false;
+ // _sortIndex = 0;
+ _sortID = kpidName;
+ _ascending = true;
+ _lastFocusedIsList = true;
+
+ DWORD style = WS_CHILD | WS_VISIBLE; // | WS_BORDER ; // | LVS_SHAREIMAGELISTS; // | LVS_SHOWSELALWAYS;;
+
+ style |= LVS_SHAREIMAGELISTS;
+ // style |= LVS_AUTOARRANGE;
+ style |= WS_CLIPCHILDREN;
+ style |= WS_CLIPSIBLINGS;
+
+ const UInt32 kNumListModes = sizeof(kStyles) / sizeof(kStyles[0]);
+ if (_ListViewMode >= kNumListModes)
+ _ListViewMode = kNumListModes - 1;
+
+ style |= kStyles[_ListViewMode]
+ | WS_TABSTOP
+ | LVS_EDITLABELS;
+ if (_mySelectMode)
+ style |= LVS_SINGLESEL;
+
+ /*
+ if (_virtualMode)
+ style |= LVS_OWNERDATA;
+ */
+
+ DWORD exStyle;
+ exStyle = WS_EX_CLIENTEDGE;
+
+ if (!_listView.CreateEx(exStyle, style, 0, 0, 116, 260,
+ HWND(*this), (HMENU)(UINT_PTR)(_baseID + 1), g_hInstance, NULL))
+ return false;
+
+ _listView.SetUnicodeFormat(true);
+
+ _listView.SetUserDataLongPtr(LONG_PTR(&_listView));
+ _listView._panel = this;
+
+ #ifndef _UNICODE
+ if(g_IsNT)
+ _listView._origWindowProc =
+ (WNDPROC)_listView.SetLongPtrW(GWLP_WNDPROC, LONG_PTR(ListViewSubclassProc));
+ else
+ #endif
+ _listView._origWindowProc =
+ (WNDPROC)_listView.SetLongPtr(GWLP_WNDPROC, LONG_PTR(ListViewSubclassProc));
+
+ _listView.SetImageList(GetSysImageList(true), LVSIL_SMALL);
+ _listView.SetImageList(GetSysImageList(false), LVSIL_NORMAL);
+
+ // _exStyle |= LVS_EX_HEADERDRAGDROP;
+ // DWORD extendedStyle = _listView.GetExtendedListViewStyle();
+ // extendedStyle |= _exStyle;
+ // _listView.SetExtendedListViewStyle(extendedStyle);
+ SetExtendedStyle();
+
+ _listView.Show(SW_SHOW);
+ _listView.InvalidateRect(NULL, true);
+ _listView.Update();
+
+ // Ensure that the common control DLL is loaded.
+ INITCOMMONCONTROLSEX icex;
+
+ icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
+ icex.dwICC = ICC_BAR_CLASSES;
+ InitCommonControlsEx(&icex);
+
+ TBBUTTON tbb [ ] =
+ {
+ // {0, 0, TBSTATE_ENABLED, BTNS_SEP, 0L, 0},
+ {VIEW_PARENTFOLDER, kParentFolderID, TBSTATE_ENABLED, BTNS_BUTTON, 0L, 0},
+ // {0, 0, TBSTATE_ENABLED, BTNS_SEP, 0L, 0},
+ // {VIEW_NEWFOLDER, kCreateFolderID, TBSTATE_ENABLED, BTNS_BUTTON, 0L, 0},
+ };
+
+ if (g_ComCtl32Version >= MAKELONG(71, 4))
+ {
+ icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
+ icex.dwICC = ICC_COOL_CLASSES | ICC_BAR_CLASSES;
+ InitCommonControlsEx(&icex);
+
+ _headerReBar.Attach(::CreateWindowEx(WS_EX_TOOLWINDOW,
+ REBARCLASSNAME,
+ NULL, WS_VISIBLE | WS_BORDER | WS_CHILD |
+ WS_CLIPCHILDREN | WS_CLIPSIBLINGS
+ | CCS_NODIVIDER
+ | CCS_NOPARENTALIGN
+ | CCS_TOP
+ | RBS_VARHEIGHT
+ | RBS_BANDBORDERS
+ ,0,0,0,0, HWND(*this), NULL, g_hInstance, NULL));
+ }
+
+ DWORD toolbarStyle = WS_CHILD | WS_VISIBLE ;
+ if (_headerReBar)
+ {
+ toolbarStyle |= 0
+ // | WS_CLIPCHILDREN
+ // | WS_CLIPSIBLINGS
+
+ | TBSTYLE_TOOLTIPS
+ | CCS_NODIVIDER
+ | CCS_NORESIZE
+ | TBSTYLE_FLAT
+ ;
+ }
+
+ _headerToolBar.Attach(::CreateToolbarEx ((*this), toolbarStyle,
+ _baseID + 2, 11,
+ (HINSTANCE)HINST_COMMCTRL,
+ IDB_VIEW_SMALL_COLOR,
+ (LPCTBBUTTON)&tbb, sizeof(tbb) / sizeof(tbb[0]),
+ 0, 0, 0, 0, sizeof (TBBUTTON)));
+
+ icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
+ icex.dwICC = ICC_USEREX_CLASSES;
+ InitCommonControlsEx(&icex);
+
+ _headerComboBox.CreateEx(0, WC_COMBOBOXEXW, NULL,
+ WS_BORDER | WS_VISIBLE |WS_CHILD | CBS_DROPDOWN | CBS_AUTOHSCROLL,
+ 0, 0, 100, 520,
+ ((_headerReBar == 0) ? HWND(*this) : _headerToolBar),
+ (HMENU)(UINT_PTR)(_comboBoxID),
+ g_hInstance, NULL);
+ _headerComboBox.SendMessage(CBEM_SETUNICODEFORMAT, (WPARAM)(BOOL)TRUE, 0);
+
+ _headerComboBox.SetImageList(GetSysImageList(true));
+
+ _headerComboBox.SetExtendedStyle(CBES_EX_PATHWORDBREAKPROC, CBES_EX_PATHWORDBREAKPROC);
+
+ /*
+ _headerComboBox.SetUserDataLongPtr(LONG_PTR(&_headerComboBox));
+ _headerComboBox._panel = this;
+ _headerComboBox._origWindowProc =
+ (WNDPROC)_headerComboBox.SetLongPtr(GWLP_WNDPROC,
+ LONG_PTR(ComboBoxSubclassProc));
+ */
+ _comboBoxEdit.Attach(_headerComboBox.GetEditControl());
+
+ // _comboBoxEdit.SendMessage(CCM_SETUNICODEFORMAT, (WPARAM)(BOOL)TRUE, 0);
+
+ _comboBoxEdit.SetUserDataLongPtr(LONG_PTR(&_comboBoxEdit));
+ _comboBoxEdit._panel = this;
+ #ifndef _UNICODE
+ if(g_IsNT)
+ _comboBoxEdit._origWindowProc =
+ (WNDPROC)_comboBoxEdit.SetLongPtrW(GWLP_WNDPROC, LONG_PTR(ComboBoxEditSubclassProc));
+ else
+ #endif
+ _comboBoxEdit._origWindowProc =
+ (WNDPROC)_comboBoxEdit.SetLongPtr(GWLP_WNDPROC, LONG_PTR(ComboBoxEditSubclassProc));
+
+ if (_headerReBar)
+ {
+ REBARINFO rbi;
+ rbi.cbSize = sizeof(REBARINFO); // Required when using this struct.
+ rbi.fMask = 0;
+ rbi.himl = (HIMAGELIST)NULL;
+ _headerReBar.SetBarInfo(&rbi);
+
+ // Send the TB_BUTTONSTRUCTSIZE message, which is required for
+ // backward compatibility.
+ // _headerToolBar.SendMessage(TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);
+ SIZE size;
+ _headerToolBar.GetMaxSize(&size);
+
+ REBARBANDINFO rbBand;
+ rbBand.cbSize = sizeof(REBARBANDINFO); // Required
+ rbBand.fMask = RBBIM_STYLE | RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_SIZE;
+ rbBand.fStyle = RBBS_NOGRIPPER;
+ rbBand.cxMinChild = size.cx;
+ rbBand.cyMinChild = size.cy;
+ rbBand.cyChild = size.cy;
+ rbBand.cx = size.cx;
+ rbBand.hwndChild = _headerToolBar;
+ _headerReBar.InsertBand(-1, &rbBand);
+
+ RECT rc;
+ ::GetWindowRect(_headerComboBox, &rc);
+ rbBand.cxMinChild = 30;
+ rbBand.cyMinChild = rc.bottom - rc.top;
+ rbBand.cx = 1000;
+ rbBand.hwndChild = _headerComboBox;
+ _headerReBar.InsertBand(-1, &rbBand);
+ // _headerReBar.MaximizeBand(1, false);
+ }
+
+ _statusBar.Create(WS_CHILD | WS_VISIBLE, L"Status", (*this), _statusBarID);
+ // _statusBar2.Create(WS_CHILD | WS_VISIBLE, L"Status", (*this), _statusBarID + 1);
+
+ int sizes[] = {150, 250, 350, -1};
+ _statusBar.SetParts(4, sizes);
+ // _statusBar2.SetParts(5, sizes);
+
+ /*
+ RECT rect;
+ GetClientRect(&rect);
+ OnSize(0, rect.right - rect.left, rect.top - rect.bottom);
+ */
+
+ SetTimer(kTimerID, kTimerElapse);
+
+ // InitListCtrl();
+ RefreshListCtrl();
+ RefreshStatusBar();
+
+ return true;
+}
+#else
+bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */)
+{
+ printf("WARNING CPanel::OnCreate\n");
+ _sortID = kpidName;
+ _ascending = true;
+ _lastFocusedIsList = true;
+
+ extern HWND g_HWND;
+ HWND w = GetDlgItem(g_HWND, _comboBoxID);
+ if (w == 0)
+ {
+ printf("Can't find id=%d\n",_comboBoxID);
+ return false;
+ }
+ printf("CPanel::OnCreate : _headerComboBox.Attach(%p)\n",w);
+ _headerComboBox.Attach(w);
+
+ w = GetDlgItem(g_HWND, _statusBarID);
+ if (w == 0)
+ {
+ printf("Can't find id=%d\n",_statusBarID);
+ return false;
+ }
+ printf("CPanel::OnCreate : _statusBar.Attach(%p)\n",w);
+ _statusBar.Attach(w);
+
+ w = GetDlgItem(g_HWND, _baseID + 1);
+ if (w == 0)
+ {
+ printf("Can't find id=%d\n",_baseID + 1);
+ return false;
+ }
+ printf("CPanel::OnCreate : _listView.Attach(%p)\n",w);
+ _listView.Attach(w);
+
+ _listView.SetUnicodeFormat(true);
+
+ // _listView.SetUserDataLongPtr(LONG_PTR(&_listView));
+ _listView._panel = this;
+
+ // FIXME _listView.SetImageList(GetSysImageList(true), LVSIL_SMALL);
+ // FIXME _listView.SetImageList(GetSysImageList(false), LVSIL_NORMAL);
+
+ // FIXME SetExtendedStyle();
+
+ // FIXME _listView.Show(SW_SHOW);
+ // FIXME _listView.InvalidateRect(NULL, true);
+ _listView.Update();
+
+ /* FIXME
+ _headerToolBar.Attach(::CreateToolbarEx ((*this), toolbarStyle,
+ _baseID + 2, 11,
+ (HINSTANCE)HINST_COMMCTRL,
+ IDB_VIEW_SMALL_COLOR,
+ (LPCTBBUTTON)&tbb, sizeof(tbb) / sizeof(tbb[0]),
+ 0, 0, 0, 0, sizeof (TBBUTTON)));
+ */
+
+ /* FIXME
+ _headerComboBox.CreateEx(0, WC_COMBOBOXEXW, NULL,
+ WS_BORDER | WS_VISIBLE |WS_CHILD | CBS_DROPDOWN | CBS_AUTOHSCROLL,
+ 0, 0, 100, 520,
+ ((_headerReBar == 0) ? HWND(*this) : _headerToolBar),
+ (HMENU)(UINT_PTR)(_comboBoxID),
+ g_hInstance, NULL);
+ _headerComboBox.SendMessage(CBEM_SETUNICODEFORMAT, (WPARAM)(BOOL)TRUE, 0);
+
+ _headerComboBox.SetImageList(GetSysImageList(true));
+
+ _headerComboBox.SetExtendedStyle(CBES_EX_PATHWORDBREAKPROC, CBES_EX_PATHWORDBREAKPROC);
+ */
+
+ // FIXME _comboBoxEdit.Attach(_headerComboBox.GetEditControl());
+
+ _comboBoxEdit._panel = this;
+
+ // FIXME if (_headerReBar) ...
+
+ // _statusBar.Create(WS_CHILD | WS_VISIBLE, L"Status", (*this), _statusBarID);
+
+ // int sizes[] = {150, 250, 350, -1};
+ // _statusBar.SetParts(4, sizes);
+
+ // SetTimer(kTimerID, kTimerElapse);
+
+ // InitListCtrl();
+ RefreshListCtrl();
+ RefreshStatusBar();
+
+ return true;
+}
+#endif
+
+
+void CPanel::OnDestroy()
+{
+ printf("CPanel::OnDestroy\n");
+
+ SaveListViewInfo();
+ CWindow2::OnDestroy();
+}
+
+#ifdef _WIN32
+void CPanel::ChangeWindowSize(int xSize, int ySize)
+{
+ int kHeaderSize;
+ int kStatusBarSize;
+ // int kStatusBar2Size;
+ RECT rect;
+ if (_headerReBar)
+ _headerReBar.GetWindowRect(&rect);
+ else
+ _headerToolBar.GetWindowRect(&rect);
+
+ kHeaderSize = rect.bottom - rect.top;
+
+ _statusBar.GetWindowRect(&rect);
+ kStatusBarSize = rect.bottom - rect.top;
+
+ // _statusBar2.GetWindowRect(&rect);
+ // kStatusBar2Size = rect.bottom - rect.top;
+
+ int yListViewSize = MyMax(ySize - kHeaderSize - kStatusBarSize, 0);
+ const int kStartXPos = 32;
+ if (_headerReBar)
+ {
+ }
+ else
+ {
+ _headerToolBar.Move(0, 0, xSize, 0);
+ _headerComboBox.Move(kStartXPos, 2,
+ MyMax(xSize - kStartXPos - 10, kStartXPos), 0);
+ }
+ _listView.Move(0, kHeaderSize, xSize, yListViewSize);
+ _statusBar.Move(0, kHeaderSize + yListViewSize, xSize, kStatusBarSize);
+ // _statusBar2.MoveWindow(0, kHeaderSize + yListViewSize + kStatusBarSize, xSize, kStatusBar2Size);
+ // _statusBar.MoveWindow(0, 100, xSize, kStatusBarSize);
+ // _statusBar2.MoveWindow(0, 200, xSize, kStatusBar2Size);
+}
+
+bool CPanel::OnSize(WPARAM /* wParam */, int xSize, int ySize)
+{
+ if (_headerReBar)
+ _headerReBar.Move(0, 0, xSize, 0);
+ ChangeWindowSize(xSize, ySize);
+ return true;
+}
+
+bool CPanel::OnNotifyReBar(LPNMHDR header, LRESULT & /* result */)
+{
+ switch(header->code)
+ {
+ case RBN_HEIGHTCHANGE:
+ {
+ RECT rect;
+ GetWindowRect(&rect);
+ ChangeWindowSize(rect.right - rect.left, rect.bottom - rect.top);
+ return false;
+ }
+ }
+ return false;
+}
+#endif
+
+bool CPanel::OnNotify(UINT /* controlID */, LPNMHDR header, LRESULT &result)
+{
+ if (!_processNotify)
+ return false;
+ if (header->hwndFrom == _headerComboBox)
+ return OnNotifyComboBox(header, result);
+#ifdef _WIN32
+ else if (header->hwndFrom == _headerReBar)
+ return OnNotifyReBar(header, result);
+#endif
+ else if (header->hwndFrom == _listView)
+ return OnNotifyList(header, result);
+#ifdef _WIN32
+ else if (::GetParent(header->hwndFrom) == _listView &&
+ header->code == NM_RCLICK)
+ return OnRightClick((LPNMITEMACTIVATE)header, result);
+#endif
+ return false;
+}
+
+bool CPanel::OnCommand(int code, int itemID, LPARAM lParam, LRESULT &result)
+{
+ printf("CPanel::OnCommand(code=%d,itemID=%d)\n",code,itemID);
+ if (itemID == kParentFolderID)
+ {
+ OpenParentFolder();
+ result = 0;
+ return true;
+ }
+ /*
+ if (itemID == kCreateFolderID)
+ {
+ CreateFolder();
+ result = 0;
+ return true;
+ }
+ */
+ if (itemID == _comboBoxID)
+ {
+ if (OnComboBoxCommand(code, lParam, result))
+ return true;
+ }
+ return CWindow2::OnCommand(code, itemID, lParam, result);
+}
+
+void CPanel::MessageBoxInfo(LPCWSTR message, LPCWSTR caption)
+ { ::MessageBoxW(HWND(*this), message, caption, MB_OK); }
+void CPanel::MessageBox(LPCWSTR message, LPCWSTR caption)
+ { ::MessageBoxW(HWND(*this), message, caption, MB_OK | MB_ICONSTOP); }
+void CPanel::MessageBox(LPCWSTR message)
+ { MessageBox(message, L"7-Zip"); }
+void CPanel::MessageBoxMyError(LPCWSTR message)
+ { MessageBox(message, L"Error"); }
+void CPanel::MessageBoxError(HRESULT errorCode, LPCWSTR caption)
+{
+ UString message;
+ if (errorCode == E_OUTOFMEMORY)
+ message = LangString(IDS_MEM_ERROR, 0x0200060B);
+ else
+ if (!NError::MyFormatMessage(errorCode, message))
+ message = L"Error";
+ MessageBox(message, caption);
+}
+
+void CPanel::MessageBoxError(HRESULT errorCode)
+ { MessageBoxError(errorCode, L"7-Zip"); }
+void CPanel::MessageBoxLastError(LPCWSTR caption)
+ { MessageBoxError(::GetLastError(), caption); }
+void CPanel::MessageBoxLastError()
+ { MessageBoxLastError(L"Error"); }
+
+void CPanel::MessageBoxErrorLang(UINT resourceID, UInt32 langID)
+ { MessageBox(LangString(resourceID, langID)); }
+
+
+void CPanel::SetFocusToList()
+{
+ _listView.SetFocus();
+ // SetCurrentPathText();
+}
+
+void CPanel::SetFocusToLastRememberedItem()
+{
+ if (_lastFocusedIsList)
+ SetFocusToList();
+#ifdef _WIN32 // FIXME
+ else
+ _headerComboBox.SetFocus();
+#endif
+}
+
+UString CPanel::GetFolderTypeID() const
+{
+ NCOM::CPropVariant prop;
+ if (_folder->GetFolderProperty(kpidType, &prop) == S_OK)
+ if (prop.vt == VT_BSTR)
+ return (const wchar_t *)prop.bstrVal;
+ return L"";
+}
+
+bool CPanel::IsFolderTypeEqTo(const wchar_t *s) const
+{
+ return GetFolderTypeID() == s;
+}
+
+bool CPanel::IsRootFolder() const { return IsFolderTypeEqTo(L"RootFolder"); }
+bool CPanel::IsFSFolder() const { return IsFolderTypeEqTo(L"FSFolder"); }
+bool CPanel::IsFSDrivesFolder() const { return IsFolderTypeEqTo(L"FSDrives"); }
+bool CPanel::IsArcFolder() const
+{
+ UString s = GetFolderTypeID();
+ return s.Left(5) == L"7-Zip";
+}
+
+UString CPanel::GetFsPath() const
+{
+ if (IsFSDrivesFolder())
+ return UString();
+ return _currentFolderPrefix;
+}
+
+UString CPanel::GetDriveOrNetworkPrefix() const
+{
+ if (!IsFSFolder())
+ return UString();
+ UString drive = GetFsPath();
+ if (drive.Length() < 3)
+ return UString();
+ if (drive[0] == L'\\' && drive[1] == L'\\')
+ {
+ // if network
+ int pos = drive.Find(L'\\', 2);
+ if (pos < 0)
+ return UString();
+ pos = drive.Find(L'\\', pos + 1);
+ if (pos < 0)
+ return UString();
+ return drive.Left(pos + 1);
+ }
+ if (drive[1] != L':' || drive[2] != L'\\')
+ return UString();
+ return drive.Left(3);
+}
+
+bool CPanel::DoesItSupportOperations() const
+{
+ CMyComPtr<IFolderOperations> folderOperations;
+ return _folder.QueryInterface(IID_IFolderOperations, &folderOperations) == S_OK;
+}
+
+void CPanel::SetListViewMode(UInt32 index)
+{
+#ifdef _WIN32 // FIXME
+ if (index >= 4)
+ return;
+ _ListViewMode = index;
+ DWORD oldStyle = (DWORD)_listView.GetStyle();
+ DWORD newStyle = kStyles[index];
+ if ((oldStyle & LVS_TYPEMASK) != newStyle)
+ _listView.SetStyle((oldStyle & ~LVS_TYPEMASK) | newStyle);
+ // RefreshListCtrlSaveFocused();
+#endif
+}
+
+void CPanel::ChangeFlatMode()
+{
+ _flatMode = !_flatMode;
+ RefreshListCtrlSaveFocused();
+}
+
+
+void CPanel::RefreshStatusBar()
+{
+ // FIXME PostMessage(kRefreshStatusBar);
+}
+
+void CPanel::AddToArchive()
+{
+ CRecordVector<UInt32> indices;
+ GetOperatedItemIndices(indices);
+ if (!IsFsOrDrivesFolder())
+ {
+ MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
+ return;
+ }
+ if (indices.Size() == 0)
+ {
+ MessageBoxErrorLang(IDS_SELECT_FILES, 0x03020A03);
+ return;
+ }
+ UStringVector names;
+
+ UString curPrefix = _currentFolderPrefix;
+ UString destCurDirPrefix = _currentFolderPrefix;
+ if (IsFSDrivesFolder())
+ {
+ destCurDirPrefix = ROOT_FS_FOLDER;
+ if (!IsDeviceDrivesPrefix())
+ curPrefix.Empty();
+ }
+
+ for (int i = 0; i < indices.Size(); i++)
+ names.Add(curPrefix + GetItemRelPath(indices[i]));
+ const UString archiveName = CreateArchiveName(names.Front(), (names.Size() > 1), false);
+ HRESULT res = CompressFiles(destCurDirPrefix, archiveName, L"", names, false, true, false);
+ if (res != S_OK)
+ {
+ if (destCurDirPrefix.Length() >= MAX_PATH)
+ MessageBoxErrorLang(IDS_MESSAGE_UNSUPPORTED_OPERATION_FOR_LONG_PATH_FOLDER, 0x03020A01);
+ }
+ // KillSelection();
+}
+
+static UString GetSubFolderNameForExtract(const UString &archiveName)
+{
+ int slashPos = archiveName.ReverseFind(WCHAR_PATH_SEPARATOR);
+ int dotPos = archiveName.ReverseFind(L'.');
+ if (dotPos < 0 || slashPos > dotPos)
+ return archiveName + UString(L"~");
+ UString res = archiveName.Left(dotPos);
+ res.TrimRight();
+ return res;
+}
+
+void CPanel::GetFilePaths(const CRecordVector<UInt32> &indices, UStringVector &paths)
+{
+ for (int i = 0; i < indices.Size(); i++)
+ {
+ int index = indices[i];
+ if (IsItemFolder(index))
+ {
+ paths.Clear();
+ break;
+ }
+ paths.Add(GetItemFullPath(index));
+ }
+ if (paths.Size() == 0)
+ {
+ MessageBoxErrorLang(IDS_SELECT_FILES, 0x03020A03);
+ return;
+ }
+}
+
+void CPanel::ExtractArchives()
+{
+ if (_parentFolders.Size() > 0)
+ {
+ _panelCallback->OnCopy(false, false);
+ return;
+ }
+ CRecordVector<UInt32> indices;
+ GetOperatedItemIndices(indices);
+ UStringVector paths;
+ GetFilePaths(indices, paths);
+ if (paths.IsEmpty())
+ return;
+ UString folderName;
+ if (indices.Size() == 1)
+ folderName = GetSubFolderNameForExtract(GetItemRelPath(indices[0]));
+ else
+ folderName = L"*";
+ ::ExtractArchives(paths, _currentFolderPrefix + folderName + UString(WCHAR_PATH_SEPARATOR), true);
+}
+
+static void AddValuePair(UINT resourceID, UInt32 langID, UInt64 value, UString &s)
+{
+ wchar_t sz[32];
+ s += LangString(resourceID, langID);
+ s += L' ';
+ ConvertUInt64ToString(value, sz);
+ s += sz;
+ s += L'\n';
+}
+
+class CThreadTest: public CProgressThreadVirt
+{
+ HRESULT ProcessVirt();
+public:
+ CRecordVector<UInt32> Indices;
+ CExtractCallbackImp *ExtractCallbackSpec;
+ CMyComPtr<IFolderArchiveExtractCallback> ExtractCallback;
+ CMyComPtr<IArchiveFolder> ArchiveFolder;
+};
+
+HRESULT CThreadTest::ProcessVirt()
+{
+ RINOK(ArchiveFolder->Extract(&Indices[0], Indices.Size(),
+ NExtract::NPathMode::kFullPathnames, NExtract::NOverwriteMode::kAskBefore,
+ NULL, BoolToInt(true), ExtractCallback));
+ if (ExtractCallbackSpec->IsOK())
+ {
+ UString s;
+ AddValuePair(IDS_FOLDERS_COLON, 0x02000321, ExtractCallbackSpec->NumFolders, s);
+ AddValuePair(IDS_FILES_COLON, 0x02000320, ExtractCallbackSpec->NumFiles, s);
+ // AddSizePair(IDS_SIZE_COLON, 0x02000322, Stat.UnpackSize, s);
+ // AddSizePair(IDS_COMPRESSED_COLON, 0x02000323, Stat.PackSize, s);
+ s += L'\n';
+ s += LangString(IDS_MESSAGE_NO_ERRORS, 0x02000608);
+ OkMessage = s;
+ }
+ return S_OK;
+};
+
+/*
+static void AddSizePair(UINT resourceID, UInt32 langID, UInt64 value, UString &s)
+{
+ wchar_t sz[32];
+ s += LangString(resourceID, langID);
+ s += L" ";
+ ConvertUInt64ToString(value, sz);
+ s += sz;
+ ConvertUInt64ToString(value >> 20, sz);
+ s += L" (";
+ s += sz;
+ s += L" MB)";
+ s += L'\n';
+}
+*/
+
+void CPanel::TestArchives()
+{
+ CRecordVector<UInt32> indices;
+ GetOperatedIndicesSmart(indices);
+ CMyComPtr<IArchiveFolder> archiveFolder;
+ _folder.QueryInterface(IID_IArchiveFolder, &archiveFolder);
+ if (archiveFolder)
+ {
+ {
+ CThreadTest extracter;
+
+ extracter.ArchiveFolder = archiveFolder;
+ extracter.ExtractCallbackSpec = new CExtractCallbackImp;
+ extracter.ExtractCallback = extracter.ExtractCallbackSpec;
+ extracter.ExtractCallbackSpec->ProgressDialog = &extracter.ProgressDialog;
+
+ if (indices.IsEmpty())
+ return;
+
+ extracter.Indices = indices;
+
+ UString title = LangString(IDS_PROGRESS_TESTING, 0x02000F90);
+ UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000);
+
+ extracter.ProgressDialog.CompressingMode = false;
+ extracter.ProgressDialog.MainWindow = GetParent();
+ extracter.ProgressDialog.MainTitle = progressWindowTitle;
+ extracter.ProgressDialog.MainAddTitle = title + L" ";
+
+ extracter.ExtractCallbackSpec->OverwriteMode = NExtract::NOverwriteMode::kAskBefore;
+ extracter.ExtractCallbackSpec->Init();
+
+ if (extracter.Create(title, GetParent()) != S_OK)
+ return;
+
+ }
+ RefreshTitleAlways();
+ return;
+ }
+
+ if (!IsFSFolder())
+ {
+ MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
+ return;
+ }
+ UStringVector paths;
+ GetFilePaths(indices, paths);
+ if (paths.IsEmpty())
+ return;
+ ::TestArchives(paths);
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/Panel.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/Panel.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/Panel.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/Panel.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,625 @@
+// Panel.h
+
+#ifndef __PANEL_H
+#define __PANEL_H
+
+#include "../../../../C/Alloc.h"
+
+#include "Common/MyCom.h"
+
+#include "Windows/DLL.h"
+#include "Windows/FileFind.h"
+#include "Windows/FileDir.h"
+#include "Windows/Synchronization.h"
+
+#include "Windows/Control/ComboBox.h"
+#include "Windows/Control/Edit.h"
+#include "Windows/Control/ListView.h"
+// #include "Windows/Control/ReBar.h"
+#include "Windows/Control/Static.h"
+#include "Windows/Control/StatusBar.h"
+// #include "Windows/Control/ToolBar.h"
+#include "Windows/Control/Window2.h"
+
+#include "AppState.h"
+#include "IFolder.h"
+//#include "MyCom2.h"
+#include "ProgressDialog2.h"
+#include "SysIconUtils.h"
+
+const int kParentFolderID = 100;
+const int kPluginMenuStartID = 1000;
+const int kToolbarStartID = 2000;
+
+const int kParentIndex = -1;
+
+#ifdef UNDER_CE
+#define ROOT_FS_FOLDER L"\\"
+#else
+#ifdef _WIN32
+#define ROOT_FS_FOLDER L"C:\\\\"
+#else
+#define ROOT_FS_FOLDER L"\\"
+#endif
+#endif
+
+struct CPanelCallback
+{
+ virtual void OnTab() = 0;
+ virtual void SetFocusToPath(int index) = 0;
+ virtual void OnCopy(bool move, bool copyToSame) = 0;
+ virtual void OnSetSameFolder() = 0;
+ virtual void OnSetSubFolder() = 0;
+ virtual void PanelWasFocused() = 0;
+ virtual void DragBegin() = 0;
+ virtual void DragEnd() = 0;
+ virtual void RefreshTitle(bool always) = 0;
+};
+
+void PanelCopyItems();
+
+struct CItemProperty
+{
+ UString Name;
+ PROPID ID;
+ VARTYPE Type;
+ int Order;
+ bool IsVisible;
+ UInt32 Width;
+};
+
+inline bool operator<(const CItemProperty &a1, const CItemProperty &a2)
+ { return (a1.Order < a2.Order); }
+
+inline bool operator==(const CItemProperty &a1, const CItemProperty &a2)
+ { return (a1.Order == a2.Order); }
+
+class CItemProperties: public CObjectVector<CItemProperty>
+{
+public:
+ int FindItemWithID(PROPID id)
+ {
+ for (int i = 0; i < Size(); i++)
+ if ((*this)[i].ID == id)
+ return i;
+ return -1;
+ }
+};
+
+struct CTempFileInfo
+{
+ UString ItemName;
+ UString FolderPath;
+ UString FilePath;
+ NWindows::NFile::NFind::CFileInfoW FileInfo;
+ bool NeedDelete;
+
+ CTempFileInfo(): NeedDelete(false) {}
+ void DeleteDirAndFile() const
+ {
+ if (NeedDelete)
+ {
+ NWindows::NFile::NDirectory::DeleteFileAlways(FilePath);
+ NWindows::NFile::NDirectory::MyRemoveDirectory(FolderPath);
+ }
+ }
+ bool WasChanged(const NWindows::NFile::NFind::CFileInfoW &newFileInfo) const
+ {
+ return newFileInfo.Size != FileInfo.Size ||
+ CompareFileTime(&newFileInfo.MTime, &FileInfo.MTime) != 0;
+ }
+};
+
+struct CFolderLink: public CTempFileInfo
+{
+ NWindows::NDLL::CLibrary Library;
+ CMyComPtr<IFolderFolder> ParentFolder;
+ bool UsePassword;
+ UString Password;
+ bool IsVirtual;
+
+ UString VirtualPath;
+ CFolderLink(): UsePassword(false), IsVirtual(false) {}
+
+ bool WasChanged(const NWindows::NFile::NFind::CFileInfoW &newFileInfo) const
+ {
+ return IsVirtual || CTempFileInfo::WasChanged(newFileInfo);
+ }
+
+};
+
+enum MyMessages
+{
+ kShiftSelectMessage = 20000, // FIXME = WM_USER + 1,
+ kReLoadMessage,
+ kSetFocusToListView,
+ kOpenItemChanged,
+ kRefreshStatusBar
+};
+
+UString GetFolderPath(IFolderFolder * folder);
+
+class CPanel;
+
+class CMyListView: public NWindows::NControl::CListView
+{
+public:
+ WNDPROC _origWindowProc;
+ CPanel *_panel;
+ LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
+};
+
+/*
+class CMyComboBox: public NWindows::NControl::CComboBoxEx
+{
+public:
+ WNDPROC _origWindowProc;
+ CPanel *_panel;
+ LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
+};
+*/
+class CMyComboBoxEdit: public NWindows::NControl::CEdit
+{
+public:
+ WNDPROC _origWindowProc;
+ CPanel *_panel;
+ LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
+};
+
+struct CSelectedState
+{
+ int FocusedItem;
+ UString FocusedName;
+ bool SelectFocused;
+ UStringVector SelectedNames;
+ CSelectedState(): FocusedItem(-1), SelectFocused(false) {}
+};
+
+class CPanel :public NWindows::NControl::CWindow2
+{
+ CExtToIconMap _extToIconMap;
+ UINT _baseID;
+ int _comboBoxID;
+ UINT _statusBarID;
+
+ CAppState *_appState;
+
+ bool OnCommand(int code, int itemID, LPARAM lParam, LRESULT &result);
+ LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
+ virtual bool OnCreate(CREATESTRUCT *createStruct);
+ // FIXME virtual bool OnSize(WPARAM wParam, int xSize, int ySize);
+ virtual void OnDestroy();
+ virtual bool OnNotify(UINT controlID, LPNMHDR lParam, LRESULT &result);
+
+ void AddComboBoxItem(const UString &name, int iconIndex, int indent, bool addToList);
+
+ bool OnComboBoxCommand(UINT code, LPARAM param, LRESULT &result);
+
+ #ifndef UNDER_CE
+
+ LRESULT OnNotifyComboBoxEnter(const UString &s);
+ bool OnNotifyComboBoxEndEdit(PNMCBEENDEDITW info, LRESULT &result);
+ #ifndef _UNICODE
+ bool OnNotifyComboBoxEndEdit(PNMCBEENDEDIT info, LRESULT &result);
+ #endif
+
+ #endif
+
+ // FIXME bool OnNotifyReBar(LPNMHDR lParam, LRESULT &result);
+ bool OnNotifyComboBox(LPNMHDR lParam, LRESULT &result);
+ void OnItemChanged(NMLISTVIEW *item);
+ bool OnNotifyList(LPNMHDR lParam, LRESULT &result);
+ // FIXME void OnDrag(LPNMLISTVIEW nmListView);
+ // FIXME bool OnKeyDown(LPNMLVKEYDOWN keyDownInfo, LRESULT &result);
+ // FIXME BOOL OnBeginLabelEdit(LV_DISPINFOW * lpnmh);
+ // FIXME BOOL OnEndLabelEdit(LV_DISPINFOW * lpnmh);
+ void OnColumnClick(LPNMLISTVIEW info);
+ // FIXME bool OnCustomDraw(LPNMLVCUSTOMDRAW lplvcd, LRESULT &result);
+
+public:
+ HWND _mainWindow;
+ CPanelCallback *_panelCallback;
+
+/* FIXME BEGIN */
+ HWND GetParent() { return 0; }
+ operator HWND() const { return 0; }
+/* FIXME END */
+
+ void DeleteItems(bool toRecycleBin);
+ void DeleteItemsInternal(CRecordVector<UInt32> &indices);
+ void CreateFolder();
+ void CreateFile();
+
+private:
+
+ void ChangeWindowSize(int xSize, int ySize);
+
+ void InitColumns();
+ // void InitColumns2(PROPID sortID);
+ void InsertColumn(int index);
+
+ void SetFocusedSelectedItem(int index, bool select);
+ void RefreshListCtrl(const UString &focusedName, int focusedPos, bool selectFocused,
+ const UStringVector &selectedNames);
+
+ void OnShiftSelectMessage();
+ void OnArrowWithShift();
+
+ void OnInsert();
+ // void OnUpWithShift();
+ // void OnDownWithShift();
+public:
+ void myTests();
+ void UpdateSelection();
+ void SelectSpec(bool selectMode);
+ void SelectByType(bool selectMode);
+ void SelectAll(bool selectMode);
+ void InvertSelection();
+private:
+
+ // UString GetFileType(UInt32 index);
+ LRESULT SetItemText(LVITEMW &item);
+
+ // CRecordVector<PROPID> m_ColumnsPropIDs;
+
+public:
+ // FIXME NWindows::NControl::CReBar _headerReBar;
+ // FIXME NWindows::NControl::CToolBar _headerToolBar;
+ NWindows::NControl::CComboBoxEx _headerComboBox;
+ // CMyComboBox _headerComboBox;
+ CMyComboBoxEdit _comboBoxEdit;
+ CMyListView _listView;
+ NWindows::NControl::CStatusBar _statusBar;
+ bool _lastFocusedIsList;
+ // NWindows::NControl::CStatusBar _statusBar2;
+
+ DWORD _exStyle;
+ bool _showDots;
+ bool _showRealFileIcons;
+ // bool _virtualMode;
+ // CUIntVector _realIndices;
+ bool _enableItemChangeNotify;
+ bool _mySelectMode;
+ CBoolVector _selectedStatusVector;
+
+ CSelectedState _selectedState;
+
+ UInt32 GetRealIndex(const LVITEMW &item) const
+ {
+ /*
+ if (_virtualMode)
+ return _realIndices[item.iItem];
+ */
+ return (UInt32)item.lParam;
+ }
+ int GetRealItemIndex(int indexInListView) const
+ {
+ /*
+ if (_virtualMode)
+ return indexInListView;
+ */
+ LPARAM param;
+ if (!_listView.GetItemParam(indexInListView, param))
+ throw 1;
+ return (int)param;
+ }
+
+ UInt32 _ListViewMode;
+ int _xSize;
+
+ bool _flatMode;
+ bool _flatModeForDisk;
+ bool _flatModeForArc;
+
+ bool _dontShowMode;
+
+
+ UString _currentFolderPrefix;
+
+ CObjectVector<CFolderLink> _parentFolders;
+ NWindows::NDLL::CLibrary _library;
+ CMyComPtr<IFolderFolder> _folder;
+ // CMyComPtr<IFolderGetSystemIconIndex> _folderGetSystemIconIndex;
+
+ UStringVector _fastFolders;
+
+ void GetSelectedNames(UStringVector &selectedNames);
+ void SaveSelectedState(CSelectedState &s);
+ void RefreshListCtrl(const CSelectedState &s);
+ void RefreshListCtrlSaveFocused();
+
+ UString GetItemName(int itemIndex) const;
+ UString GetItemPrefix(int itemIndex) const;
+ UString GetItemRelPath(int itemIndex) const;
+ UString GetItemFullPath(int itemIndex) const;
+ bool IsItemFolder(int itemIndex) const;
+ UInt64 GetItemSize(int itemIndex) const;
+
+ ////////////////////////
+ // PanelFolderChange.cpp
+
+ void SetToRootFolder();
+ HRESULT BindToPath(const UString &fullPath, const UString &arcFormat, bool &archiveIsOpened, bool &encrypted); // can be prefix
+ HRESULT BindToPathAndRefresh(const UString &path);
+ void OpenDrivesFolder();
+
+ void SetBookmark(int index);
+ void OpenBookmark(int index);
+
+ void LoadFullPath();
+ void LoadFullPathAndShow();
+ void FoldersHistory();
+ void OpenParentFolder();
+ void CloseOpenFolders();
+ void OpenRootFolder();
+
+
+ HRESULT Create(HWND mainWindow, HWND parentWindow,
+ UINT id,
+ const UString ¤tFolderPrefix,
+ const UString &arcFormat,
+ CPanelCallback *panelCallback,
+ CAppState *appState, bool &archiveIsOpened, bool &encrypted);
+ void SetFocusToList();
+ void SetFocusToLastRememberedItem();
+
+
+ void ReadListViewInfo();
+ void SaveListViewInfo();
+
+ CPanel() :
+ // _virtualMode(flase),
+ _exStyle(0),
+ _showDots(false),
+ _showRealFileIcons(false),
+ _needSaveInfo(false),
+ _startGroupSelect(0),
+ _selectionIsDefined(false),
+ _ListViewMode(3),
+ _flatMode(false),
+ _flatModeForDisk(false),
+ _flatModeForArc(false),
+ _xSize(300),
+ _mySelectMode(false),
+ _enableItemChangeNotify(true),
+ _dontShowMode(false)
+ {}
+
+
+ void SetExtendedStyle()
+ {
+/* FIXME
+ if (_listView != 0)
+ _listView.SetExtendedListViewStyle(_exStyle);
+ */
+ }
+
+
+ bool _needSaveInfo;
+ UString _typeIDString;
+ CListViewInfo _listViewInfo;
+ CItemProperties _properties;
+ CItemProperties _visibleProperties;
+
+ PROPID _sortID;
+ // int _sortIndex;
+ bool _ascending;
+
+ void Release();
+ ~CPanel();
+ // FIXME void OnLeftClick(LPNMITEMACTIVATE itemActivate);
+ // FIXME bool OnRightClick(LPNMITEMACTIVATE itemActivate, LRESULT &result);
+
+ void OnTimer();
+ void OnReload();
+ bool OnContextMenu(HANDLE windowHandle, int xPos, int yPos);
+
+#ifdef _WIN32
+ CMyComPtr<IContextMenu> _sevenZipContextMenu;
+ CMyComPtr<IContextMenu> _systemContextMenu;
+ HRESULT CreateShellContextMenu(
+ const CRecordVector<UInt32> &operatedIndices,
+ CMyComPtr<IContextMenu> &systemContextMenu);
+ void CreateSystemMenu(HMENU menu,
+ const CRecordVector<UInt32> &operatedIndices,
+ CMyComPtr<IContextMenu> &systemContextMenu);
+ void CreateSevenZipMenu(HMENU menu,
+ const CRecordVector<UInt32> &operatedIndices,
+ CMyComPtr<IContextMenu> &sevenZipContextMenu);
+ void CreateFileMenu(HMENU menu,
+ CMyComPtr<IContextMenu> &sevenZipContextMenu,
+ CMyComPtr<IContextMenu> &systemContextMenu,
+ bool programMenu);
+ void CreateFileMenu(HMENU menu);
+ bool InvokePluginCommand(int id);
+ bool InvokePluginCommand(int id, IContextMenu *sevenZipContextMenu,
+ IContextMenu *systemContextMenu);
+#endif // ifdef _WIN32
+
+ void InvokeSystemCommand(const char *command);
+ void Properties();
+ void EditCut();
+ void EditCopy();
+ void EditPaste();
+
+ int _startGroupSelect;
+
+ bool _selectionIsDefined;
+ bool _selectMark;
+ int _prevFocusedItem;
+
+
+ // void SortItems(int index);
+ void SortItemsWithPropID(PROPID propID);
+
+ void GetSelectedItemsIndices(CRecordVector<UInt32> &indices) const;
+ void GetOperatedItemIndices(CRecordVector<UInt32> &indices) const;
+ void GetAllItemIndices(CRecordVector<UInt32> &indices) const;
+ void GetOperatedIndicesSmart(CRecordVector<UInt32> &indices) const;
+ // void GetOperatedListViewIndices(CRecordVector<UInt32> &indices) const;
+ void KillSelection();
+
+ UString GetFolderTypeID() const;
+ bool IsFolderTypeEqTo(const wchar_t *s) const;
+ bool IsRootFolder() const;
+ bool IsFSFolder() const;
+ bool IsFSDrivesFolder() const;
+ bool IsArcFolder() const;
+ bool IsFsOrDrivesFolder() const { return IsFSFolder() || IsFSDrivesFolder(); }
+ bool IsDeviceDrivesPrefix() const { return _currentFolderPrefix == L"\\\\.\\"; }
+ bool IsFsOrPureDrivesFolder() const { return IsFSFolder() || (IsFSDrivesFolder() && !IsDeviceDrivesPrefix()); }
+
+ UString GetFsPath() const;
+ UString GetDriveOrNetworkPrefix() const;
+
+ bool DoesItSupportOperations() const;
+
+ bool _processTimer;
+ bool _processNotify;
+
+ class CDisableTimerProcessing
+ {
+ bool _processTimerMem;
+ bool _processNotifyMem;
+
+ CPanel &_panel;
+ public:
+
+ CDisableTimerProcessing(CPanel &panel): _panel(panel)
+ {
+ Disable();
+ }
+ void Disable()
+ {
+ _processTimerMem = _panel._processTimer;
+ _processNotifyMem = _panel._processNotify;
+ _panel._processTimer = false;
+ _panel._processNotify = false;
+ }
+ void Restore()
+ {
+ _panel._processTimer = _processTimerMem;
+ _panel._processNotify = _processNotifyMem;
+ }
+ ~CDisableTimerProcessing()
+ {
+ Restore();
+ }
+ CDisableTimerProcessing& operator=(const CDisableTimerProcessing &) {; }
+ };
+
+ // bool _passwordIsDefined;
+ // UString _password;
+
+ void RefreshListCtrl();
+
+ void MessageBoxInfo(LPCWSTR message, LPCWSTR caption);
+ void MessageBox(LPCWSTR message);
+ void MessageBox(LPCWSTR message, LPCWSTR caption);
+ void MessageBoxMyError(LPCWSTR message);
+ void MessageBoxError(HRESULT errorCode, LPCWSTR caption);
+ void MessageBoxError(HRESULT errorCode);
+ void MessageBoxLastError(LPCWSTR caption);
+ void MessageBoxLastError();
+
+ void MessageBoxErrorForUpdate(HRESULT errorCode, UINT resourceID, UInt32 langID);
+
+ void MessageBoxErrorLang(UINT resourceID, UInt32 langID);
+
+ void OpenFocusedItemAsInternal();
+ void OpenSelectedItems(bool internal);
+
+ void OpenFolderExternal(int index);
+
+ void OpenFolder(int index);
+ HRESULT OpenParentArchiveFolder();
+ HRESULT OpenItemAsArchive(IInStream *inStream,
+ const CTempFileInfo &tempFileInfo,
+ const UString &virtualFilePath,
+ const UString &arcFormat,
+ bool &encrypted);
+ HRESULT OpenItemAsArchive(const UString &name, const UString &arcFormat, bool &encrypted);
+ HRESULT OpenItemAsArchive(int index);
+ void OpenItemInArchive(int index, bool tryInternal, bool tryExternal,
+ bool editMode);
+ HRESULT OnOpenItemChanged(const UString &folderPath, const UString &itemName, bool usePassword, const UString &password);
+ LRESULT OnOpenItemChanged(LPARAM lParam);
+
+ void OpenItem(int index, bool tryInternal, bool tryExternal);
+ void EditItem();
+ void EditItem(int index);
+
+ void RenameFile();
+ void ChangeComment();
+
+ void SetListViewMode(UInt32 index);
+ UInt32 GetListViewMode() const { return _ListViewMode; };
+ PROPID GetSortID() const { return _sortID; }
+
+ void ChangeFlatMode();
+ bool GetFlatMode() const { return _flatMode; };
+
+ void RefreshStatusBar();
+ void OnRefreshStatusBar();
+
+ void AddToArchive();
+
+ void GetFilePaths(const CRecordVector<UInt32> &indices, UStringVector &paths);
+ void ExtractArchives();
+ void TestArchives();
+
+ HRESULT CopyTo(const CRecordVector<UInt32> &indices, const UString &folder,
+ bool moveMode, bool showErrorMessages, UStringVector *messages,
+ bool &usePassword, UString &password);
+
+ HRESULT CopyTo(const CRecordVector<UInt32> &indices, const UString &folder,
+ bool moveMode, bool showErrorMessages, UStringVector *messages)
+ {
+ bool usePassword = false;
+ UString password;
+ if (_parentFolders.Size() > 0)
+ {
+ const CFolderLink &fl = _parentFolders.Back();
+ usePassword = fl.UsePassword;
+ password = fl.Password;
+ }
+ return CopyTo(indices, folder, moveMode, showErrorMessages, messages, usePassword, password);
+ }
+
+ HRESULT CopyFrom(const UString &folderPrefix, const UStringVector &filePaths,
+ bool showErrorMessages, UStringVector *messages);
+
+ void CopyFromNoAsk(const UStringVector &filePaths);
+ void CopyFromAsk(const UStringVector &filePaths);
+
+ // empty folderPath means create new Archive to path of first fileName.
+ #ifdef _WIN32
+ void DropObject(IDataObject * dataObject, const UString &folderPath);
+
+ // empty folderPath means create new Archive to path of first fileName.
+ void CompressDropFiles(const UStringVector &fileNames, const UString &folderPath);
+#endif
+
+ void RefreshTitle(bool always = false) { _panelCallback->RefreshTitle(always); }
+ void RefreshTitleAlways() { RefreshTitle(true); }
+
+ UString GetItemsInfoString(const CRecordVector<UInt32> &indices);
+};
+
+class CMyBuffer
+{
+ void *_data;
+public:
+ CMyBuffer(): _data(0) {}
+ operator void *() { return _data; }
+ bool Allocate(size_t size)
+ {
+ if (_data != 0)
+ return false;
+ _data = ::MidAlloc(size);
+ return _data != 0;
+ }
+ ~CMyBuffer() { ::MidFree(_data); }
+};
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelCopy.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelCopy.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelCopy.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelCopy.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,227 @@
+// PanelExtract.cpp
+
+#include "StdAfx.h"
+
+#include "Panel.h"
+#include "resource.h"
+#include "LangUtils.h"
+#include "ExtractCallback.h"
+#include "Windows/Thread.h"
+////////////////////////////////////////////////////////////////
+
+#include "UpdateCallback100.h"
+
+using namespace NWindows;
+
+class CPanelCopyThread: public CProgressThreadVirt
+{
+ HRESULT ProcessVirt();
+public:
+ CMyComPtr<IFolderOperations> FolderOperations;
+ CRecordVector<UInt32> Indices;
+ UString DestPath;
+ CExtractCallbackImp *ExtractCallbackSpec;
+ CMyComPtr<IFolderOperationsExtractCallback> ExtractCallback;
+ HRESULT Result;
+ bool MoveMode;
+
+ CPanelCopyThread(): MoveMode(false), Result(E_FAIL) {}
+};
+
+HRESULT CPanelCopyThread::ProcessVirt()
+{
+ if (MoveMode)
+ Result = FolderOperations->MoveTo(&Indices.Front(), Indices.Size(), DestPath, ExtractCallback);
+ else
+ Result = FolderOperations->CopyTo(&Indices.Front(), Indices.Size(), DestPath, ExtractCallback);
+ return Result;
+}
+
+HRESULT CPanel::CopyTo(const CRecordVector<UInt32> &indices, const UString &folder,
+ bool moveMode, bool showErrorMessages, UStringVector *messages,
+ bool &usePassword, UString &password)
+{
+ CMyComPtr<IFolderOperations> folderOperations;
+ if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
+ {
+ UString errorMessage = LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
+ if (showErrorMessages)
+ MessageBox(errorMessage);
+ else if (messages != 0)
+ messages->Add(errorMessage);
+ return E_FAIL;
+ }
+
+ HRESULT res;
+ {
+ CPanelCopyThread extracter;
+
+
+ extracter.ExtractCallbackSpec = new CExtractCallbackImp;
+ extracter.ExtractCallback = extracter.ExtractCallbackSpec;
+ extracter.ExtractCallbackSpec->ProgressDialog = &extracter.ProgressDialog;
+ extracter.ProgressDialog.CompressingMode = false;
+
+ UString title = moveMode ?
+ LangString(IDS_MOVING, 0x03020206):
+ LangString(IDS_COPYING, 0x03020205);
+ UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000);
+
+ extracter.ProgressDialog.MainWindow = GetParent();
+ extracter.ProgressDialog.MainTitle = progressWindowTitle;
+ extracter.ProgressDialog.MainAddTitle = title + L" ";
+
+ extracter.ExtractCallbackSpec->OverwriteMode = NExtract::NOverwriteMode::kAskBefore;
+ extracter.ExtractCallbackSpec->Init();
+ extracter.Indices = indices;
+ extracter.DestPath = folder;
+ extracter.FolderOperations = folderOperations;
+ extracter.MoveMode = moveMode;
+
+ extracter.ExtractCallbackSpec->PasswordIsDefined = usePassword;
+ extracter.ExtractCallbackSpec->Password = password;
+
+ RINOK(extracter.Create(title, GetParent()));
+
+ if (messages != 0)
+ *messages = extracter.ProgressDialog.Sync.Messages;
+ res = extracter.Result;
+
+ if (res == S_OK && extracter.ExtractCallbackSpec->IsOK())
+ {
+ usePassword = extracter.ExtractCallbackSpec->PasswordIsDefined;
+ password = extracter.ExtractCallbackSpec->Password;
+ }
+ }
+ RefreshTitleAlways();
+ return res;
+}
+
+
+struct CThreadUpdate
+{
+ CMyComPtr<IFolderOperations> FolderOperations;
+ UString FolderPrefix;
+ UStringVector FileNames;
+ CRecordVector<const wchar_t *> FileNamePointers;
+ CProgressDialog ProgressDialog;
+ CMyComPtr<IFolderArchiveUpdateCallback> UpdateCallback;
+ CUpdateCallback100Imp *UpdateCallbackSpec;
+ HRESULT Result;
+
+ void Process()
+ {
+ try
+ {
+ CProgressCloser closer(ProgressDialog);
+ Result = FolderOperations->CopyFrom(
+ FolderPrefix,
+ &FileNamePointers.Front(),
+ FileNamePointers.Size(),
+ UpdateCallback);
+ }
+ catch(...) { Result = E_FAIL; }
+ }
+ static THREAD_FUNC_DECL MyThreadFunction(void *param)
+ {
+ ((CThreadUpdate *)param)->Process();
+ return 0;
+ }
+};
+
+HRESULT CPanel::CopyFrom(const UString &folderPrefix, const UStringVector &filePaths,
+ bool showErrorMessages, UStringVector *messages)
+{
+ CMyComPtr<IFolderOperations> folderOperations;
+ _folder.QueryInterface(IID_IFolderOperations, &folderOperations);
+ HRESULT res;
+ if (!folderOperations)
+ res = E_NOINTERFACE;
+ else
+ {
+ CThreadUpdate updater;
+ updater.UpdateCallbackSpec = new CUpdateCallback100Imp;
+ updater.UpdateCallback = updater.UpdateCallbackSpec;
+
+ updater.UpdateCallbackSpec->ProgressDialog = &updater.ProgressDialog;
+
+ UString title = LangString(IDS_COPYING, 0x03020205);
+ UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000);
+
+ updater.ProgressDialog.MainWindow = GetParent();
+ updater.ProgressDialog.MainTitle = progressWindowTitle;
+ updater.ProgressDialog.MainAddTitle = title + UString(L" ");
+
+ updater.UpdateCallbackSpec->Init(false, L"");
+ updater.FolderOperations = folderOperations;
+ updater.FolderPrefix = folderPrefix;
+ updater.FileNames.Reserve(filePaths.Size());
+ int i;
+ for(i = 0; i < filePaths.Size(); i++)
+ updater.FileNames.Add(filePaths[i]);
+ updater.FileNamePointers.Reserve(updater.FileNames.Size());
+ for(i = 0; i < updater.FileNames.Size(); i++)
+ updater.FileNamePointers.Add(updater.FileNames[i]);
+
+ NWindows::CThread thread;
+ RINOK(thread.Create(CThreadUpdate::MyThreadFunction, &updater));
+ updater.ProgressDialog.Create(title, thread, GetParent());
+
+ if (messages != 0)
+ *messages = updater.ProgressDialog.Sync.Messages;
+
+ res = updater.Result;
+ }
+
+ if (res == E_NOINTERFACE)
+ {
+ UString errorMessage = LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
+ if (showErrorMessages)
+ MessageBox(errorMessage);
+ else if (messages != 0)
+ messages->Add(errorMessage);
+ return E_ABORT;
+ }
+
+ RefreshTitleAlways();
+ return res;
+}
+
+void CPanel::CopyFromNoAsk(const UStringVector &filePaths)
+{
+ CDisableTimerProcessing disableTimerProcessing(*this);
+
+ CSelectedState srcSelState;
+ SaveSelectedState(srcSelState);
+
+ HRESULT result = CopyFrom(L"", filePaths, true, 0);
+
+ if (result != S_OK)
+ {
+ disableTimerProcessing.Restore();
+ // For Password:
+ SetFocusToList();
+ if (result != E_ABORT)
+ MessageBoxError(result);
+ return;
+ }
+
+ RefreshListCtrl(srcSelState);
+
+ disableTimerProcessing.Restore();
+ SetFocusToList();
+}
+
+void CPanel::CopyFromAsk(const UStringVector &filePaths)
+{
+ UString title = LangString(IDS_CONFIRM_FILE_COPY, 0x03020222);
+ UString message = LangString(IDS_WANT_TO_COPY_FILES, 0x03020223);
+ message += L"\n\'";
+ message += _currentFolderPrefix;
+ message += L"\' ?";
+ int res = ::MessageBoxW(*(this), message, title, MB_YESNOCANCEL | MB_ICONQUESTION);
+ if (res != IDYES)
+ return;
+
+ CopyFromNoAsk(filePaths);
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelCrc.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelCrc.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelCrc.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelCrc.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,342 @@
+// PanelSplitFile.cpp
+
+#include "StdAfx.h"
+
+#include "../../../../C/7zCrc.h"
+#include "../../../../C/Sha256.h"
+
+#include "Common/IntToString.h"
+
+#include "Windows/FileFind.h"
+#include "Windows/FileIO.h"
+#include "Windows/FileName.h"
+
+#include "OverwriteDialogRes.h"
+
+#include "App.h"
+#include "FormatUtils.h"
+#include "LangUtils.h"
+
+#include "../Common/PropIDUtils.h"
+
+#include "resource.h"
+
+using namespace NWindows;
+using namespace NFile;
+
+static const UInt32 kBufSize = (1 << 15);
+
+struct CDirEnumerator
+{
+ bool FlatMode;
+ UString BasePrefix;
+ UStringVector FileNames;
+
+ CObjectVector<NFind::CEnumeratorW> Enumerators;
+ UStringVector Prefixes;
+ int Index;
+ HRESULT GetNextFile(NFind::CFileInfoW &fileInfo, bool &filled, UString &fullPath);
+ void Init();
+
+ CDirEnumerator(): FlatMode(false) {};
+};
+
+void CDirEnumerator::Init()
+{
+ Enumerators.Clear();
+ Prefixes.Clear();
+ Index = 0;
+}
+
+static HRESULT GetNormalizedError()
+{
+ HRESULT errorCode = GetLastError();
+ return (errorCode == 0) ? E_FAIL : errorCode;
+}
+
+HRESULT CDirEnumerator::GetNextFile(NFind::CFileInfoW &fileInfo, bool &filled, UString &resPath)
+{
+ filled = false;
+ for (;;)
+ {
+ if (Enumerators.IsEmpty())
+ {
+ if (Index >= FileNames.Size())
+ return S_OK;
+ const UString &path = FileNames[Index];
+ int pos = path.ReverseFind(WCHAR_PATH_SEPARATOR);
+ resPath.Empty();
+ if (pos >= 0)
+ resPath = path.Left(pos + 1);
+
+ #ifdef _WIN32
+ // it's for "c:" paths/
+ if (BasePrefix.IsEmpty() && path.Length() == 2 && path[1] == ':')
+ {
+ fileInfo.Name = path;
+ fileInfo.Attrib = FILE_ATTRIBUTE_DIRECTORY;
+ fileInfo.Size = 0;
+ }
+ else
+ #endif
+ if (!fileInfo.Find(BasePrefix + path))
+ {
+ WRes errorCode = GetNormalizedError();
+ resPath = path;
+ return errorCode;
+ }
+ Index++;
+ break;
+ }
+ bool found;
+ if (!Enumerators.Back().Next(fileInfo, found))
+ {
+ HRESULT errorCode = GetNormalizedError();
+ resPath = Prefixes.Back();
+ return errorCode;
+ }
+ if (found)
+ {
+ resPath = Prefixes.Back();
+ break;
+ }
+ Enumerators.DeleteBack();
+ Prefixes.DeleteBack();
+ }
+ resPath += fileInfo.Name;
+ if (!FlatMode && fileInfo.IsDir())
+ {
+ UString prefix = resPath + WCHAR_PATH_SEPARATOR;
+ Enumerators.Add(NFind::CEnumeratorW(BasePrefix + prefix + (UString)(wchar_t)NName::kAnyStringWildcard));
+ Prefixes.Add(prefix);
+ }
+ filled = true;
+ return S_OK;
+}
+
+static void ConvertByteToHex(unsigned value, wchar_t *s)
+{
+ for (int i = 0; i < 2; i++)
+ {
+ unsigned t = value & 0xF;
+ value >>= 4;
+ s[1 - i] = (wchar_t)((t < 10) ? (L'0' + t) : (L'A' + (t - 10)));
+ }
+}
+
+class CThreadCrc: public CProgressThreadVirt
+{
+ UInt64 NumFilesScan;
+ UInt64 NumFiles;
+ UInt64 NumFolders;
+ UInt64 DataSize;
+ UInt32 DataCrcSum;
+ Byte Sha256Sum[SHA256_DIGEST_SIZE];
+ UInt32 DataNameCrcSum;
+
+ UString GetResultMessage() const;
+ HRESULT ProcessVirt();
+public:
+ CDirEnumerator Enumerator;
+
+};
+
+UString CThreadCrc::GetResultMessage() const
+{
+ UString s;
+ wchar_t sz[32];
+
+ s += LangString(IDS_FILES_COLON, 0x02000320);
+ s += L' ';
+ ConvertUInt64ToString(NumFiles, sz);
+ s += sz;
+ s += L'\n';
+
+ s += LangString(IDS_FOLDERS_COLON, 0x02000321);
+ s += L' ';
+ ConvertUInt64ToString(NumFolders, sz);
+ s += sz;
+ s += L'\n';
+
+ s += LangString(IDS_SIZE_COLON, 0x02000322);
+ s += L' ';
+ ConvertUInt64ToString(DataSize, sz);
+ s += MyFormatNew(IDS_FILE_SIZE, 0x02000982, sz);
+ s += L'\n';
+
+ s += LangString(IDS_CHECKSUM_CRC_DATA, 0x03020721);
+ s += L' ';
+ ConvertUInt32ToHex(DataCrcSum, sz);
+ s += sz;
+ s += L'\n';
+
+ s += LangString(IDS_CHECKSUM_CRC_DATA_NAMES, 0x03020722);
+ s += L' ';
+ ConvertUInt32ToHex(DataNameCrcSum, sz);
+ s += sz;
+ s += L'\n';
+
+ if (NumFiles == 1 && NumFilesScan == 1)
+ {
+ s += L"SHA-256: ";
+ for (int i = 0; i < SHA256_DIGEST_SIZE; i++)
+ {
+ wchar_t s2[4];
+ ConvertByteToHex(Sha256Sum[i], s2);
+ s2[2] = 0;
+ s += s2;
+ }
+ }
+ return s;
+}
+
+HRESULT CThreadCrc::ProcessVirt()
+{
+ DataSize = NumFolders = NumFiles = NumFilesScan = DataCrcSum = DataNameCrcSum = 0;
+ memset(Sha256Sum, 0, SHA256_DIGEST_SIZE);
+ // ProgressDialog.WaitCreating();
+
+ CMyBuffer bufferObject;
+ if (!bufferObject.Allocate(kBufSize))
+ return E_OUTOFMEMORY;
+ Byte *buffer = (Byte *)(void *)bufferObject;
+
+ UInt64 totalSize = 0;
+
+ Enumerator.Init();
+
+ UString scanningStr = LangString(IDS_SCANNING, 0x03020800);
+ scanningStr += L' ';
+
+ CProgressSync &sync = ProgressDialog.Sync;
+
+ for (;;)
+ {
+ NFind::CFileInfoW fileInfo;
+ bool filled;
+ UString resPath;
+ HRESULT errorCode = Enumerator.GetNextFile(fileInfo, filled, resPath);
+ if (errorCode != 0)
+ {
+ ErrorPath1 = resPath;
+ return errorCode;
+ }
+ if (!filled)
+ break;
+ if (!fileInfo.IsDir())
+ {
+ totalSize += fileInfo.Size;
+ NumFilesScan++;
+ }
+ sync.SetCurrentFileName(scanningStr + resPath);
+ sync.SetProgress(totalSize, 0);
+ RINOK(sync.SetPosAndCheckPaused(0));
+ }
+ sync.SetNumFilesTotal(NumFilesScan);
+ sync.SetProgress(totalSize, 0);
+
+ Enumerator.Init();
+
+ for (;;)
+ {
+ NFind::CFileInfoW fileInfo;
+ bool filled;
+ UString resPath;
+ HRESULT errorCode = Enumerator.GetNextFile(fileInfo, filled, resPath);
+ if (errorCode != 0)
+ {
+ ErrorPath1 = resPath;
+ return errorCode;
+ }
+ if (!filled)
+ break;
+
+ UInt32 crc = CRC_INIT_VAL;
+ CSha256 sha256;
+ Sha256_Init(&sha256);
+
+ if (fileInfo.IsDir())
+ NumFolders++;
+ else
+ {
+ NIO::CInFile inFile;
+ if (!inFile.Open(Enumerator.BasePrefix + resPath))
+ {
+ errorCode = GetNormalizedError();
+ ErrorPath1 = resPath;
+ return errorCode;
+ }
+ sync.SetCurrentFileName(resPath);
+ sync.SetNumFilesCur(NumFiles);
+ NumFiles++;
+ for (;;)
+ {
+ UInt32 processedSize;
+ if (!inFile.Read(buffer, kBufSize, processedSize))
+ {
+ errorCode = GetNormalizedError();
+ ErrorPath1 = resPath;
+ return errorCode;
+ }
+ if (processedSize == 0)
+ break;
+ crc = CrcUpdate(crc, buffer, processedSize);
+ if (NumFilesScan == 1)
+ Sha256_Update(&sha256, buffer, processedSize);
+
+ DataSize += processedSize;
+ RINOK(sync.SetPosAndCheckPaused(DataSize));
+ }
+ DataCrcSum += CRC_GET_DIGEST(crc);
+ if (NumFilesScan == 1)
+ Sha256_Final(&sha256, Sha256Sum);
+ }
+ for (int i = 0; i < resPath.Length(); i++)
+ {
+ wchar_t c = resPath[i];
+ crc = CRC_UPDATE_BYTE(crc, ((Byte)(c & 0xFF)));
+ crc = CRC_UPDATE_BYTE(crc, ((Byte)((c >> 8) & 0xFF)));
+ }
+ DataNameCrcSum += CRC_GET_DIGEST(crc);
+ RINOK(sync.SetPosAndCheckPaused(DataSize));
+ }
+ sync.SetNumFilesCur(NumFiles);
+ OkMessage = GetResultMessage();
+ OkMessageTitle = LangString(IDS_CHECKSUM_INFORMATION, 0x03020720);
+ return S_OK;
+}
+
+void CApp::CalculateCrc()
+{
+ int srcPanelIndex = GetFocusedPanelIndex();
+ CPanel &srcPanel = Panels[srcPanelIndex];
+ if (!srcPanel.IsFsOrDrivesFolder())
+ {
+ srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
+ return;
+ }
+ CRecordVector<UInt32> indices;
+ srcPanel.GetOperatedItemIndices(indices);
+ if (indices.IsEmpty())
+ return;
+
+ {
+ CThreadCrc t;
+ for (int i = 0; i < indices.Size(); i++)
+ t.Enumerator.FileNames.Add(srcPanel.GetItemRelPath(indices[i]));
+ t.Enumerator.BasePrefix = srcPanel.GetFsPath();
+ t.Enumerator.FlatMode = GetFlatMode();
+
+ t.ProgressDialog.ShowCompressionInfo = false;
+
+ UString title = LangString(IDS_CHECKSUM_CALCULATING, 0x03020710);
+
+ t.ProgressDialog.MainWindow = _window;
+ t.ProgressDialog.MainTitle = LangString(IDS_APP_TITLE, 0x03000000);
+ t.ProgressDialog.MainAddTitle = title + UString(L' ');
+
+ if (t.Create(title, _window) != S_OK)
+ return;
+ }
+ RefreshTitleAlways();
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelCrc.cpp.back
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelCrc.cpp.back?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelCrc.cpp.back (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelCrc.cpp.back Sun Dec 16 23:23:25 2012
@@ -0,0 +1,368 @@
+// PanelSplitFile.cpp
+
+#include "StdAfx.h"
+
+#include "resource.h"
+
+extern "C"
+{
+ #include "../../../../C/Alloc.h"
+ #include "../../../../C/7zCrc.h"
+}
+
+#include "Common/IntToString.h"
+#include "Common/StringConvert.h"
+
+#include "Windows/FileIO.h"
+#include "Windows/FileFind.h"
+#include "Windows/FileName.h"
+#include "Windows/Thread.h"
+#include "Windows/Error.h"
+
+#include "ProgressDialog2.h"
+#include "OverwriteDialogRes.h"
+
+#include "App.h"
+#include "FormatUtils.h"
+#include "LangUtils.h"
+
+using namespace NWindows;
+using namespace NFile;
+using namespace NName;
+
+static const UInt32 kBufSize = (1 << 15);
+
+struct CDirEnumerator
+{
+ bool FlatMode;
+ UString BasePrefix;
+ UStringVector FileNames;
+
+ CObjectVector<NFind::CEnumeratorW> Enumerators;
+ UStringVector Prefixes;
+ int Index;
+ bool GetNextFile(NFind::CFileInfoW &fileInfo, bool &filled, UString &fullPath, DWORD &errorCode);
+ void Init();
+
+ CDirEnumerator(): FlatMode(false) {};
+};
+
+void CDirEnumerator::Init()
+{
+ Enumerators.Clear();
+ Prefixes.Clear();
+ Index = 0;
+}
+
+bool CDirEnumerator::GetNextFile(NFind::CFileInfoW &fileInfo, bool &filled, UString &resPath, DWORD &errorCode)
+{
+ filled = false;
+ for (;;)
+ {
+ if (Enumerators.IsEmpty())
+ {
+ if (Index >= FileNames.Size())
+ return true;
+ const UString &path = FileNames[Index];
+ int pos = path.ReverseFind('\\');
+ resPath.Empty();
+ if (pos >= 0)
+ resPath = path.Left(pos + 1);
+ if (!NFind::FindFile(BasePrefix + path, fileInfo))
+ {
+ errorCode = ::GetLastError();
+ resPath = path;
+ return false;
+ }
+ Index++;
+ break;
+ }
+ bool found;
+ if (!Enumerators.Back().Next(fileInfo, found))
+ {
+ errorCode = ::GetLastError();
+ resPath = Prefixes.Back();
+ return false;
+ }
+ if (found)
+ {
+ resPath = Prefixes.Back();
+ break;
+ }
+ Enumerators.DeleteBack();
+ Prefixes.DeleteBack();
+ }
+ resPath += fileInfo.Name;
+ if (!FlatMode && fileInfo.IsDir())
+ {
+ UString prefix = resPath + (UString)(wchar_t)kDirDelimiter;
+ Enumerators.Add(NFind::CEnumeratorW(BasePrefix + prefix + (UString)(wchar_t)kAnyStringWildcard));
+ Prefixes.Add(prefix);
+ }
+ filled = true;
+ return true;
+}
+
+struct CThreadCrc
+{
+ class CMyBuffer
+ {
+ void *_data;
+ public:
+ CMyBuffer(): _data(0) {}
+ operator void *() { return _data; }
+ bool Allocate(size_t size)
+ {
+ if (_data != 0)
+ return false;
+ _data = ::MidAlloc(size);
+ return _data != 0;
+ }
+ ~CMyBuffer() { ::MidFree(_data); }
+ };
+
+ CProgressDialog *ProgressDialog;
+
+ CDirEnumerator DirEnumerator;
+
+ UInt64 NumFiles;
+ UInt64 NumFolders;
+ UInt64 DataSize;
+ UInt32 DataCrcSum;
+ UInt32 DataNameCrcSum;
+
+ HRESULT Result;
+ DWORD ErrorCode;
+ UString ErrorPath;
+ UString Error;
+ bool ThereIsError;
+
+ void Process2()
+ {
+ DataSize = NumFolders = NumFiles = DataCrcSum = DataNameCrcSum = 0;
+ ProgressDialog->WaitCreating();
+
+ CMyBuffer bufferObject;
+ if (!bufferObject.Allocate(kBufSize))
+ {
+ Error = L"Can not allocate memory";
+ ThereIsError = true;
+ return;
+ }
+ Byte *buffer = (Byte *)(void *)bufferObject;
+
+ UInt64 totalSize = 0;
+
+ DirEnumerator.Init();
+
+ UString scanningStr = LangString(IDS_SCANNING, 0x03020800);
+ scanningStr += L" ";
+
+ for (;;)
+ {
+ NFile::NFind::CFileInfoW fileInfo;
+ bool filled;
+ UString resPath;
+ if (!DirEnumerator.GetNextFile(fileInfo, filled, resPath, ErrorCode))
+ {
+ ThereIsError = true;
+ ErrorPath = resPath;
+ return;
+ }
+ if (!filled)
+ break;
+ if (!fileInfo.IsDir())
+ totalSize += fileInfo.Size;
+ ProgressDialog->ProgressSynch.SetCurrentFileName(scanningStr + resPath);
+ ProgressDialog->ProgressSynch.SetProgress(totalSize, 0);
+ Result = ProgressDialog->ProgressSynch.SetPosAndCheckPaused(0);
+ if (Result != S_OK)
+ return;
+ }
+
+ ProgressDialog->ProgressSynch.SetProgress(totalSize, 0);
+
+ DirEnumerator.Init();
+
+ for (;;)
+ {
+ NFile::NFind::CFileInfoW fileInfo;
+ bool filled;
+ UString resPath;
+ if (!DirEnumerator.GetNextFile(fileInfo, filled, resPath, ErrorCode))
+ {
+ ThereIsError = true;
+ ErrorPath = resPath;
+ return;
+ }
+ if (!filled)
+ break;
+
+ UInt32 crc = CRC_INIT_VAL;
+ if (fileInfo.IsDir())
+ NumFolders++;
+ else
+ {
+ NFile::NIO::CInFile inFile;
+ if (!inFile.Open(DirEnumerator.BasePrefix + resPath))
+ {
+ ErrorCode = ::GetLastError();
+ ThereIsError = true;
+ ErrorPath = resPath;
+ return;
+ }
+ NumFiles++;
+ ProgressDialog->ProgressSynch.SetCurrentFileName(resPath);
+ for (;;)
+ {
+ UInt32 processedSize;
+ if (!inFile.Read(buffer, kBufSize, processedSize))
+ {
+ ErrorCode = ::GetLastError();
+ ThereIsError = true;
+ ErrorPath = resPath;
+ return;
+ }
+ if (processedSize == 0)
+ break;
+ crc = CrcUpdate(crc, buffer, processedSize);
+ DataSize += processedSize;
+ Result = ProgressDialog->ProgressSynch.SetPosAndCheckPaused(DataSize);
+ if (Result != S_OK)
+ return;
+ }
+ DataCrcSum += CRC_GET_DIGEST(crc);
+ }
+ for (int i = 0; i < resPath.Length(); i++)
+ {
+ wchar_t c = resPath[i];
+ crc = CRC_UPDATE_BYTE(crc, ((Byte)(c & 0xFF)));
+ crc = CRC_UPDATE_BYTE(crc, ((Byte)((c >> 8) & 0xFF)));
+ }
+ DataNameCrcSum += CRC_GET_DIGEST(crc);
+ Result = ProgressDialog->ProgressSynch.SetPosAndCheckPaused(DataSize);
+ if (Result != S_OK)
+ return;
+ }
+ }
+ DWORD Process()
+ {
+ try { Process2(); }
+ catch(...) { Error = L"Error"; ThereIsError = true;}
+ ProgressDialog->MyClose();
+ return 0;
+ }
+
+ static THREAD_FUNC_DECL MyThreadFunction(void *param)
+ {
+ return ((CThreadCrc *)param)->Process();
+ }
+};
+
+static void ConvertUInt32ToHex(UInt32 value, wchar_t *s)
+{
+ for (int i = 0; i < 8; i++)
+ {
+ int t = value & 0xF;
+ value >>= 4;
+ s[7 - i] = (wchar_t)((t < 10) ? (L'0' + t) : (L'A' + (t - 10)));
+ }
+ s[8] = L'\0';
+}
+
+void CApp::CalculateCrc()
+{
+ int srcPanelIndex = GetFocusedPanelIndex();
+ CPanel &srcPanel = Panels[srcPanelIndex];
+ if (!srcPanel.IsFSFolder())
+ {
+ srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
+ return;
+ }
+ CRecordVector<UInt32> indices;
+ srcPanel.GetOperatedItemIndices(indices);
+ if (indices.IsEmpty())
+ return;
+
+ CThreadCrc combiner;
+ for (int i = 0; i < indices.Size(); i++)
+ combiner.DirEnumerator.FileNames.Add(srcPanel.GetItemRelPath(indices[i]));
+ combiner.DirEnumerator.BasePrefix = srcPanel._currentFolderPrefix;
+ combiner.DirEnumerator.FlatMode = GetFlatMode();
+
+ {
+ CProgressDialog progressDialog;
+ combiner.ProgressDialog = &progressDialog;
+ combiner.ErrorCode = 0;
+ combiner.Result = S_OK;
+ combiner.ThereIsError = false;
+
+ UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000);
+ UString title = LangString(IDS_CHECKSUM_CALCULATING, 0x03020710);
+
+ progressDialog.MainWindow = _window;
+ progressDialog.MainTitle = progressWindowTitle;
+ progressDialog.MainAddTitle = title + UString(L" ");
+
+ NWindows::CThread thread;
+ if (thread.Create(CThreadCrc::MyThreadFunction, &combiner) != S_OK)
+ return;
+ progressDialog.Create(title, _window);
+
+ if (combiner.Result != S_OK)
+ {
+ if (combiner.Result != E_ABORT)
+ srcPanel.MessageBoxError(combiner.Result);
+ }
+ else if (combiner.ThereIsError)
+ {
+ if (combiner.Error.IsEmpty())
+ {
+ UString message = combiner.DirEnumerator.BasePrefix + combiner.ErrorPath;
+ message += L"\n";
+ message += NError::MyFormatMessageW(combiner.ErrorCode);
+ srcPanel.MessageBoxMyError(message);
+ }
+ else
+ srcPanel.MessageBoxMyError(combiner.Error);
+ }
+ else
+ {
+ UString s;
+ {
+ wchar_t sz[32];
+
+ s += LangString(IDS_FILES_COLON, 0x02000320);
+ s += L" ";
+ ConvertUInt64ToString(combiner.NumFiles, sz);
+ s += sz;
+ s += L"\n";
+
+ s += LangString(IDS_FOLDERS_COLON, 0x02000321);
+ s += L" ";
+ ConvertUInt64ToString(combiner.NumFolders, sz);
+ s += sz;
+ s += L"\n";
+
+ s += LangString(IDS_SIZE_COLON, 0x02000322);
+ s += L" ";
+ ConvertUInt64ToString(combiner.DataSize, sz);
+ s += MyFormatNew(IDS_FILE_SIZE, 0x02000982, sz);;
+ s += L"\n";
+
+ s += LangString(IDS_CHECKSUM_CRC_DATA, 0x03020721);
+ s += L" ";
+ ConvertUInt32ToHex(combiner.DataCrcSum, sz);
+ s += sz;
+ s += L"\n";
+
+ s += LangString(IDS_CHECKSUM_CRC_DATA_NAMES, 0x03020722);
+ s += L" ";
+ ConvertUInt32ToHex(combiner.DataNameCrcSum, sz);
+ s += sz;
+ }
+ srcPanel.MessageBoxInfo(s, LangString(IDS_CHECKSUM_INFORMATION, 0x03020720));
+ }
+ }
+ RefreshTitleAlways();
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelFolderChange.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelFolderChange.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelFolderChange.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelFolderChange.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,635 @@
+// PanelFolderChange.cpp
+
+#include "StdAfx.h"
+
+#include "Common/StringConvert.h"
+#include "Common/Wildcard.h"
+
+#include "Windows/PropVariant.h"
+
+#include "../../PropID.h"
+
+#ifdef UNDER_CE
+#include "FSFolder.h"
+#else
+#include "FSDrives.h"
+#endif
+#include "LangUtils.h"
+#include "ListViewDialog.h"
+#include "Panel.h"
+#include "RootFolder.h"
+#include "ViewSettings.h"
+
+#include "resource.h"
+
+using namespace NWindows;
+using namespace NFile;
+using namespace NFind;
+
+void CPanel::SetToRootFolder()
+{
+ _folder.Release();
+ _library.Free();
+ CRootFolder *rootFolderSpec = new CRootFolder;
+ _folder = rootFolderSpec;
+ rootFolderSpec->Init();
+}
+
+HRESULT CPanel::BindToPath(const UString &fullPath, const UString &arcFormat, bool &archiveIsOpened, bool &encrypted)
+{
+ archiveIsOpened = false;
+ encrypted = false;
+ CDisableTimerProcessing disableTimerProcessing1(*this);
+
+ printf("CPanel::BindToPath(%ls)\n",(const wchar_t *)fullPath);
+
+ if (_parentFolders.Size() > 0)
+ {
+ const UString &virtPath = _parentFolders.Back().VirtualPath;
+ if (fullPath.Left(virtPath.Length()) == virtPath)
+ {
+ for (;;)
+ {
+ CMyComPtr<IFolderFolder> newFolder;
+ HRESULT res = _folder->BindToParentFolder(&newFolder);
+ if (!newFolder || res != S_OK)
+ break;
+ _folder = newFolder;
+ }
+ UStringVector parts;
+ SplitPathToParts(fullPath.Mid(virtPath.Length()), parts);
+ for (int i = 0; i < parts.Size(); i++)
+ {
+ const UString &s = parts[i];
+ if ((i == 0 || i == parts.Size() - 1) && s.IsEmpty())
+ continue;
+ CMyComPtr<IFolderFolder> newFolder;
+ HRESULT res = _folder->BindToFolder(s, &newFolder);
+ if (!newFolder || res != S_OK)
+ break;
+ _folder = newFolder;
+ }
+ return S_OK;
+ }
+ }
+
+ CloseOpenFolders();
+ UString sysPath = fullPath;
+ CFileInfoW fileInfo;
+ UStringVector reducedParts;
+ while (!sysPath.IsEmpty())
+ {
+ if (fileInfo.Find(sysPath))
+ break;
+ int pos = sysPath.ReverseFind(WCHAR_PATH_SEPARATOR);
+ if (pos < 0)
+ sysPath.Empty();
+ else
+ {
+ if (reducedParts.Size() > 0 || pos < sysPath.Length() - 1)
+ reducedParts.Add(sysPath.Mid(pos + 1));
+ sysPath = sysPath.Left(pos);
+ }
+ }
+ SetToRootFolder();
+ CMyComPtr<IFolderFolder> newFolder;
+ if (sysPath.IsEmpty())
+ {
+ if (_folder->BindToFolder(fullPath, &newFolder) == S_OK)
+ _folder = newFolder;
+ }
+ else if (fileInfo.IsDir())
+ {
+ NName::NormalizeDirPathPrefix(sysPath);
+ if (_folder->BindToFolder(sysPath, &newFolder) == S_OK)
+ _folder = newFolder;
+ }
+ else
+ {
+ UString dirPrefix;
+ if (!NDirectory::GetOnlyDirPrefix(sysPath, dirPrefix))
+ dirPrefix.Empty();
+ if (_folder->BindToFolder(dirPrefix, &newFolder) == S_OK)
+ {
+ _folder = newFolder;
+ LoadFullPath();
+ UString fileName;
+ if (NDirectory::GetOnlyName(sysPath, fileName))
+ {
+ HRESULT res = OpenItemAsArchive(fileName, arcFormat, encrypted);
+ if (res != S_FALSE)
+ {
+ RINOK(res);
+ }
+ /*
+ if (res == E_ABORT)
+ return res;
+ */
+ if (res == S_OK)
+ {
+ archiveIsOpened = true;
+ for (int i = reducedParts.Size() - 1; i >= 0; i--)
+ {
+ CMyComPtr<IFolderFolder> newFolder;
+ _folder->BindToFolder(reducedParts[i], &newFolder);
+ if (!newFolder)
+ break;
+ _folder = newFolder;
+ }
+ }
+ }
+ }
+ }
+ return S_OK;
+}
+
+HRESULT CPanel::BindToPathAndRefresh(const UString &path)
+{
+ CDisableTimerProcessing disableTimerProcessing1(*this);
+ bool archiveIsOpened, encrypted;
+ RINOK(BindToPath(path, UString(), archiveIsOpened, encrypted));
+ RefreshListCtrl(UString(), -1, true, UStringVector());
+ return S_OK;
+}
+
+void CPanel::SetBookmark(int index)
+{
+ _appState->FastFolders.SetString(index, _currentFolderPrefix);
+}
+
+void CPanel::OpenBookmark(int index)
+{
+ BindToPathAndRefresh(_appState->FastFolders.GetString(index));
+}
+
+UString GetFolderPath(IFolderFolder *folder)
+{
+ NCOM::CPropVariant prop;
+ if (folder->GetFolderProperty(kpidPath, &prop) == S_OK)
+ if (prop.vt == VT_BSTR)
+ return (wchar_t *)prop.bstrVal;
+ return UString();
+}
+
+void CPanel::LoadFullPath()
+{
+ _currentFolderPrefix.Empty();
+ for (int i = 0; i < _parentFolders.Size(); i++)
+ {
+ const CFolderLink &folderLink = _parentFolders[i];
+ _currentFolderPrefix += GetFolderPath(folderLink.ParentFolder);
+ _currentFolderPrefix += folderLink.ItemName;
+ _currentFolderPrefix += WCHAR_PATH_SEPARATOR;
+ }
+ if (_folder)
+ _currentFolderPrefix += GetFolderPath(_folder);
+}
+
+static int GetRealIconIndex(LPCWSTR path, DWORD attributes)
+{
+ int index = -1;
+ if (GetRealIconIndex(path, attributes, index) != 0)
+ return index;
+ return -1;
+}
+
+void CPanel::LoadFullPathAndShow()
+{
+ LoadFullPath();
+ _appState->FolderHistory.AddString(_currentFolderPrefix);
+
+#ifdef _WIN32
+ _headerComboBox.SetText(_currentFolderPrefix);
+#else
+ {
+ extern const TCHAR * nameWindowToUnix(const TCHAR * lpFileName);
+ UString tmp = nameWindowToUnix(_currentFolderPrefix);
+ _headerComboBox.SetText(tmp);
+ }
+#endif
+
+#ifdef _WIN32 // FIXME
+ COMBOBOXEXITEM item;
+ item.mask = 0;
+
+ UString path = _currentFolderPrefix;
+ if (path.Length() >
+ #ifdef _WIN32
+ 3
+ #else
+ 1
+ #endif
+ && path[path.Length() - 1] == WCHAR_PATH_SEPARATOR)
+ path.Delete(path.Length() - 1);
+
+ CFileInfoW info;
+ DWORD attrib = FILE_ATTRIBUTE_DIRECTORY;
+ if (info.Find(path))
+ attrib = info.Attrib;
+
+ item.iImage = GetRealIconIndex(path, attrib);
+
+ if (item.iImage >= 0)
+ {
+ item.iSelectedImage = item.iImage;
+ item.mask |= (CBEIF_IMAGE | CBEIF_SELECTEDIMAGE);
+ }
+ item.iItem = -1;
+ _headerComboBox.SetItem(&item);
+#endif
+
+ RefreshTitle();
+}
+
+#ifndef UNDER_CE
+LRESULT CPanel::OnNotifyComboBoxEnter(const UString &s)
+{
+ if (BindToPathAndRefresh(GetUnicodeString(s)) == S_OK)
+ {
+ // FIXME PostMessage(kSetFocusToListView);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+bool CPanel::OnNotifyComboBoxEndEdit(PNMCBEENDEDITW info, LRESULT &result)
+{
+ if (info->iWhy == CBENF_ESCAPE)
+ {
+ _headerComboBox.SetText(_currentFolderPrefix);
+ // FIXME PostMessage(kSetFocusToListView);
+ result = FALSE;
+ return true;
+ }
+
+ /*
+ if (info->iWhy == CBENF_DROPDOWN)
+ {
+ result = FALSE;
+ return true;
+ }
+ */
+
+ if (info->iWhy == CBENF_RETURN)
+ {
+ // When we use Edit control and press Enter.
+ UString s;
+ _headerComboBox.GetText(s);
+ result = OnNotifyComboBoxEnter(s);
+ return true;
+ }
+ return false;
+}
+#endif
+
+#ifndef _UNICODE
+bool CPanel::OnNotifyComboBoxEndEdit(PNMCBEENDEDIT info, LRESULT &result)
+{
+ if (info->iWhy == CBENF_ESCAPE)
+ {
+ _headerComboBox.SetText(_currentFolderPrefix);
+ PostMessage(kSetFocusToListView);
+ result = FALSE;
+ return true;
+ }
+ /*
+ if (info->iWhy == CBENF_DROPDOWN)
+ {
+ result = FALSE;
+ return true;
+ }
+ */
+
+ if (info->iWhy == CBENF_RETURN)
+ {
+ UString s;
+ _headerComboBox.GetText(s);
+ // GetUnicodeString(info->szText)
+ result = OnNotifyComboBoxEnter(s);
+ return true;
+ }
+ return false;
+}
+#endif
+
+#ifdef _WIN32
+void CPanel::AddComboBoxItem(const UString &name, int iconIndex, int indent, bool addToList)
+{
+ #ifdef UNDER_CE
+
+ UString s;
+ iconIndex = iconIndex;
+ for (int i = 0; i < indent; i++)
+ s += L" ";
+ _headerComboBox.AddString(s + name);
+
+ #else
+
+ COMBOBOXEXITEMW item;
+ item.mask = CBEIF_TEXT | CBEIF_INDENT;
+ item.iSelectedImage = item.iImage = iconIndex;
+ if (iconIndex >= 0)
+ item.mask |= (CBEIF_IMAGE | CBEIF_SELECTEDIMAGE);
+ item.iItem = -1;
+ item.iIndent = indent;
+ item.pszText = (LPWSTR)(LPCWSTR)name;
+ _headerComboBox.InsertItem(&item);
+
+ #endif
+
+ if (addToList)
+ ComboBoxPaths.Add(name);
+}
+
+extern UString RootFolder_GetName_Computer(int &iconIndex);
+extern UString RootFolder_GetName_Network(int &iconIndex);
+extern UString RootFolder_GetName_Documents(int &iconIndex);
+#endif
+
+
+bool CPanel::OnComboBoxCommand(UINT code, LPARAM /* param */, LRESULT &result)
+{
+#ifdef _WIN32 // FIXME
+ result = FALSE;
+ switch(code)
+ {
+ case CBN_DROPDOWN:
+ {
+ ComboBoxPaths.Clear();
+ _headerComboBox.ResetContent();
+
+ int i;
+ UStringVector pathParts;
+
+ SplitPathToParts(_currentFolderPrefix, pathParts);
+ UString sumPass;
+ if (!pathParts.IsEmpty())
+ pathParts.DeleteBack();
+ for (i = 0; i < pathParts.Size(); i++)
+ {
+ UString name = pathParts[i];
+ sumPass += name;
+ sumPass += WCHAR_PATH_SEPARATOR;
+ CFileInfoW info;
+ DWORD attrib = FILE_ATTRIBUTE_DIRECTORY;
+ if (info.Find(sumPass))
+ attrib = info.Attrib;
+ AddComboBoxItem(name.IsEmpty() ? L"\\" : name, GetRealIconIndex(sumPass, attrib), i, false);
+ ComboBoxPaths.Add(sumPass);
+ }
+
+ #ifndef UNDER_CE
+
+ int iconIndex;
+ UString name;
+ name = RootFolder_GetName_Documents(iconIndex);
+ AddComboBoxItem(name, iconIndex, 0, true);
+
+ name = RootFolder_GetName_Computer(iconIndex);
+ AddComboBoxItem(name, iconIndex, 0, true);
+
+ UStringVector driveStrings;
+ MyGetLogicalDriveStrings(driveStrings);
+ for (i = 0; i < driveStrings.Size(); i++)
+ {
+ UString s = driveStrings[i];
+ ComboBoxPaths.Add(s);
+ int iconIndex = GetRealIconIndex(s, 0);
+ if (s.Length() > 0 && s[s.Length() - 1] == WCHAR_PATH_SEPARATOR)
+ s.Delete(s.Length() - 1);
+ AddComboBoxItem(s, iconIndex, 1, false);
+ }
+
+ name = RootFolder_GetName_Network(iconIndex);
+ AddComboBoxItem(name, iconIndex, 0, true);
+
+ #endif
+
+ return false;
+ }
+
+ case CBN_SELENDOK:
+ {
+ code = code;
+ int index = _headerComboBox.GetCurSel();
+ if (index >= 0)
+ {
+ UString pass = ComboBoxPaths[index];
+ _headerComboBox.SetCurSel(-1);
+ // _headerComboBox.SetText(pass); // it's fix for seclecting by mouse.
+ if (BindToPathAndRefresh(pass) == S_OK)
+ {
+ PostMessage(kSetFocusToListView);
+ #ifdef UNDER_CE
+ PostMessage(kRefreshHeaderComboBox);
+ #endif
+
+ return true;
+ }
+ }
+ return false;
+ }
+ /*
+ case CBN_CLOSEUP:
+ {
+ LoadFullPathAndShow();
+ true;
+
+ }
+ case CBN_SELCHANGE:
+ {
+ // LoadFullPathAndShow();
+ return true;
+ }
+ */
+ }
+#endif
+ return false;
+}
+
+bool CPanel::OnNotifyComboBox(LPNMHDR header, LRESULT &result)
+{
+ #ifndef UNDER_CE
+ switch(header->code)
+ {
+ case CBEN_BEGINEDIT:
+ {
+ _lastFocusedIsList = false;
+ _panelCallback->PanelWasFocused();
+ break;
+ }
+#ifdef _WIN32
+ #ifndef _UNICODE
+ case CBEN_ENDEDIT:
+ {
+ return OnNotifyComboBoxEndEdit((PNMCBEENDEDIT)header, result);
+ }
+ #endif
+#endif // #ifdef _WIN32
+ case CBEN_ENDEDITW:
+ {
+ return OnNotifyComboBoxEndEdit((PNMCBEENDEDITW)header, result);
+ }
+ }
+ #endif
+ return false;
+}
+
+
+void CPanel::FoldersHistory()
+{
+ CListViewDialog listViewDialog;
+ listViewDialog.DeleteIsAllowed = true;
+ listViewDialog.Title = LangString(IDS_FOLDERS_HISTORY, 0x03020260);
+ _appState->FolderHistory.GetList(listViewDialog.Strings);
+ if (listViewDialog.Create(GetParent()) == IDCANCEL)
+ return;
+ UString selectString;
+ if (listViewDialog.StringsWereChanged)
+ {
+ _appState->FolderHistory.RemoveAll();
+ for (int i = listViewDialog.Strings.Size() - 1; i >= 0; i--)
+ _appState->FolderHistory.AddString(listViewDialog.Strings[i]);
+ if (listViewDialog.FocusedItemIndex >= 0)
+ selectString = listViewDialog.Strings[listViewDialog.FocusedItemIndex];
+ }
+ else
+ {
+ if (listViewDialog.FocusedItemIndex >= 0)
+ selectString = listViewDialog.Strings[listViewDialog.FocusedItemIndex];
+ }
+ if (listViewDialog.FocusedItemIndex >= 0)
+ BindToPathAndRefresh(selectString);
+}
+
+void CPanel::OpenParentFolder()
+{
+printf("CPanel::OpenParentFolder\n");
+ LoadFullPath(); // Maybe we don't need it ??
+ UString focucedName;
+ if (!_currentFolderPrefix.IsEmpty() &&
+ _currentFolderPrefix.Back() == WCHAR_PATH_SEPARATOR)
+ {
+ focucedName = _currentFolderPrefix;
+ focucedName.DeleteBack();
+ if (focucedName != L"\\\\.")
+ {
+ int pos = focucedName.ReverseFind(WCHAR_PATH_SEPARATOR);
+ if (pos >= 0)
+ focucedName = focucedName.Mid(pos + 1);
+ }
+ }
+
+ printf("CPanel::OpenParentFolder focucedName=%ls\n",(const wchar_t *)focucedName);
+
+ CDisableTimerProcessing disableTimerProcessing1(*this);
+ CMyComPtr<IFolderFolder> newFolder;
+ _folder->BindToParentFolder(&newFolder);
+ if (newFolder)
+ _folder = newFolder;
+ else
+ {
+ if (_parentFolders.IsEmpty())
+ {
+ SetToRootFolder();
+ if (focucedName.IsEmpty())
+ focucedName = GetItemName(0);
+ }
+ else
+ {
+ _folder.Release();
+ _library.Free();
+ CFolderLink &link = _parentFolders.Back();
+ _folder = link.ParentFolder;
+ _library.Attach(link.Library.Detach());
+ focucedName = link.ItemName;
+ if (_parentFolders.Size() > 1)
+ OpenParentArchiveFolder();
+ _parentFolders.DeleteBack();
+ if (_parentFolders.IsEmpty())
+ _flatMode = _flatModeForDisk;
+ }
+ }
+
+ UStringVector selectedItems;
+ /*
+ if (!focucedName.IsEmpty())
+ selectedItems.Add(focucedName);
+ */
+ LoadFullPath();
+ // ::SetCurrentDirectory(::_currentFolderPrefix);
+ RefreshListCtrl(focucedName, -1, true, selectedItems);
+ _listView.EnsureVisible(_listView.GetFocusedItem(), false);
+ RefreshStatusBar();
+
+ printf("CPanel::OpenParentFolder-end\n");
+}
+
+void CPanel::CloseOpenFolders()
+{
+ while (_parentFolders.Size() > 0)
+ {
+ _folder.Release();
+ _library.Free();
+ _folder = _parentFolders.Back().ParentFolder;
+ _library.Attach(_parentFolders.Back().Library.Detach());
+ if (_parentFolders.Size() > 1)
+ OpenParentArchiveFolder();
+ _parentFolders.DeleteBack();
+ }
+ _flatMode = _flatModeForDisk;
+ _folder.Release();
+ _library.Free();
+}
+
+void CPanel::OpenRootFolder()
+{
+ CDisableTimerProcessing disableTimerProcessing1(*this);
+ _parentFolders.Clear();
+ SetToRootFolder();
+ RefreshListCtrl(UString(), -1, true, UStringVector());
+ // ::SetCurrentDirectory(::_currentFolderPrefix);
+ /*
+ BeforeChangeFolder();
+ _currentFolderPrefix.Empty();
+ AfterChangeFolder();
+ SetCurrentPathText();
+ RefreshListCtrl(UString(), 0, UStringVector());
+ _listView.EnsureVisible(_listView.GetFocusedItem(), false);
+ */
+}
+
+void CPanel::OpenDrivesFolder()
+{
+ CloseOpenFolders();
+ #ifdef UNDER_CE
+ NFsFolder::CFSFolder *folderSpec = new NFsFolder::CFSFolder;
+ _folder = folderSpec;
+ folderSpec->InitToRoot();
+ #else
+ CFSDrives *folderSpec = new CFSDrives;
+ _folder = folderSpec;
+ folderSpec->Init();
+ #endif
+ RefreshListCtrl();
+}
+
+void CPanel::OpenFolder(int index)
+{
+ if (index == kParentIndex)
+ {
+ OpenParentFolder();
+ return;
+ }
+ CMyComPtr<IFolderFolder> newFolder;
+ _folder->BindToFolder(index, &newFolder);
+ if (!newFolder)
+ return;
+ _folder = newFolder;
+ LoadFullPath();
+ // ::SetCurrentDirectory(::_currentFolderPrefix);
+ RefreshListCtrl();
+ UINT state = LVIS_SELECTED;
+ _listView.SetItemState(_listView.GetFocusedItem(), state, state);
+ _listView.EnsureVisible(_listView.GetFocusedItem(), false);
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelItemOpen.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelItemOpen.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelItemOpen.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelItemOpen.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,750 @@
+// PanelItemOpen.cpp
+
+#include "StdAfx.h"
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx/wx.h"
+#endif
+#include "wx/mimetype.h"
+
+#undef _WIN32
+
+#include "resource.h"
+
+#include "Common/StringConvert.h"
+// FIXME #include "Common/Random.h"
+#include "Common/StringConvert.h"
+#include "Common/AutoPtr.h"
+
+#include "Windows/FileDir.h"
+#include "Windows/FileFind.h"
+#include "Windows/Thread.h"
+#include "Windows/Synchronization.h"
+#include "Windows/Error.h"
+#include "Windows/PropVariant.h"
+
+#include "App.h"
+
+#include "ExtractCallback.h"
+#include "UpdateCallback100.h"
+#include "IFolder.h"
+#include "FileFolderPluginOpen.h"
+#include "FormatUtils.h"
+#include "Panel.h"
+#include "RegistryUtils.h"
+#include "LangUtils.h"
+
+using namespace NWindows;
+using namespace NSynchronization;
+using namespace NFile;
+using namespace NDirectory;
+
+extern HWND g_HWND;
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
+
+#ifndef _WIN32
+void CloseHandle(HANDLE) {}
+#endif
+
+static const wchar_t *kTempDirPrefix = L"7zO";
+
+
+static bool IsNameVirus(const UString &name)
+{
+ return (name.Find(L" ") >= 0);
+}
+
+struct CTmpProcessInfo: public CTempFileInfo
+{
+ HANDLE ProcessHandle;
+ HWND Window;
+ UString FullPathFolderPrefix;
+ bool UsePassword;
+ UString Password;
+ CTmpProcessInfo(): UsePassword(false) {}
+};
+
+class CTmpProcessInfoRelease
+{
+ CTmpProcessInfo *_tmpProcessInfo;
+public:
+ bool _needDelete;
+ CTmpProcessInfoRelease(CTmpProcessInfo &tmpProcessInfo):
+ _tmpProcessInfo(&tmpProcessInfo), _needDelete(true) {}
+ ~CTmpProcessInfoRelease()
+ {
+ if (_needDelete)
+ _tmpProcessInfo->DeleteDirAndFile();
+ }
+};
+
+HRESULT CPanel::OpenItemAsArchive(IInStream *inStream,
+ const CTempFileInfo &tempFileInfo,
+ const UString &virtualFilePath,
+ const UString &arcFormat,
+ bool &encrypted)
+{
+ encrypted = false;
+ CFolderLink folderLink;
+ (CTempFileInfo &)folderLink = tempFileInfo;
+ if (inStream)
+ folderLink.IsVirtual = true;
+ else
+ {
+ if (!folderLink.FileInfo.Find(folderLink.FilePath))
+ return ::GetLastError();
+ if (folderLink.FileInfo.IsDir())
+ return S_FALSE;
+ folderLink.IsVirtual = false;
+ }
+
+ folderLink.VirtualPath = virtualFilePath;
+
+ CMyComPtr<IFolderFolder> newFolder;
+
+ // _passwordIsDefined = false;
+ // _password.Empty();
+
+ NDLL::CLibrary library;
+
+ UString password;
+ RINOK(OpenFileFolderPlugin(inStream,
+ folderLink.FilePath.IsEmpty() ? virtualFilePath : folderLink.FilePath,
+ arcFormat,
+ &library, &newFolder, GetParent(), encrypted, password));
+
+ folderLink.Password = password;
+ folderLink.UsePassword = encrypted;
+
+ folderLink.ParentFolder = _folder;
+ _parentFolders.Add(folderLink);
+ _parentFolders.Back().Library.Attach(_library.Detach());
+
+ _folder.Release();
+ _library.Free();
+ _folder = newFolder;
+ _library.Attach(library.Detach());
+
+ _flatMode = _flatModeForArc;
+
+ CMyComPtr<IGetFolderArcProps> getFolderArcProps;
+ _folder.QueryInterface(IID_IGetFolderArcProps, &getFolderArcProps);
+ if (getFolderArcProps)
+ {
+ CMyComPtr<IFolderArcProps> arcProps;
+ getFolderArcProps->GetFolderArcProps(&arcProps);
+ if (arcProps)
+ {
+ UString s;
+ UInt32 numLevels;
+ if (arcProps->GetArcNumLevels(&numLevels) != S_OK)
+ numLevels = 0;
+ for (UInt32 level2 = 0; level2 < numLevels; level2++)
+ {
+ UInt32 level = numLevels - 1 - level2;
+ PROPID propIDs[] = { kpidError, kpidPath, kpidType } ;
+ UString values[3];
+ for (Int32 i = 0; i < 3; i++)
+ {
+ CMyComBSTR name;
+ NCOM::CPropVariant prop;
+ if (arcProps->GetArcProp(level, propIDs[i], &prop) != S_OK)
+ continue;
+ if (prop.vt != VT_EMPTY)
+ values[i] = (prop.vt == VT_BSTR) ? prop.bstrVal : L"?";
+ }
+ if (!values[0].IsEmpty())
+ {
+ if (!s.IsEmpty())
+ s += L"--------------------\n";
+ s += values[0]; s += L"\n\n[";
+ s += values[2]; s += L"] ";
+ s += values[1]; s += L"\n";
+ }
+ }
+ if (!s.IsEmpty())
+ MessageBox(s);
+ }
+ }
+
+ return S_OK;
+}
+
+HRESULT CPanel::OpenItemAsArchive(const UString &name, const UString &arcFormat, bool &encrypted)
+{
+ CTempFileInfo tfi;
+ tfi.ItemName = name;
+ tfi.FolderPath = _currentFolderPrefix;
+ tfi.FilePath = _currentFolderPrefix + name;
+ return OpenItemAsArchive(NULL, tfi, _currentFolderPrefix + name, arcFormat, encrypted);
+}
+
+HRESULT CPanel::OpenItemAsArchive(int index)
+{
+ CDisableTimerProcessing disableTimerProcessing1(*this);
+ bool encrypted;
+ RINOK(OpenItemAsArchive(GetItemRelPath(index), UString(), encrypted));
+ RefreshListCtrl();
+ return S_OK;
+}
+
+HRESULT CPanel::OpenParentArchiveFolder()
+{
+ CDisableTimerProcessing disableTimerProcessing1(*this);
+ if (_parentFolders.Size() < 2)
+ return S_OK;
+ CFolderLink &folderLink = _parentFolders.Back();
+ NFind::CFileInfoW newFileInfo;
+ if (NFind::FindFile(folderLink.FilePath, newFileInfo))
+ {
+ if (newFileInfo.Size != folderLink.FileInfo.Size ||
+ CompareFileTime(&newFileInfo.MTime, &folderLink.FileInfo.MTime) != 0)
+ {
+ UString message = MyFormatNew(IDS_WANT_UPDATE_MODIFIED_FILE,
+ 0x03020280, folderLink.ItemName);
+ if (::MessageBoxW(HWND(*this), message, L"7-Zip", MB_OKCANCEL | MB_ICONQUESTION) == IDOK)
+ {
+ if (OnOpenItemChanged(folderLink.FolderPath, folderLink.ItemName,
+ folderLink.UsePassword, folderLink.Password) != S_OK)
+ {
+ ::MessageBoxW(HWND(*this), MyFormatNew(IDS_CANNOT_UPDATE_FILE,
+ 0x03020281, folderLink.FilePath), L"7-Zip", MB_OK | MB_ICONSTOP);
+ return S_OK;
+ }
+ }
+ }
+ }
+ folderLink.DeleteDirAndFile();
+ return S_OK;
+}
+
+static const wchar_t *kStartExtensions[] =
+{
+ #ifdef UNDER_CE
+ L"cab",
+ #endif
+ L"exe", L"bat", L"com",
+ L"chm",
+ L"msi", L"doc", L"xls", L"ppt", L"pps", L"wps", L"wpt", L"wks", L"xlr", L"wdb",
+
+ L"docx", L"docm", L"dotx", L"dotm", L"xlsx", L"xlsm", L"xltx", L"xltm", L"xlsb",
+ L"xlam", L"pptx", L"pptm", L"potx", L"potm", L"ppam", L"ppsx", L"ppsm", L"xsn",
+ L"msg",
+ L"dwf",
+
+ L"flv", L"swf",
+
+ L"odt", L"ods",
+ L"wb3",
+ L"pdf"
+};
+
+static bool DoItemAlwaysStart(const UString &name)
+{
+ int extPos = name.ReverseFind('.');
+ if (extPos < 0)
+ return false;
+ UString ext = name.Mid(extPos + 1);
+ ext.MakeLower();
+ for (int i = 0; i < sizeof(kStartExtensions) / sizeof(kStartExtensions[0]); i++)
+ if (ext.Compare(kStartExtensions[i]) == 0)
+ return true;
+ return false;
+}
+
+static UString GetQuotedString(const UString &s)
+{
+ return UString(L'\"') + s + UString(L'\"');
+}
+
+static HANDLE StartEditApplication(const UString &path, HWND window)
+{
+ UString command;
+ ReadRegEditor(command);
+ if (command.IsEmpty())
+ {
+#ifdef _WIN32
+ if (!MyGetWindowsDirectory(command))
+ return 0;
+ NFile::NName::NormalizeDirPathPrefix(command);
+ command += L"notepad.exe";
+#else
+ command += L"vi";
+#endif // _WIN32
+ }
+ command = UString(L"\"") + command + UString(L"\"");
+ command += L" \"";
+ command += UString(path);
+ command += L"\"";
+
+#ifdef _WIN32
+ PROCESS_INFORMATION processInformation;
+ BOOL result;
+ #ifndef _UNICODE
+ if (!g_IsNT)
+ {
+ STARTUPINFOA startupInfo;
+ startupInfo.cb = sizeof(startupInfo);
+ startupInfo.lpReserved = 0;
+ startupInfo.lpDesktop = 0;
+ startupInfo.lpTitle = 0;
+ startupInfo.dwFlags = 0;
+ startupInfo.cbReserved2 = 0;
+ startupInfo.lpReserved2 = 0;
+
+ result = ::CreateProcessA(NULL, (CHAR *)(const CHAR *)GetSystemString(command),
+ NULL, NULL, FALSE, 0, NULL, NULL, &startupInfo, &processInformation);
+ }
+ else
+ #endif
+ {
+ STARTUPINFOW startupInfo;
+ startupInfo.cb = sizeof(startupInfo);
+ startupInfo.lpReserved = 0;
+ startupInfo.lpDesktop = 0;
+ startupInfo.lpTitle = 0;
+ startupInfo.dwFlags = 0;
+ startupInfo.cbReserved2 = 0;
+ startupInfo.lpReserved2 = 0;
+
+ result = ::CreateProcessW(NULL, (WCHAR *)(const WCHAR *)command,
+ NULL, NULL, FALSE, 0, NULL, NULL, &startupInfo, &processInformation);
+ }
+
+ if (result != FALSE)
+ {
+ ::CloseHandle(processInformation.hThread);
+ return processInformation.hProcess;
+ }
+#else
+ wxString cmd = (const wchar_t *)command;
+ long pid = wxExecute(cmd, wxEXEC_ASYNC);
+ if (pid) return 0;
+#endif
+ ::MessageBoxW(window, LangString(IDS_CANNOT_START_EDITOR, 0x03020282),
+ L"7-Zip", MB_OK | MB_ICONSTOP);
+ return 0;
+}
+
+void CApp::DiffFiles()
+{
+ const CPanel &panel = GetFocusedPanel();
+
+ CRecordVector<UInt32> indices;
+ panel.GetSelectedItemsIndices(indices);
+
+ UString path1, path2;
+ if (indices.Size() == 2)
+ {
+ path1 = panel.GetItemFullPath(indices[0]);
+ path2 = panel.GetItemFullPath(indices[1]);
+ }
+ else if (indices.Size() == 1 && NumPanels >= 2)
+ {
+ const CPanel &destPanel = Panels[1 - LastFocusedPanel];
+ path1 = panel.GetItemFullPath(indices[0]);
+ const UString relPath = panel.GetItemRelPath(indices[0]);
+ CRecordVector<UInt32> indices2;
+ destPanel.GetSelectedItemsIndices(indices2);
+ if (indices2.Size() == 1)
+ path2 = destPanel.GetItemFullPath(indices2[0]);
+ else
+ path2 = destPanel._currentFolderPrefix + relPath;
+ }
+ else
+ return;
+
+ UString command;
+ ReadRegDiff(command);
+ if (command.IsEmpty())
+ return;
+
+ UString param = GetQuotedString(path1) + L' ' + GetQuotedString(path2);
+
+#ifdef _WIN32
+ HRESULT res = MyCreateProcess(command, param);
+ if (res == SZ_OK)
+ return;
+#else
+ wxString cmd = (const wchar_t *)command;
+ cmd += L" ";
+ cmd += (const wchar_t *)param;
+
+ long pid = wxExecute(cmd, wxEXEC_ASYNC);
+ if (pid) return ;
+#endif
+ ::MessageBoxW(_window, LangString(IDS_CANNOT_START_EDITOR, 0x03020282), L"7-Zip", MB_OK | MB_ICONSTOP);
+}
+
+#ifndef _UNICODE
+typedef BOOL (WINAPI * ShellExecuteExWP)(LPSHELLEXECUTEINFOW lpExecInfo);
+#endif
+
+static HANDLE StartApplication(const UString &path, HWND window)
+{
+ // FIXME
+ extern const TCHAR * nameWindowToUnix(const TCHAR * lpFileName);
+ UString tmpPath = path;
+
+ wxString filename(nameWindowToUnix(tmpPath));
+
+
+ wxString ext = filename.AfterLast(_T('.'));
+
+ printf("StartApplication(%ls) ext='%ls'\n",(const wchar_t *)filename,(const wchar_t *)ext);
+
+ if ( ! ext.empty() )
+ {
+ wxFileType *ft = wxTheMimeTypesManager->GetFileTypeFromExtension(ext);
+ // printf("StartApplication(%ls) ft=%p\n",(const wchar_t *)filename,ft);
+ if (ft)
+ {
+ wxString cmd;
+ // wxString type; ft->GetMimeType(&type);
+ wxFileType::MessageParameters params(filename); // , type);
+ bool ok = ft->GetOpenCommand(&cmd, params);
+ // printf("StartApplication(%ls) ok=%d\n",(const wchar_t *)filename,(int)ok);
+ delete ft;
+ if ( ok )
+ {
+ printf("StartApplication(%ls) cmd='%ls'\n",(const wchar_t *)filename,(const wchar_t *)cmd);
+ long pid = wxExecute(cmd, wxEXEC_ASYNC);
+ if (pid) return 0;
+ }
+ }
+ }
+ ::MessageBoxW(window,
+ // NError::MyFormatMessageW(::GetLastError()),
+ L"There is no application associated with the given file name extension",
+ L"7-Zip", MB_OK | MB_ICONSTOP);
+ return 0;
+}
+
+void CPanel::EditItem(int index)
+{
+ if (!_parentFolders.IsEmpty())
+ {
+ OpenItemInArchive(index, false, true, true);
+ return;
+ }
+ HANDLE hProcess = StartEditApplication(_currentFolderPrefix + GetItemRelPath(index), (HWND)*this);
+ if (hProcess != 0)
+ ::CloseHandle(hProcess);
+}
+
+void CPanel::OpenFolderExternal(int index)
+{
+ HANDLE hProcess = StartApplication(GetFsPath() + GetItemRelPath(index), (HWND)*this);
+ if (hProcess != 0)
+ ::CloseHandle(hProcess);
+}
+
+void CPanel::OpenItem(int index, bool tryInternal, bool tryExternal)
+{
+ CDisableTimerProcessing disableTimerProcessing1(*this);
+ if (!_parentFolders.IsEmpty())
+ {
+ OpenItemInArchive(index, tryInternal, tryExternal, false);
+ return;
+ }
+ UString name = GetItemRelPath(index);
+ if (IsNameVirus(name))
+ {
+ MessageBoxErrorLang(IDS_VIRUS, 0x03020284);
+ return;
+ }
+ UString fullPath = _currentFolderPrefix + name;
+ if (tryInternal)
+ if (!tryExternal || !DoItemAlwaysStart(name))
+ {
+ HRESULT res = OpenItemAsArchive(index);
+ if (res == S_OK || res == E_ABORT)
+ return;
+ if (res != S_FALSE)
+ {
+ MessageBoxError(res);
+ return;
+ }
+ }
+ if (tryExternal)
+ {
+ // SetCurrentDirectory opens HANDLE to folder!!!
+ // NDirectory::MySetCurrentDirectory(_currentFolderPrefix);
+ HANDLE hProcess = StartApplication(fullPath, (HWND)*this);
+ if (hProcess != 0)
+ ::CloseHandle(hProcess);
+ }
+}
+
+class CThreadCopyFrom: public CProgressThreadVirt
+{
+ HRESULT ProcessVirt();
+public:
+ UString PathPrefix;
+ UString Name;
+
+ CMyComPtr<IFolderOperations> FolderOperations;
+ CMyComPtr<IProgress> UpdateCallback;
+ CUpdateCallback100Imp *UpdateCallbackSpec;
+};
+
+HRESULT CThreadCopyFrom::ProcessVirt()
+{
+ UStringVector fileNames;
+ CRecordVector<const wchar_t *> fileNamePointers;
+ fileNames.Add(Name);
+ fileNamePointers.Add(fileNames[0]);
+ return FolderOperations->CopyFrom(PathPrefix, &fileNamePointers.Front(), fileNamePointers.Size(), UpdateCallback);
+};
+
+HRESULT CPanel::OnOpenItemChanged(const UString &folderPath, const UString &itemName,
+ bool usePassword, const UString &password)
+{
+ CMyComPtr<IFolderOperations> folderOperations;
+ if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
+ {
+ MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
+ return E_FAIL;
+ }
+
+ CThreadCopyFrom t;
+ t.UpdateCallbackSpec = new CUpdateCallback100Imp;
+ t.UpdateCallback = t.UpdateCallbackSpec;
+ t.UpdateCallbackSpec->ProgressDialog = &t.ProgressDialog;
+ t.Name = itemName;
+ t.PathPrefix = folderPath;
+ NName::NormalizeDirPathPrefix(t.PathPrefix);
+ t.FolderOperations = folderOperations;
+ t.UpdateCallbackSpec->Init(usePassword, password);
+ RINOK(t.Create(itemName, (HWND)*this));
+ return t.Result;
+}
+
+LRESULT CPanel::OnOpenItemChanged(LPARAM lParam)
+{
+ CTmpProcessInfo &tmpProcessInfo = *(CTmpProcessInfo *)lParam;
+ // LoadCurrentPath()
+ if (tmpProcessInfo.FullPathFolderPrefix != _currentFolderPrefix)
+ return 0;
+
+ CSelectedState state;
+ SaveSelectedState(state);
+
+ HRESULT result = OnOpenItemChanged(tmpProcessInfo.FolderPath, tmpProcessInfo.ItemName,
+ tmpProcessInfo.UsePassword, tmpProcessInfo.Password);
+ if (result != S_OK)
+ return 0;
+ RefreshListCtrl(state);
+ return 1;
+}
+
+/*
+class CTmpProcessInfoList
+{
+public:
+ CObjectVector<CTmpProcessInfo> _items;
+} g_TmpProcessInfoList;
+*/
+
+class CExitEventLauncher
+{
+public:
+ NWindows::NSynchronization::CManualResetEvent _exitEvent;
+ CExitEventLauncher()
+ {
+ if (_exitEvent.Create(false) != S_OK)
+ throw 9387173;
+ };
+ ~CExitEventLauncher() { _exitEvent.Set(); }
+} g_ExitEventLauncher;
+
+#ifdef _WIN32
+static THREAD_FUNC_DECL MyThreadFunction(void *param)
+{
+ CMyAutoPtr<CTmpProcessInfo> tmpProcessInfoPtr((CTmpProcessInfo *)param);
+ CTmpProcessInfo *tmpProcessInfo = tmpProcessInfoPtr.get();
+
+ HANDLE hProcess = tmpProcessInfo->ProcessHandle;
+ HANDLE events[2] = { g_ExitEventLauncher._exitEvent, hProcess};
+ DWORD waitResult = ::WaitForMultipleObjects(2, events, FALSE, INFINITE);
+ ::CloseHandle(hProcess);
+ if (waitResult == WAIT_OBJECT_0 + 0)
+ return 0;
+ if (waitResult != WAIT_OBJECT_0 + 1)
+ return 1;
+ Sleep(200);
+ NFind::CFileInfoW newFileInfo;
+ if (NFind::FindFile(tmpProcessInfo->FilePath, newFileInfo))
+ {
+ if (newFileInfo.Size != tmpProcessInfo->FileInfo.Size ||
+ CompareFileTime(&newFileInfo.MTime, &tmpProcessInfo->FileInfo.MTime) != 0)
+ {
+ UString message = MyFormatNew(IDS_WANT_UPDATE_MODIFIED_FILE,
+ 0x03020280, tmpProcessInfo->ItemName);
+ if (::MessageBoxW(g_HWND, message, L"7-Zip", MB_OKCANCEL | MB_ICONQUESTION) == IDOK)
+ {
+ if (SendMessage(tmpProcessInfo->Window, kOpenItemChanged, 0, (LONG_PTR)tmpProcessInfo) != 1)
+ {
+ ::MessageBoxW(g_HWND, MyFormatNew(IDS_CANNOT_UPDATE_FILE,
+ 0x03020281, tmpProcessInfo->FilePath), L"7-Zip", MB_OK | MB_ICONSTOP);
+ return 0;
+ }
+ }
+ }
+ }
+ tmpProcessInfo->DeleteDirAndFile();
+ return 0;
+}
+#endif
+
+void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bool editMode)
+{
+ const UString name = GetItemName(index);
+ if (IsNameVirus(name))
+ {
+ MessageBoxErrorLang(IDS_VIRUS, 0x03020284);
+ return;
+ }
+
+ CMyComPtr<IFolderOperations> folderOperations;
+ if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
+ {
+ MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
+ return;
+ }
+
+#ifdef _WIN32
+ NFile::NDirectory::CTempDirectoryW tempDirectory;
+ tempDirectory.Create(kTempDirPrefix);
+ UString tempDir = tempDirectory.GetPath();
+ UString tempDirNorm = tempDir;
+ NFile::NName::NormalizeDirPathPrefix(tempDirNorm);
+
+ CRecordVector<UInt32> indices;
+ indices.Add(index);
+
+ UStringVector messages;
+
+ bool usePassword = false;
+ UString password;
+ if (_parentFolders.Size() > 0)
+ {
+ const CFolderLink &fl = _parentFolders.Back();
+ usePassword = fl.UsePassword;
+ password = fl.Password;
+ }
+
+ HRESULT result = CopyTo(indices, tempDirNorm, false, true, &messages, usePassword, password);
+
+ if (_parentFolders.Size() > 0)
+ {
+ CFolderLink &fl = _parentFolders.Back();
+ fl.UsePassword = usePassword;
+ fl.Password = password;
+ }
+
+ if (!messages.IsEmpty())
+ return;
+ if (result != S_OK)
+ {
+ if (result != E_ABORT)
+ MessageBoxError(result);
+ return;
+ }
+
+ UString tempFilePath = tempDirNorm + name;
+
+ CMyAutoPtr<CTmpProcessInfo> tmpProcessInfoPtr(new CTmpProcessInfo());
+ CTmpProcessInfo *tmpProcessInfo = tmpProcessInfoPtr.get();
+ tmpProcessInfo->FolderPath = tempDir;
+ tmpProcessInfo->FilePath = tempFilePath;
+ tmpProcessInfo->UsePassword = usePassword;
+ tmpProcessInfo->Password = password;
+
+ if (!NFind::FindFile(tempFilePath, tmpProcessInfo->FileInfo))
+ return;
+
+ if (tryInternal)
+ {
+ if (!tryExternal || !DoItemAlwaysStart(name))
+ {
+ bool encrypted;
+ if (OpenItemAsArchive(name, tempDir, tempFilePath,
+ _currentFolderPrefix + name, encrypted) == S_OK)
+ {
+ RefreshListCtrl();
+ return;
+ }
+ }
+ }
+
+ CTmpProcessInfoRelease tmpProcessInfoRelease(*tmpProcessInfo);
+
+ if (!tryExternal)
+ return;
+
+ HANDLE hProcess;
+ if (editMode)
+ hProcess = StartEditApplication(tempFilePath, (HWND)*this);
+ else
+ hProcess = StartApplication(tempFilePath, (HWND)*this);
+
+ if (hProcess == 0)
+ return;
+
+ tmpProcessInfo->Window = (HWND)(*this);
+ tmpProcessInfo->FullPathFolderPrefix = _currentFolderPrefix;
+ tmpProcessInfo->ItemName = name;
+ tmpProcessInfo->ProcessHandle = hProcess;
+
+ NWindows::CThread thread;
+ if (thread.Create(MyThreadFunction, tmpProcessInfo) != S_OK)
+ throw 271824;
+ tempDirectory.DisableDeleting();
+ tmpProcessInfoPtr.release();
+ tmpProcessInfoRelease._needDelete = false;
+#else
+ printf(" CPanel::OpenItemInArchive : FIXME\n");
+#endif
+}
+
+/*
+static const UINT64 kTimeLimit = UINT64(10000000) * 3600 * 24;
+
+static bool CheckDeleteItem(UINT64 currentFileTime, UINT64 folderFileTime)
+{
+ return (currentFileTime - folderFileTime > kTimeLimit &&
+ folderFileTime - currentFileTime > kTimeLimit);
+}
+
+void DeleteOldTempFiles()
+{
+ UString tempPath;
+ if(!NFile::NDirectory::MyGetTempPath(tempPath))
+ throw 1;
+
+ UINT64 currentFileTime;
+ NTime::GetCurUtcFileTime(currentFileTime);
+ UString searchWildCard = tempPath + kTempDirPrefix + L"*.tmp";
+ searchWildCard += WCHAR(NName::kAnyStringWildcard);
+ NFind::CEnumeratorW enumerator(searchWildCard);
+ NFind::CFileInfoW fileInfo;
+ while(enumerator.Next(fileInfo))
+ {
+ if (!fileInfo.IsDir())
+ continue;
+ const UINT64 &cTime = *(const UINT64 *)(&fileInfo.CTime);
+ if(CheckDeleteItem(cTime, currentFileTime))
+ RemoveDirectoryWithSubItems(tempPath + fileInfo.Name);
+ }
+}
+*/
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelItems.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelItems.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelItems.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelItems.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,832 @@
+// PanelItems.cpp
+
+#include "StdAfx.h"
+
+#include "../../../../C/Sort.h"
+
+#include "Common/StringConvert.h"
+
+#include "Windows/PropVariant.h"
+#include "Windows/PropVariantConversions.h"
+#include "Windows/Menu.h"
+
+#include "../../PropID.h"
+
+#include "resource.h"
+
+#include "LangUtils.h"
+#include "Panel.h"
+#include "PropertyName.h"
+#include "RootFolder.h"
+
+using namespace NWindows;
+
+static int GetColumnAlign(PROPID propID, VARTYPE varType)
+{
+ switch(propID)
+ {
+ case kpidCTime:
+ case kpidATime:
+ case kpidMTime:
+ return LVCFMT_LEFT;
+ }
+ switch(varType)
+ {
+ case VT_UI1:
+ case VT_I2:
+ case VT_UI2:
+ case VT_I4:
+ case VT_INT:
+ case VT_UI4:
+ case VT_UINT:
+ case VT_I8:
+ case VT_UI8:
+ case VT_BOOL:
+ return LVCFMT_RIGHT;
+
+ case VT_EMPTY:
+ case VT_I1:
+ case VT_FILETIME:
+ case VT_BSTR:
+ return LVCFMT_LEFT;
+
+ default:
+ return LVCFMT_CENTER;
+ }
+}
+
+void CPanel::InitColumns()
+{
+ printf("CPanel::InitColumns\n");
+ if (_needSaveInfo)
+ SaveListViewInfo();
+
+ _listView.DeleteAllItems();
+ _selectedStatusVector.Clear();
+
+ ReadListViewInfo();
+
+
+ PROPID sortID;
+ /*
+ if (_listViewInfo.SortIndex >= 0)
+ sortID = _listViewInfo.Columns[_listViewInfo.SortIndex].PropID;
+ */
+ sortID = _listViewInfo.SortID;
+
+ _ascending = _listViewInfo.Ascending;
+
+ _properties.Clear();
+
+ _needSaveInfo = true;
+
+ UInt32 numProperties;
+ _folder->GetNumberOfProperties(&numProperties);
+ int i;
+ for (i = 0; i < (int)numProperties; i++)
+ {
+ CMyComBSTR name;
+ PROPID propID;
+ VARTYPE varType;
+
+ if (_folder->GetPropertyInfo(i, &name, &propID, &varType) != S_OK)
+ throw 1;
+
+ if (propID == kpidIsDir)
+ continue;
+
+ CItemProperty prop;
+ prop.Type = varType;
+ prop.ID = propID;
+ prop.Name = GetNameOfProperty(propID, name);
+ prop.Order = -1;
+ prop.IsVisible = true;
+ prop.Width = 100;
+
+ _properties.Add(prop);
+ }
+ // InitColumns2(sortID);
+
+ for (;;)
+ if (!_listView.DeleteColumn(0))
+ break;
+
+ int order = 0;
+ for(i = 0; i < _listViewInfo.Columns.Size(); i++)
+ {
+ const CColumnInfo &columnInfo = _listViewInfo.Columns[i];
+ int index = _properties.FindItemWithID(columnInfo.PropID);
+ if (index >= 0)
+ {
+ CItemProperty &item = _properties[index];
+ item.IsVisible = columnInfo.IsVisible;
+ item.Width = columnInfo.Width;
+
+ if (columnInfo.IsVisible)
+ item.Order = order++;
+ continue;
+ }
+ }
+ for(i = 0; i < _properties.Size(); i++)
+ {
+ CItemProperty &item = _properties[i];
+ if (item.Order < 0)
+ item.Order = order++;
+ }
+
+ _visibleProperties.Clear();
+ for (i = 0; i < _properties.Size(); i++)
+ {
+ const CItemProperty &prop = _properties[i];
+ if (prop.IsVisible)
+ _visibleProperties.Add(prop);
+ }
+
+ // _sortIndex = 0;
+ _sortID = kpidName;
+ /*
+ if (_listViewInfo.SortIndex >= 0)
+ {
+ int sortIndex = _properties.FindItemWithID(sortID);
+ if (sortIndex >= 0)
+ _sortIndex = sortIndex;
+ }
+ */
+ _sortID = _listViewInfo.SortID;
+
+ for (i = 0; i < _visibleProperties.Size(); i++)
+ {
+ InsertColumn(i);
+ }
+}
+
+void CPanel::InsertColumn(int index)
+{
+ const CItemProperty &prop = _visibleProperties[index];
+ LV_COLUMNW column;
+ column.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM | LVCF_ORDER;
+ column.cx = prop.Width;
+ column.fmt = GetColumnAlign(prop.ID, prop.Type);
+ column.iOrder = prop.Order;
+ column.iSubItem = index;
+ column.pszText = (wchar_t *)(const wchar_t *)prop.Name;
+
+ _listView.InsertColumn(index, &column);
+}
+
+void CPanel::RefreshListCtrl()
+{
+ RefreshListCtrl(UString(), -1, true, UStringVector());
+}
+
+// int CALLBACK CompareItems(LPARAM lParam1, LPARAM lParam2, LPARAM lpData);
+int
+#if defined(__WIN32__) && !defined(__WXMICROWIN__) // FIXME
+ wxCALLBACK
+#endif
+ CompareItems_WX(long item1, long item2, long sortData);
+
+
+void CPanel::GetSelectedNames(UStringVector &selectedNames)
+{
+ selectedNames.Clear();
+
+ CRecordVector<UInt32> indices;
+ GetSelectedItemsIndices(indices);
+ selectedNames.Reserve(indices.Size());
+ for (int i = 0; i < indices.Size(); i++)
+ selectedNames.Add(GetItemRelPath(indices[i]));
+
+ /*
+ for (int i = 0; i < _listView.GetItemCount(); i++)
+ {
+ const int kSize = 1024;
+ WCHAR name[kSize + 1];
+ LVITEMW item;
+ item.iItem = i;
+ item.pszText = name;
+ item.cchTextMax = kSize;
+ item.iSubItem = 0;
+ item.mask = LVIF_TEXT | LVIF_PARAM;
+ if (!_listView.GetItem(&item))
+ continue;
+ int realIndex = GetRealIndex(item);
+ if (realIndex == kParentIndex)
+ continue;
+ if (_selectedStatusVector[realIndex])
+ selectedNames.Add(item.pszText);
+ }
+ */
+ selectedNames.Sort();
+}
+
+void CPanel::SaveSelectedState(CSelectedState &s)
+{
+ s.FocusedName.Empty();
+ s.SelectedNames.Clear();
+ s.FocusedItem = _listView.GetFocusedItem();
+ {
+ if (s.FocusedItem >= 0)
+ {
+ int realIndex = GetRealItemIndex(s.FocusedItem);
+ if (realIndex != kParentIndex)
+ s.FocusedName = GetItemRelPath(realIndex);
+ /*
+ const int kSize = 1024;
+ WCHAR name[kSize + 1];
+ LVITEMW item;
+ item.iItem = focusedItem;
+ item.pszText = name;
+ item.cchTextMax = kSize;
+ item.iSubItem = 0;
+ item.mask = LVIF_TEXT;
+ if (_listView.GetItem(&item))
+ focusedName = item.pszText;
+ */
+ }
+ }
+ GetSelectedNames(s.SelectedNames);
+}
+
+void CPanel::RefreshListCtrl(const CSelectedState &s)
+{
+ bool selectFocused = s.SelectFocused;
+ if (_mySelectMode)
+ selectFocused = true;
+ RefreshListCtrl(s.FocusedName, s.FocusedItem, selectFocused, s.SelectedNames);
+}
+
+void CPanel::RefreshListCtrlSaveFocused()
+{
+ CSelectedState state;
+ SaveSelectedState(state);
+ RefreshListCtrl(state);
+}
+
+void CPanel::SetFocusedSelectedItem(int index, bool select)
+{
+ UINT state = LVIS_FOCUSED;
+ if (select)
+ state |= LVIS_SELECTED;
+ _listView.SetItemState(index, state, state);
+ if (!_mySelectMode && select)
+ {
+ int realIndex = GetRealItemIndex(index);
+ if (realIndex != kParentIndex)
+ _selectedStatusVector[realIndex] = true;
+ }
+}
+
+void CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool selectFocused,
+ const UStringVector &selectedNames)
+{
+printf("CPanel::RefreshListCtrl\n");
+ _dontShowMode = false;
+ LoadFullPathAndShow();
+ // OutputDebugStringA("=======\n");
+ // OutputDebugStringA("s1 \n");
+ CDisableTimerProcessing timerProcessing(*this);
+
+ if (focusedPos < 0)
+ focusedPos = 0;
+
+ _listView.SetRedraw(false);
+ // m_RedrawEnabled = false;
+
+#ifdef _WIN32
+ LVITEMW item;
+ ZeroMemory(&item, sizeof(item));
+#else
+ LVITEMW item = { 0 };
+#endif
+
+ _listView.DeleteAllItems();
+ _selectedStatusVector.Clear();
+ // _realIndices.Clear();
+ _startGroupSelect = 0;
+
+ _selectionIsDefined = false;
+
+ // m_Files.Clear();
+ // _folder.Release();
+
+ if (!_folder)
+ {
+ // throw 1;
+ SetToRootFolder();
+ }
+
+ // FIXME _headerToolBar.EnableButton(kParentFolderID, !IsRootFolder());
+
+ CMyComPtr<IFolderSetFlatMode> folderSetFlatMode;
+ _folder.QueryInterface(IID_IFolderSetFlatMode, &folderSetFlatMode);
+ if (folderSetFlatMode)
+ folderSetFlatMode->SetFlatMode(BoolToInt(_flatMode));
+
+ if (_folder->LoadItems() != S_OK)
+ return;
+
+ InitColumns();
+
+
+ // OutputDebugString(TEXT("Start Dir\n"));
+ UInt32 numItems;
+ _folder->GetNumberOfItems(&numItems);
+
+ bool showDots = _showDots && !IsRootFolder();
+
+ _listView.SetItemCount(numItems + (showDots ? 1 : 0));
+
+ _selectedStatusVector.Reserve(numItems);
+ int cursorIndex = -1;
+
+ CMyComPtr<IFolderGetSystemIconIndex> folderGetSystemIconIndex;
+ if (!IsFSFolder() || _showRealFileIcons)
+ _folder.QueryInterface(IID_IFolderGetSystemIconIndex, &folderGetSystemIconIndex);
+
+ if (showDots)
+ {
+ UString itemName = L"..";
+ item.iItem = _listView.GetItemCount();
+ if (itemName.CompareNoCase(focusedName) == 0)
+ cursorIndex = item.iItem;
+ item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
+ int subItem = 0;
+ item.iSubItem = subItem++;
+ item.lParam = kParentIndex;
+ item.pszText = (wchar_t *)(const wchar_t *)itemName;
+ UInt32 attrib = FILE_ATTRIBUTE_DIRECTORY;
+ item.iImage = _extToIconMap.GetIconIndex(attrib, itemName);
+ if (item.iImage < 0)
+ item.iImage = 0;
+ if(_listView.InsertItem(&item) == -1)
+ return;
+ }
+
+ // OutputDebugStringA("S1\n");
+
+ for(UInt32 i = 0; i < numItems; i++)
+ {
+ UString itemName = GetItemName(i);
+ const UString relPath = GetItemRelPath(i);
+ if (relPath.CompareNoCase(focusedName) == 0)
+ cursorIndex = _listView.GetItemCount();
+ bool selected = false;
+ if (selectedNames.FindInSorted(relPath) >= 0)
+ selected = true;
+ _selectedStatusVector.Add(selected);
+
+ item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
+
+ if (!_mySelectMode)
+ if (selected)
+ {
+ item.mask |= LVIF_STATE;
+ item.state = LVIS_SELECTED;
+ }
+
+ int subItem = 0;
+ item.iItem = _listView.GetItemCount();
+
+ item.iSubItem = subItem++;
+ item.lParam = i;
+
+ UString correctedName;
+ if (itemName.Find(L" ") >= 0)
+ {
+ int pos = 0;
+ for (;;)
+ {
+ int posNew = itemName.Find(L" ", pos);
+ if (posNew < 0)
+ {
+ correctedName += itemName.Mid(pos);
+ break;
+ }
+ correctedName += itemName.Mid(pos, posNew - pos);
+ correctedName += L" ... ";
+ pos = posNew;
+ while (itemName[++pos] == ' ');
+ }
+ item.pszText = (wchar_t *)(const wchar_t *)correctedName;
+ }
+ else
+ item.pszText = (wchar_t *)(const wchar_t *)itemName;
+
+ NCOM::CPropVariant prop;
+ _folder->GetProperty(i, kpidAttrib, &prop);
+ UInt32 attrib = 0;
+ if (prop.vt == VT_UI4)
+ attrib = prop.ulVal;
+ else if (IsItemFolder(i))
+ attrib |= FILE_ATTRIBUTE_DIRECTORY;
+
+ bool defined = false;
+
+ if (folderGetSystemIconIndex)
+ {
+ folderGetSystemIconIndex->GetSystemIconIndex(i, &item.iImage);
+ defined = (item.iImage > 0);
+ }
+ if (!defined)
+ {
+ if (_currentFolderPrefix.IsEmpty())
+ {
+ int iconIndexTemp;
+ GetRealIconIndex(itemName + WCHAR_PATH_SEPARATOR, attrib, iconIndexTemp);
+ item.iImage = iconIndexTemp;
+ }
+ else
+ {
+ item.iImage = _extToIconMap.GetIconIndex(attrib, itemName);
+ }
+ }
+ if (item.iImage < 0)
+ item.iImage = 0;
+
+ if(_listView.InsertItem(&item) == -1)
+ return; // error
+
+ // FIXME Added
+ item.pszText = (LPWSTR)malloc(4096); // FIXME
+ for(int col=1;col < _listView.GetColumnCount(); col++)
+ {
+ item.iSubItem = col;
+ item.cchTextMax = 4096 / sizeof(item.pszText[0]);
+ this->SetItemText(item);
+ _listView.SetItem(&item);
+ }
+ free(item.pszText); item.pszText = 0;
+
+ }
+ // OutputDebugStringA("End2\n");
+
+ if(_listView.GetItemCount() > 0 && cursorIndex >= 0)
+ SetFocusedSelectedItem(cursorIndex, selectFocused);
+ _listView.SortItems(CompareItems_WX, (LPARAM)this);
+ if (cursorIndex < 0 && _listView.GetItemCount() > 0)
+ {
+ if (focusedPos >= _listView.GetItemCount())
+ focusedPos = _listView.GetItemCount() - 1;
+ SetFocusedSelectedItem(focusedPos, showDots);
+ }
+ // m_RedrawEnabled = true;
+ _listView.EnsureVisible(_listView.GetFocusedItem(), false);
+ _listView.SetRedraw(true);
+ _listView.InvalidateRect(NULL, true);
+ // OutputDebugStringA("End1\n");
+ /*
+ _listView.UpdateWindow();
+ */
+}
+
+void CPanel::GetSelectedItemsIndices(CRecordVector<UInt32> &indices) const
+{
+ indices.Clear();
+ /*
+ int itemIndex = -1;
+ while ((itemIndex = _listView.GetNextItem(itemIndex, LVNI_SELECTED)) != -1)
+ {
+ LPARAM param;
+ if (_listView.GetItemParam(itemIndex, param))
+ indices.Add(param);
+ }
+ */
+ for (int i = 0; i < _selectedStatusVector.Size(); i++)
+ if (_selectedStatusVector[i])
+ indices.Add(i);
+ HeapSort(&indices.Front(), indices.Size());
+}
+
+void CPanel::GetOperatedItemIndices(CRecordVector<UInt32> &indices) const
+{
+ GetSelectedItemsIndices(indices);
+ if (!indices.IsEmpty())
+ return;
+ if (_listView.GetSelectedCount() == 0)
+ return;
+ int focusedItem = _listView.GetFocusedItem();
+ if (focusedItem >= 0)
+ {
+ if(_listView.GetItemState(focusedItem, LVIS_SELECTED) == LVIS_SELECTED)
+ {
+ int realIndex = GetRealItemIndex(focusedItem);
+ if (realIndex != kParentIndex)
+ indices.Add(realIndex);
+ }
+ }
+}
+
+void CPanel::GetAllItemIndices(CRecordVector<UInt32> &indices) const
+{
+ indices.Clear();
+ UInt32 numItems;
+ if (_folder->GetNumberOfItems(&numItems) == S_OK)
+ for (UInt32 i = 0; i < numItems; i++)
+ indices.Add(i);
+}
+
+void CPanel::GetOperatedIndicesSmart(CRecordVector<UInt32> &indices) const
+{
+ GetOperatedItemIndices(indices);
+ if (indices.IsEmpty() || (indices.Size() == 1 && indices[0] == (UInt32)(Int32)-1))
+ GetAllItemIndices(indices);
+}
+
+/*
+void CPanel::GetOperatedListViewIndices(CRecordVector<UInt32> &indices) const
+{
+ indices.Clear();
+ int numItems = _listView.GetItemCount();
+ for (int i = 0; i < numItems; i++)
+ {
+ int realIndex = GetRealItemIndex(i);
+ if (realIndex >= 0)
+ if (_selectedStatusVector[realIndex])
+ indices.Add(i);
+ }
+ if (indices.IsEmpty())
+ {
+ int focusedItem = _listView.GetFocusedItem();
+ if (focusedItem >= 0)
+ indices.Add(focusedItem);
+ }
+}
+*/
+
+void CPanel::EditItem()
+{
+ int focusedItem = _listView.GetFocusedItem();
+ if (focusedItem < 0)
+ return;
+ int realIndex = GetRealItemIndex(focusedItem);
+ if (realIndex == kParentIndex)
+ return;
+ if (!IsItemFolder(realIndex))
+ EditItem(realIndex);
+}
+
+void CPanel::OpenFocusedItemAsInternal()
+{
+ int focusedItem = _listView.GetFocusedItem();
+ if (focusedItem < 0)
+ return;
+ int realIndex = GetRealItemIndex(focusedItem);
+ if (IsItemFolder(realIndex))
+ OpenFolder(realIndex);
+ else
+ OpenItem(realIndex, true, false);
+}
+
+void CPanel::OpenSelectedItems(bool tryInternal)
+{
+ CRecordVector<UInt32> indices;
+ GetOperatedItemIndices(indices);
+ if (indices.Size() > 20)
+ {
+ MessageBoxErrorLang(IDS_TOO_MANY_ITEMS, 0x02000606);
+ return;
+ }
+
+ int focusedItem = _listView.GetFocusedItem();
+ if (focusedItem >= 0)
+ {
+ int realIndex = GetRealItemIndex(focusedItem);
+ if (realIndex == kParentIndex && (tryInternal || indices.Size() == 0) &&
+ _listView.GetItemState(focusedItem, LVIS_SELECTED) == LVIS_SELECTED)
+ indices.Insert(0, realIndex);
+ }
+
+ bool dirIsStarted = false;
+ for(int i = 0; i < indices.Size(); i++)
+ {
+ UInt32 index = indices[i];
+ // CFileInfo &aFile = m_Files[index];
+ if (IsItemFolder(index))
+ {
+ if (!dirIsStarted)
+ {
+ if (tryInternal)
+ {
+ OpenFolder(index);
+ dirIsStarted = true;
+ break;
+ }
+ else
+ OpenFolderExternal(index);
+ }
+ }
+ else
+ OpenItem(index, (tryInternal && indices.Size() == 1), true);
+ }
+}
+
+UString CPanel::GetItemName(int itemIndex) const
+{
+ if (itemIndex == kParentIndex)
+ return L"..";
+ NCOM::CPropVariant prop;
+ if (_folder->GetProperty(itemIndex, kpidName, &prop) != S_OK)
+ throw 2723400;
+ if (prop.vt != VT_BSTR)
+ throw 2723401;
+ return prop.bstrVal;
+}
+
+UString CPanel::GetItemPrefix(int itemIndex) const
+{
+ if (itemIndex == kParentIndex)
+ return UString();
+ NCOM::CPropVariant prop;
+ if (_folder->GetProperty(itemIndex, kpidPrefix, &prop) != S_OK)
+ throw 2723400;
+ UString prefix;
+ if (prop.vt == VT_BSTR)
+ prefix = prop.bstrVal;
+ return prefix;
+}
+
+UString CPanel::GetItemRelPath(int itemIndex) const
+{
+ return GetItemPrefix(itemIndex) + GetItemName(itemIndex);
+}
+
+UString CPanel::GetItemFullPath(int itemIndex) const
+{
+ return _currentFolderPrefix + GetItemRelPath(itemIndex);
+}
+
+bool CPanel::IsItemFolder(int itemIndex) const
+{
+ if (itemIndex == kParentIndex)
+ return true;
+ NCOM::CPropVariant prop;
+ if (_folder->GetProperty(itemIndex, kpidIsDir, &prop) != S_OK)
+ throw 2723400;
+ if (prop.vt == VT_BOOL)
+ return VARIANT_BOOLToBool(prop.boolVal);
+ if (prop.vt == VT_EMPTY)
+ return false;
+ return false;
+}
+
+UINT64 CPanel::GetItemSize(int itemIndex) const
+{
+ if (itemIndex == kParentIndex)
+ return 0;
+ NCOM::CPropVariant prop;
+ if (_folder->GetProperty(itemIndex, kpidSize, &prop) != S_OK)
+ throw 2723400;
+ if (prop.vt == VT_EMPTY)
+ return 0;
+ return ConvertPropVariantToUInt64(prop);
+}
+
+void CPanel::ReadListViewInfo()
+{
+ _typeIDString = GetFolderTypeID();
+ if (!_typeIDString.IsEmpty())
+ ::ReadListViewInfo(_typeIDString, _listViewInfo);
+}
+
+void CPanel::SaveListViewInfo()
+{
+ int i;
+ for(i = 0; i < _visibleProperties.Size(); i++)
+ {
+ CItemProperty &prop = _visibleProperties[i];
+ LVCOLUMN winColumnInfo;
+ winColumnInfo.mask = LVCF_ORDER | LVCF_WIDTH;
+ if (!_listView.GetColumn(i, &winColumnInfo))
+ throw 1;
+ prop.Order = winColumnInfo.iOrder;
+ prop.Width = winColumnInfo.cx;
+ }
+
+ CListViewInfo viewInfo;
+
+ // PROPID sortPropID = _properties[_sortIndex].ID;
+ PROPID sortPropID = _sortID;
+
+ _visibleProperties.Sort();
+ for(i = 0; i < _visibleProperties.Size(); i++)
+ {
+ const CItemProperty &prop = _visibleProperties[i];
+ CColumnInfo columnInfo;
+ columnInfo.IsVisible = prop.IsVisible;
+ columnInfo.PropID = prop.ID;
+ columnInfo.Width = prop.Width;
+ viewInfo.Columns.Add(columnInfo);
+ }
+ for(i = 0; i < _properties.Size(); i++)
+ {
+ const CItemProperty &prop = _properties[i];
+ if (!prop.IsVisible)
+ {
+ CColumnInfo columnInfo;
+ columnInfo.IsVisible = prop.IsVisible;
+ columnInfo.PropID = prop.ID;
+ columnInfo.Width = prop.Width;
+ viewInfo.Columns.Add(columnInfo);
+ }
+ }
+
+ // viewInfo.SortIndex = viewInfo.FindColumnWithID(sortPropID);
+ viewInfo.SortID = sortPropID;
+
+ viewInfo.Ascending = _ascending;
+ if (!_listViewInfo.IsEqual(viewInfo))
+ {
+ ::SaveListViewInfo(_typeIDString, viewInfo);
+ _listViewInfo = viewInfo;
+ }
+}
+
+#ifdef _WIN32
+bool CPanel::OnRightClick(LPNMITEMACTIVATE itemActiveate, LRESULT &result)
+{
+ if(itemActiveate->hdr.hwndFrom == HWND(_listView))
+ return false;
+ POINT point;
+ ::GetCursorPos(&point);
+ ShowColumnsContextMenu(point.x, point.y);
+ result = TRUE;
+ return true;
+}
+
+void CPanel::ShowColumnsContextMenu(int x, int y)
+{
+
+ CMenu menu;
+ CMenuDestroyer menuDestroyer(menu);
+
+ menu.CreatePopup();
+
+ const int kCommandStart = 100;
+ for(int i = 0; i < _properties.Size(); i++)
+ {
+ const CItemProperty &prop = _properties[i];
+ UINT flags = MF_STRING;
+ if (prop.IsVisible)
+ flags |= MF_CHECKED;
+ if (i == 0)
+ flags |= MF_GRAYED;
+ menu.AppendItem(flags, kCommandStart + i, prop.Name);
+ }
+ int menuResult = menu.Track(TPM_LEFTALIGN | TPM_RETURNCMD | TPM_NONOTIFY, x, y, _listView);
+ if (menuResult >= kCommandStart && menuResult <= kCommandStart + _properties.Size())
+ {
+ int index = menuResult - kCommandStart;
+ CItemProperty &prop = _properties[index];
+ prop.IsVisible = !prop.IsVisible;
+
+ if (prop.IsVisible)
+ {
+ int prevVisibleSize = _visibleProperties.Size();
+ prop.Order = prevVisibleSize;
+ _visibleProperties.Add(prop);
+ InsertColumn(prevVisibleSize);
+ }
+ else
+ {
+ int visibleIndex = _visibleProperties.FindItemWithID(prop.ID);
+ _visibleProperties.Delete(visibleIndex);
+ /*
+ if (_sortIndex == index)
+ {
+ _sortIndex = 0;
+ _ascending = true;
+ }
+ */
+ if (_sortID == prop.ID)
+ {
+ _sortID = kpidName;
+ _ascending = true;
+ }
+
+ _listView.DeleteColumn(visibleIndex);
+ }
+ }
+}
+#endif // _WIN32
+
+void CPanel::OnReload()
+{
+ RefreshListCtrlSaveFocused();
+ OnRefreshStatusBar();
+}
+
+void CPanel::OnTimer()
+{
+ if (!_processTimer)
+ return;
+ CMyComPtr<IFolderWasChanged> folderWasChanged;
+ if (_folder.QueryInterface(IID_IFolderWasChanged, &folderWasChanged) != S_OK)
+ return;
+ Int32 wasChanged;
+ if (folderWasChanged->WasChanged(&wasChanged) != S_OK)
+ return;
+ if (wasChanged == 0)
+ return;
+ OnReload();
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelListNotify.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelListNotify.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelListNotify.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelListNotify.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,429 @@
+// PanelListNotify.cpp
+
+#include "StdAfx.h"
+
+#include "resource.h"
+
+#include "Common/IntToString.h"
+#include "Common/StringConvert.h"
+
+#include "Windows/PropVariant.h"
+#include "Windows/PropVariantConversions.h"
+
+#include "../Common/PropIDUtils.h"
+#include "../../PropID.h"
+
+#include "Panel.h"
+#include "FormatUtils.h"
+
+using namespace NWindows;
+
+static UString ConvertSizeToStringShort(UInt64 value)
+{
+ wchar_t s[32];
+ wchar_t c, c2 = L'B';
+ if (value < (UInt64)10000)
+ {
+ c = L'B';
+ c2 = L'\0';
+ }
+ else if (value < ((UInt64)10000 << 10))
+ {
+ value >>= 10;
+ c = L'K';
+ }
+ else if (value < ((UInt64)10000 << 20))
+ {
+ value >>= 20;
+ c = L'M';
+ }
+ else
+ {
+ value >>= 30;
+ c = L'G';
+ }
+ ConvertUInt64ToString(value, s);
+ int p = MyStringLen(s);
+ s[p++] = L' ';
+ s[p++] = c;
+ s[p++] = c2;
+ s[p++] = L'\0';
+ return s;
+}
+
+UString ConvertSizeToString(UInt64 value)
+{
+ wchar_t s[32];
+ ConvertUInt64ToString(value, s);
+ int i = MyStringLen(s);
+ int pos = sizeof(s) / sizeof(s[0]);
+ s[--pos] = L'\0';
+ while (i > 3)
+ {
+ s[--pos] = s[--i];
+ s[--pos] = s[--i];
+ s[--pos] = s[--i];
+ s[--pos] = L' ';
+ }
+ while (i > 0)
+ s[--pos] = s[--i];
+ return s + pos;
+}
+
+LRESULT CPanel::SetItemText(LVITEMW &item)
+{
+ if (_dontShowMode)
+ return 0;
+
+ UINT32 realIndex = GetRealIndex(item);
+ // printf(" CPanel::SetItemText : realIndex=%d\n",realIndex);
+
+ /*
+ if ((item.mask & LVIF_IMAGE) != 0)
+ {
+ bool defined = false;
+ CComPtr<IFolderGetSystemIconIndex> folderGetSystemIconIndex;
+ _folder.QueryInterface(&folderGetSystemIconIndex);
+ if (folderGetSystemIconIndex)
+ {
+ folderGetSystemIconIndex->GetSystemIconIndex(index, &item.iImage);
+ defined = (item.iImage > 0);
+ }
+ if (!defined)
+ {
+ NCOM::CPropVariant prop;
+ _folder->GetProperty(index, kpidAttrib, &prop);
+ UINT32 attrib = 0;
+ if (prop.vt == VT_UI4)
+ attrib = prop.ulVal;
+ else if (IsItemFolder(index))
+ attrib |= FILE_ATTRIBUTE_DIRECTORY;
+ if (_currentFolderPrefix.IsEmpty())
+ throw 1;
+ else
+ item.iImage = _extToIconMap.GetIconIndex(attrib, GetSystemString(GetItemName(index)));
+ }
+ // item.iImage = 1;
+ }
+ */
+
+ if ((item.mask & LVIF_TEXT) == 0)
+ return 0;
+
+ if (realIndex == kParentIndex)
+ return 0;
+ UString s;
+ UINT32 subItemIndex = item.iSubItem;
+ PROPID propID = _visibleProperties[subItemIndex].ID;
+ /*
+ {
+ NCOM::CPropVariant property;
+ if(propID == kpidType)
+ string = GetFileType(index);
+ else
+ {
+ HRESULT result = m_ArchiveFolder->GetProperty(index, propID, &property);
+ if (result != S_OK)
+ {
+ // PrintMessage("GetPropertyValue error");
+ return 0;
+ }
+ string = ConvertPropertyToString(property, propID, false);
+ }
+ }
+ */
+ // const NFind::CFileInfo &aFileInfo = m_Files[index];
+
+ NCOM::CPropVariant prop;
+ /*
+ bool needRead = true;
+ if (propID == kpidSize)
+ {
+ CComPtr<IFolderGetItemFullSize> getItemFullSize;
+ if (_folder.QueryInterface(&getItemFullSize) == S_OK)
+ {
+ if (getItemFullSize->GetItemFullSize(index, &prop) == S_OK)
+ needRead = false;
+ }
+ }
+ if (needRead)
+ */
+
+ if (_folder->GetProperty(realIndex, propID, &prop) != S_OK)
+ throw 2723407;
+
+ if ((propID == kpidSize || propID == kpidPackSize || propID == kpidClusterSize ||
+ propID == kpidNumSubDirs || propID == kpidNumSubFiles) &&
+ (prop.vt == VT_UI8 || prop.vt == VT_UI4))
+ s = ConvertSizeToString(ConvertPropVariantToUInt64(prop));
+ else if ((propID == kpidTotalSize || propID == kpidFreeSpace) &&
+ (prop.vt == VT_UI8 || prop.vt == VT_UI4))
+ s = ConvertSizeToStringShort(ConvertPropVariantToUInt64(prop));
+ else
+ {
+ s = ConvertPropertyToString(prop, propID, false);
+ s.Replace(wchar_t(0xA), L' ');
+ s.Replace(wchar_t(0xD), L' ');
+ }
+ int size = item.cchTextMax;
+ if(size > 0)
+ {
+ if(s.Length() + 1 > size)
+ s = s.Left(size - 1);
+ MyStringCopy(item.pszText, (const wchar_t *)s);
+ }
+ return 0;
+}
+
+#ifdef _WIN32
+extern DWORD g_ComCtl32Version;
+#endif
+
+void CPanel::OnItemChanged(NMLISTVIEW *item)
+{
+ int index = (int)item->lParam;
+ if (index == kParentIndex)
+ return;
+ bool oldSelected = (item->uOldState & LVIS_SELECTED) != 0;
+ bool newSelected = (item->uNewState & LVIS_SELECTED) != 0;
+ // Don't change this code. It works only with such check
+ printf("CPanel::OnItemChanged : index=%d oldSel=%d newSel=%d\n",index,(int)oldSelected,(int)newSelected);
+ if(oldSelected != newSelected) {
+ printf("CPanel::OnItemChanged : _selectedStatusVector[%d] = %d\n",index,(int)newSelected);
+ _selectedStatusVector[index] = newSelected;
+ }
+}
+
+bool CPanel::OnNotifyList(LPNMHDR header, LRESULT &result)
+{
+ printf("CPanel::OnNotifyList : FIXME\n");
+ // bool alt = (::GetKeyState(VK_MENU) & 0x8000) != 0;
+ // bool ctrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0;
+ // bool shift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0;
+ switch(header->code)
+ {
+ case LVN_ITEMCHANGED:
+ {
+ if (_enableItemChangeNotify)
+ {
+ if (!_mySelectMode)
+ OnItemChanged((LPNMLISTVIEW)header);
+ RefreshStatusBar();
+ }
+ return false;
+ }
+ /*
+
+ case LVN_ODSTATECHANGED:
+ {
+ break;
+ }
+ */
+
+#ifdef _WIN32
+ case LVN_GETDISPINFOW:
+ {
+ LV_DISPINFOW *dispInfo = (LV_DISPINFOW *)header;
+
+ //is the sub-item information being requested?
+
+ if((dispInfo->item.mask & LVIF_TEXT) != 0 ||
+ (dispInfo->item.mask & LVIF_IMAGE) != 0)
+ SetItemText(dispInfo->item);
+ return false;
+ }
+ case LVN_KEYDOWN:
+ {
+ bool boolResult = OnKeyDown(LPNMLVKEYDOWN(header), result);
+ RefreshStatusBar();
+ return boolResult;
+ }
+#endif
+
+ case LVN_COLUMNCLICK:
+ OnColumnClick(LPNMLISTVIEW(header));
+ return false;
+ /*
+ case LVN_ITEMACTIVATE:
+ RefreshStatusBar();
+ if (!alt && !ctrl && !shift)
+ OpenSelectedItems(true);
+ return false;
+ */
+
+ case NM_DBLCLK:
+ RefreshStatusBar();
+ OpenSelectedItems(true);
+ return false;
+#ifdef _WIN32
+ case NM_RETURN:
+ {
+ bool alt = (::GetKeyState(VK_MENU) & 0x8000) != 0;
+ bool ctrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0;
+ // bool leftCtrl = (::GetKeyState(VK_LCONTROL) & 0x8000) != 0;
+ // bool RightCtrl = (::GetKeyState(VK_RCONTROL) & 0x8000) != 0;
+ bool shift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0;
+ if (!shift && alt && !ctrl)
+ {
+ Properties();
+ return false;
+ }
+ OpenSelectedItems(true);
+ return false;
+ }
+ case NM_RCLICK:
+ RefreshStatusBar();
+ break;
+
+ /*
+ return OnRightClick((LPNMITEMACTIVATE)header, result);
+ */
+ /*
+ case NM_CLICK:
+ SendRefreshStatusBarMessage();
+ return 0;
+
+ // TODO : Handler default action...
+ return 0;
+ case LVN_ITEMCHANGED:
+ {
+ NMLISTVIEW *pNMLV = (NMLISTVIEW *) lpnmh;
+ SelChange(pNMLV);
+ return TRUE;
+ }
+ case NM_SETFOCUS:
+ return onSetFocus(NULL);
+ case NM_KILLFOCUS:
+ return onKillFocus(NULL);
+ */
+ case NM_CLICK:
+ {
+ // we need SetFocusToList, if we drag-select items from other panel.
+ SetFocusToList();
+ RefreshStatusBar();
+ if(_mySelectMode)
+ if(g_ComCtl32Version >= MAKELONG(71, 4))
+ OnLeftClick((LPNMITEMACTIVATE)header);
+ return false;
+ }
+ case LVN_BEGINLABELEDITW:
+ result = OnBeginLabelEdit((LV_DISPINFOW *)header);
+ return true;
+ case LVN_ENDLABELEDITW:
+ result = OnEndLabelEdit((LV_DISPINFOW *)header);
+ return true;
+
+ case NM_CUSTOMDRAW:
+ {
+ if (_mySelectMode)
+ return OnCustomDraw((LPNMLVCUSTOMDRAW)header, result);
+ break;
+ }
+ case LVN_BEGINDRAG:
+ {
+ OnDrag((LPNMLISTVIEW)header);
+ RefreshStatusBar();
+ break;
+ }
+#endif
+ // case LVN_BEGINRDRAG:
+ }
+ return false;
+}
+
+#ifdef _WIN32
+bool CPanel::OnCustomDraw(LPNMLVCUSTOMDRAW lplvcd, LRESULT &result)
+{
+ switch(lplvcd->nmcd.dwDrawStage)
+ {
+ case CDDS_PREPAINT :
+ result = CDRF_NOTIFYITEMDRAW;
+ return true;
+
+ case CDDS_ITEMPREPAINT:
+ /*
+ SelectObject(lplvcd->nmcd.hdc,
+ GetFontForItem(lplvcd->nmcd.dwItemSpec,
+ lplvcd->nmcd.lItemlParam) );
+ lplvcd->clrText = GetColorForItem(lplvcd->nmcd.dwItemSpec,
+ lplvcd->nmcd.lItemlParam);
+ lplvcd->clrTextBk = GetBkColorForItem(lplvcd->nmcd.dwItemSpec,
+ lplvcd->nmcd.lItemlParam);
+ */
+ int realIndex = (int)lplvcd->nmcd.lItemlParam;
+ bool selected = false;
+ if (realIndex != kParentIndex)
+ selected = _selectedStatusVector[realIndex];
+ if (selected)
+ lplvcd->clrTextBk = RGB(255, 192, 192);
+ // lplvcd->clrText = RGB(255, 0, 128);
+ else
+ lplvcd->clrTextBk = _listView.GetBkColor();
+ // lplvcd->clrText = RGB(0, 0, 0);
+ // result = CDRF_NEWFONT;
+ result = CDRF_NOTIFYITEMDRAW;
+ return true;
+
+ // return false;
+ // return true;
+ /*
+ case CDDS_SUBITEM | CDDS_ITEMPREPAINT:
+ if (lplvcd->iSubItem == 0)
+ {
+ // lplvcd->clrText = RGB(255, 0, 0);
+ lplvcd->clrTextBk = RGB(192, 192, 192);
+ }
+ else
+ {
+ lplvcd->clrText = RGB(0, 0, 0);
+ lplvcd->clrTextBk = RGB(255, 255, 255);
+ }
+ return true;
+ */
+
+ /* At this point, you can change the background colors for the item
+ and any subitems and return CDRF_NEWFONT. If the list-view control
+ is in report mode, you can simply return CDRF_NOTIFYSUBITEMREDRAW
+ to customize the item's subitems individually */
+ }
+ return false;
+}
+#endif //#ifdef _WIN32
+
+void CPanel::OnRefreshStatusBar()
+{
+ CRecordVector<UINT32> indices;
+ GetOperatedItemIndices(indices);
+
+ _statusBar.SetText(0, MyFormatNew(IDS_N_SELECTED_ITEMS, 0x02000301, NumberToString(indices.Size())));
+
+ UString selectSizeString;
+
+ if (indices.Size() > 0)
+ {
+ UInt64 totalSize = 0;
+ for (int i = 0; i < indices.Size(); i++)
+ totalSize += GetItemSize(indices[i]);
+ selectSizeString = ConvertSizeToString(totalSize);
+ }
+ _statusBar.SetText(1, selectSizeString);
+
+ int focusedItem = _listView.GetFocusedItem();
+ UString sizeString;
+ UString dateString;
+ if (focusedItem >= 0 && _listView.GetSelectedCount() > 0)
+ {
+ int realIndex = GetRealItemIndex(focusedItem);
+ if (realIndex != kParentIndex)
+ {
+ sizeString = ConvertSizeToString(GetItemSize(realIndex));
+ NCOM::CPropVariant prop;
+ if (_folder->GetProperty(realIndex, kpidMTime, &prop) == S_OK)
+ dateString = ConvertPropertyToString(prop, kpidMTime, false);
+ }
+ }
+ _statusBar.SetText(2, sizeString);
+ _statusBar.SetText(3, dateString);
+ // _statusBar.SetText(4, nameString);
+ // _statusBar2.SetText(1, MyFormatNew(L"{0} bytes", NumberToStringW(totalSize)));
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelMenu.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelMenu.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelMenu.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelMenu.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,684 @@
+#include "StdAfx.h"
+
+#include "Common/StringConvert.h"
+
+#include "Windows/COM.h"
+#include "Windows/Clipboard.h"
+#include "Windows/Menu.h"
+#include "Windows/PropVariant.h"
+#include "Windows/PropVariantConversions.h"
+
+#include "../../PropID.h"
+#include "../Common/PropIDUtils.h"
+#include "../Explorer/ContextMenu.h"
+
+#include "App.h"
+#include "LangUtils.h"
+#include "MyLoadMenu.h"
+#include "PropertyName.h"
+
+#include "resource.h"
+#include "PropertyNameRes.h"
+
+using namespace NWindows;
+
+LONG g_DllRefCount = 0;
+
+static const UINT kSevenZipStartMenuID = kPluginMenuStartID ;
+static const UINT kSystemStartMenuID = kPluginMenuStartID + 100;
+
+void CPanel::InvokeSystemCommand(const char *command)
+{
+#ifdef _WIN32
+ NCOM::CComInitializer comInitializer;
+ if (!IsFsOrPureDrivesFolder())
+ return;
+ CRecordVector<UInt32> operatedIndices;
+ GetOperatedItemIndices(operatedIndices);
+ if (operatedIndices.IsEmpty())
+ return;
+ CMyComPtr<IContextMenu> contextMenu;
+ if (CreateShellContextMenu(operatedIndices, contextMenu) != S_OK)
+ return;
+
+ CMINVOKECOMMANDINFO ci;
+ ZeroMemory(&ci, sizeof(ci));
+ ci.cbSize = sizeof(CMINVOKECOMMANDINFO);
+ ci.hwnd = GetParent();
+ ci.lpVerb = command;
+ contextMenu->InvokeCommand(&ci);
+#endif
+}
+
+static const wchar_t *kSeparator = L"----------------------------\n";
+static const wchar_t *kSeparatorSmall = L"----\n";
+static const wchar_t *kPropValueSeparator = L": ";
+
+extern UString ConvertSizeToString(UInt64 value);
+
+static void AddPropertyString(PROPID propID, const wchar_t *nameBSTR,
+ const NCOM::CPropVariant &prop, UString &s)
+{
+ if (prop.vt != VT_EMPTY)
+ {
+ UString val;
+
+ if ((prop.vt == VT_UI8 || prop.vt == VT_UI4) && (
+ propID == kpidSize ||
+ propID == kpidPackSize ||
+ propID == kpidNumSubDirs ||
+ propID == kpidNumSubFiles ||
+ propID == kpidNumBlocks ||
+ propID == kpidClusterSize ||
+ propID == kpidTotalSize ||
+ propID == kpidFreeSpace ||
+ propID == kpidPhySize ||
+ propID == kpidHeadersSize ||
+ propID == kpidFreeSpace
+ ))
+ val = ConvertSizeToString(ConvertPropVariantToUInt64(prop));
+ else
+ val = ConvertPropertyToString(prop, propID);
+
+ if (!val.IsEmpty())
+ {
+ s += GetNameOfProperty(propID, nameBSTR);
+ s += kPropValueSeparator;
+ /*
+ if (propID == kpidComment)
+ s += L'\n';
+ */
+ s += val;
+ s += L'\n';
+ }
+ }
+}
+
+void CPanel::Properties()
+{
+ CMyComPtr<IGetFolderArcProps> getFolderArcProps;
+ _folder.QueryInterface(IID_IGetFolderArcProps, &getFolderArcProps);
+ if (!getFolderArcProps)
+ {
+ InvokeSystemCommand("properties");
+ return;
+ }
+
+ {
+ UString message;
+
+ CRecordVector<UInt32> operatedIndices;
+ GetOperatedItemIndices(operatedIndices);
+ if (operatedIndices.Size() == 1)
+ {
+ UInt32 index = operatedIndices[0];
+ // message += L"Item:\n";
+ UInt32 numProps;
+ if (_folder->GetNumberOfProperties(&numProps) == S_OK)
+ {
+ for (UInt32 i = 0; i < numProps; i++)
+ {
+ CMyComBSTR name;
+ PROPID propID;
+ VARTYPE varType;
+
+ if (_folder->GetPropertyInfo(i, &name, &propID, &varType) != S_OK)
+ continue;
+
+ NCOM::CPropVariant prop;
+ if (_folder->GetProperty(index, propID, &prop) != S_OK)
+ continue;
+ AddPropertyString(propID, name, prop, message);
+ }
+ }
+ message += kSeparator;
+ }
+
+ /*
+ message += LangString(IDS_PROP_FILE_TYPE, 0x02000214);
+ message += kPropValueSeparator;
+ message += GetFolderTypeID();
+ message += L"\n";
+ */
+
+ {
+ NCOM::CPropVariant prop;
+ if (_folder->GetFolderProperty(kpidPath, &prop) == S_OK)
+ {
+ AddPropertyString(kpidName, L"Path", prop, message);
+ }
+ }
+
+ CMyComPtr<IFolderProperties> folderProperties;
+ _folder.QueryInterface(IID_IFolderProperties, &folderProperties);
+ if (folderProperties)
+ {
+ UInt32 numProps;
+ if (folderProperties->GetNumberOfFolderProperties(&numProps) == S_OK)
+ {
+ for (UInt32 i = 0; i < numProps; i++)
+ {
+ CMyComBSTR name;
+ PROPID propID;
+ VARTYPE vt;
+ if (folderProperties->GetFolderPropertyInfo(i, &name, &propID, &vt) != S_OK)
+ continue;
+ NCOM::CPropVariant prop;
+ if (_folder->GetFolderProperty(propID, &prop) != S_OK)
+ continue;
+ AddPropertyString(propID, name, prop, message);
+ }
+ }
+ }
+
+ CMyComPtr<IGetFolderArcProps> getFolderArcProps;
+ _folder.QueryInterface(IID_IGetFolderArcProps, &getFolderArcProps);
+ if (getFolderArcProps)
+ {
+ CMyComPtr<IFolderArcProps> getProps;
+ getFolderArcProps->GetFolderArcProps(&getProps);
+ if (getProps)
+ {
+ UInt32 numLevels;
+ if (getProps->GetArcNumLevels(&numLevels) != S_OK)
+ numLevels = 0;
+ for (UInt32 level2 = 0; level2 < numLevels; level2++)
+ {
+ {
+ UInt32 level = numLevels - 1 - level2;
+ UInt32 numProps;
+ if (getProps->GetArcNumProps(level, &numProps) == S_OK)
+ {
+ message += kSeparator;
+ for (Int32 i = -3; i < (Int32)numProps; i++)
+ {
+ CMyComBSTR name;
+ PROPID propID;
+ VARTYPE vt;
+ switch (i)
+ {
+ case -3: propID = kpidPath; break;
+ case -2: propID = kpidType; break;
+ case -1: propID = kpidError; break;
+ default:
+ if (getProps->GetArcPropInfo(level, i, &name, &propID, &vt) != S_OK)
+ continue;
+ }
+ NCOM::CPropVariant prop;
+ if (getProps->GetArcProp(level, propID, &prop) != S_OK)
+ continue;
+ AddPropertyString(propID, name, prop, message);
+ }
+ }
+ }
+ if (level2 != numLevels - 1)
+ {
+ UInt32 level = numLevels - 1 - level2;
+ UInt32 numProps;
+ if (getProps->GetArcNumProps2(level, &numProps) == S_OK)
+ {
+ message += kSeparatorSmall;
+ for (Int32 i = 0; i < (Int32)numProps; i++)
+ {
+ CMyComBSTR name;
+ PROPID propID;
+ VARTYPE vt;
+ if (getProps->GetArcPropInfo2(level, i, &name, &propID, &vt) != S_OK)
+ continue;
+ NCOM::CPropVariant prop;
+ if (getProps->GetArcProp2(level, propID, &prop) != S_OK)
+ continue;
+ AddPropertyString(propID, name, prop, message);
+ }
+ }
+ }
+ }
+ }
+ }
+ ::MessageBoxW(*(this), message, LangString(IDS_PROPERTIES, 0x03020900), MB_OK);
+ }
+}
+
+void CPanel::EditCut()
+{
+ // InvokeSystemCommand("cut");
+}
+
+void CPanel::EditCopy()
+{
+ /*
+ CMyComPtr<IGetFolderArcProps> getFolderArcProps;
+ _folder.QueryInterface(IID_IGetFolderArcProps, &getFolderArcProps);
+ if (!getFolderArcProps)
+ {
+ InvokeSystemCommand("copy");
+ return;
+ }
+ */
+ UString s;
+ CRecordVector<UInt32> indices;
+ GetSelectedItemsIndices(indices);
+ for (int i = 0; i < indices.Size(); i++)
+ {
+ if (i > 0)
+ s += L"\xD\n";
+ s += GetItemName(indices[i]);
+ }
+ ClipboardSetText(_mainWindow, s);
+}
+
+void CPanel::EditPaste()
+{
+ /*
+ UStringVector names;
+ ClipboardGetFileNames(names);
+ CopyFromNoAsk(names);
+ UString s;
+ for (int i = 0; i < names.Size(); i++)
+ {
+ s += L" ";
+ s += names[i];
+ }
+
+ MessageBoxW(0, s, L"", 0);
+ */
+
+ // InvokeSystemCommand("paste");
+}
+
+#ifdef _WIN32
+HRESULT CPanel::CreateShellContextMenu(
+ const CRecordVector<UInt32> &operatedIndices,
+ CMyComPtr<IContextMenu> &systemContextMenu)
+{
+ systemContextMenu.Release();
+ UString folderPath = GetFsPath();
+
+ CMyComPtr<IShellFolder> desktopFolder;
+ RINOK(::SHGetDesktopFolder(&desktopFolder));
+ if (!desktopFolder)
+ {
+ // ShowMessage("Failed to get Desktop folder.");
+ return E_FAIL;
+ }
+
+ // Separate the file from the folder.
+
+
+ // Get a pidl for the folder the file
+ // is located in.
+ LPITEMIDLIST parentPidl;
+ DWORD eaten;
+ RINOK(desktopFolder->ParseDisplayName(
+ GetParent(), 0, (wchar_t *)(const wchar_t *)folderPath,
+ &eaten, &parentPidl, 0));
+
+ // Get an IShellFolder for the folder
+ // the file is located in.
+ CMyComPtr<IShellFolder> parentFolder;
+ RINOK(desktopFolder->BindToObject(parentPidl,
+ 0, IID_IShellFolder, (void**)&parentFolder));
+ if (!parentFolder)
+ {
+ // ShowMessage("Invalid file name.");
+ return E_FAIL;
+ }
+
+ // Get a pidl for the file itself.
+ CRecordVector<LPITEMIDLIST> pidls;
+ pidls.Reserve(operatedIndices.Size());
+ for (int i = 0; i < operatedIndices.Size(); i++)
+ {
+ LPITEMIDLIST pidl;
+ UString fileName = GetItemRelPath(operatedIndices[i]);
+ if (IsFSDrivesFolder())
+ fileName += WCHAR_PATH_SEPARATOR;
+ RINOK(parentFolder->ParseDisplayName(GetParent(), 0,
+ (wchar_t *)(const wchar_t *)fileName, &eaten, &pidl, 0));
+ pidls.Add(pidl);
+ }
+
+ ITEMIDLIST temp;
+ if (pidls.Size() == 0)
+ {
+ temp.mkid.cb = 0;
+ /*
+ LPITEMIDLIST pidl;
+ HRESULT result = parentFolder->ParseDisplayName(GetParent(), 0,
+ L"." WSTRING_PATH_SEPARATOR, &eaten, &pidl, 0);
+ if (result != NOERROR)
+ return;
+ */
+ pidls.Add(&temp);
+ }
+
+ // Get the IContextMenu for the file.
+ CMyComPtr<IContextMenu> cm;
+ RINOK( parentFolder->GetUIObjectOf(GetParent(), pidls.Size(),
+ (LPCITEMIDLIST *)&pidls.Front(), IID_IContextMenu, 0, (void**)&cm));
+ if (!cm)
+ {
+ // ShowMessage("Unable to get context menu interface.");
+ return E_FAIL;
+ }
+ systemContextMenu = cm;
+ return S_OK;
+}
+
+void CPanel::CreateSystemMenu(HMENU menuSpec,
+ const CRecordVector<UInt32> &operatedIndices,
+ CMyComPtr<IContextMenu> &systemContextMenu)
+{
+ systemContextMenu.Release();
+
+ CreateShellContextMenu(operatedIndices, systemContextMenu);
+
+ if (systemContextMenu == 0)
+ return;
+
+ // Set up a CMINVOKECOMMANDINFO structure.
+ CMINVOKECOMMANDINFO ci;
+ ZeroMemory(&ci, sizeof(ci));
+ ci.cbSize = sizeof(CMINVOKECOMMANDINFO);
+ ci.hwnd = GetParent();
+
+ /*
+ if (Sender == GoBtn)
+ {
+ // Verbs that can be used are cut, paste,
+ // properties, delete, and so on.
+ String action;
+ if (CutRb->Checked)
+ action = "cut";
+ else if (CopyRb->Checked)
+ action = "copy";
+ else if (DeleteRb->Checked)
+ action = "delete";
+ else if (PropertiesRb->Checked)
+ action = "properties";
+
+ ci.lpVerb = action.c_str();
+ result = cm->InvokeCommand(&ci);
+ if (result)
+ ShowMessage(
+ "Error copying file to clipboard.");
+
+ }
+ else
+ */
+ {
+ // HMENU hMenu = CreatePopupMenu();
+ CMenu popupMenu;
+ // CMenuDestroyer menuDestroyer(popupMenu);
+ if(!popupMenu.CreatePopup())
+ throw 210503;
+
+ HMENU hMenu = popupMenu;
+
+ DWORD Flags = CMF_EXPLORE;
+ // Optionally the shell will show the extended
+ // context menu on some operating systems when
+ // the shift key is held down at the time the
+ // context menu is invoked. The following is
+ // commented out but you can uncommnent this
+ // line to show the extended context menu.
+ // Flags |= 0x00000080;
+ systemContextMenu->QueryContextMenu(hMenu, 0, kSystemStartMenuID, 0x7FFF, Flags);
+
+
+ {
+ CMenu menu;
+ menu.Attach(menuSpec);
+ CMenuItem menuItem;
+ menuItem.fMask = MIIM_SUBMENU | MIIM_TYPE | MIIM_ID;
+ menuItem.fType = MFT_STRING;
+ menuItem.hSubMenu = popupMenu.Detach();
+ // menuDestroyer.Disable();
+ menuItem.StringValue = LangString(IDS_SYSTEM, 0x030202A0);
+ menu.InsertItem(0, true, menuItem);
+ }
+ /*
+ if (Cmd < 100 && Cmd != 0)
+ {
+ ci.lpVerb = MAKEINTRESOURCE(Cmd - 1);
+ ci.lpParameters = "";
+ ci.lpDirectory = "";
+ ci.nShow = SW_SHOWNORMAL;
+ cm->InvokeCommand(&ci);
+ }
+ // If Cmd is > 100 then it's one of our
+ // inserted menu items.
+ else
+ // Find the menu item.
+ for (int i = 0; i < popupMenu1->Items->Count; i++)
+ {
+ TMenuItem* menu = popupMenu1->Items->Items[i];
+ // Call its OnClick handler.
+ if (menu->Command == Cmd - 100)
+ menu->OnClick(this);
+ }
+ // Release the memory allocated for the menu.
+ DestroyMenu(hMenu);
+ */
+ }
+}
+
+void CPanel::CreateFileMenu(HMENU menuSpec)
+{
+ CreateFileMenu(menuSpec, _sevenZipContextMenu, _systemContextMenu, true);
+}
+
+void CPanel::CreateSevenZipMenu(HMENU menuSpec,
+ const CRecordVector<UInt32> &operatedIndices,
+ CMyComPtr<IContextMenu> &sevenZipContextMenu)
+{
+ sevenZipContextMenu.Release();
+
+ CMenu menu;
+ menu.Attach(menuSpec);
+ // CMenuDestroyer menuDestroyer(menu);
+ // menu.CreatePopup();
+
+ bool sevenZipMenuCreated = false;
+
+ CZipContextMenu *contextMenuSpec = new CZipContextMenu;
+ CMyComPtr<IContextMenu> contextMenu = contextMenuSpec;
+ // if (contextMenu.CoCreateInstance(CLSID_CZipContextMenu, IID_IContextMenu) == S_OK)
+ {
+ /*
+ CMyComPtr<IInitContextMenu> initContextMenu;
+ if (contextMenu.QueryInterface(IID_IInitContextMenu, &initContextMenu) != S_OK)
+ return;
+ */
+ UString currentFolderUnicode = _currentFolderPrefix;
+ UStringVector names;
+ int i;
+ for(i = 0; i < operatedIndices.Size(); i++)
+ names.Add(currentFolderUnicode + GetItemRelPath(operatedIndices[i]));
+ CRecordVector<const wchar_t *> namePointers;
+ for(i = 0; i < operatedIndices.Size(); i++)
+ namePointers.Add(names[i]);
+
+ // NFile::NDirectory::MySetCurrentDirectory(currentFolderUnicode);
+ if (contextMenuSpec->InitContextMenu(currentFolderUnicode, &namePointers.Front(),
+ operatedIndices.Size()) == S_OK)
+ {
+ HRESULT res = contextMenu->QueryContextMenu(menu, 0, kSevenZipStartMenuID,
+ kSystemStartMenuID - 1, 0);
+ sevenZipMenuCreated = (HRESULT_SEVERITY(res) == SEVERITY_SUCCESS);
+ if (sevenZipMenuCreated)
+ sevenZipContextMenu = contextMenu;
+ // int code = HRESULT_CODE(res);
+ // int nextItemID = code;
+ }
+ }
+}
+
+void CPanel::CreateFileMenu(HMENU menuSpec,
+ CMyComPtr<IContextMenu> &sevenZipContextMenu,
+ CMyComPtr<IContextMenu> &systemContextMenu,
+ bool programMenu)
+{
+ sevenZipContextMenu.Release();
+ systemContextMenu.Release();
+
+ CRecordVector<UInt32> operatedIndices;
+ GetOperatedItemIndices(operatedIndices);
+
+ CMenu menu;
+ menu.Attach(menuSpec);
+
+ CreateSevenZipMenu(menu, operatedIndices, sevenZipContextMenu);
+ if (g_App.ShowSystemMenu)
+ CreateSystemMenu(menu, operatedIndices, systemContextMenu);
+
+ /*
+ if (menu.GetItemCount() > 0)
+ menu.AppendItem(MF_SEPARATOR, 0, (LPCTSTR)0);
+ */
+
+ int i;
+ for (i = 0; i < operatedIndices.Size(); i++)
+ if (IsItemFolder(operatedIndices[i]))
+ break;
+ bool allAreFiles = (i == operatedIndices.Size());
+ LoadFileMenu(menu, menu.GetItemCount(), programMenu,
+ IsFSFolder(), operatedIndices.Size(), allAreFiles);
+}
+
+bool CPanel::InvokePluginCommand(int id)
+{
+ return InvokePluginCommand(id, _sevenZipContextMenu, _systemContextMenu);
+}
+
+bool CPanel::InvokePluginCommand(int id,
+ IContextMenu *sevenZipContextMenu, IContextMenu *systemContextMenu)
+{
+ UInt32 offset;
+ bool isSystemMenu = (id >= kSystemStartMenuID);
+ if (isSystemMenu)
+ offset = id - kSystemStartMenuID;
+ else
+ offset = id - kSevenZipStartMenuID;
+
+ #ifdef UNDER_CE
+ CMINVOKECOMMANDINFO
+ #else
+ CMINVOKECOMMANDINFOEX
+ #endif
+ commandInfo;
+ commandInfo.cbSize = sizeof(commandInfo);
+ commandInfo.fMask = 0
+ #ifndef UNDER_CE
+ | CMIC_MASK_UNICODE
+ #endif
+ ;
+ commandInfo.hwnd = GetParent();
+ commandInfo.lpVerb = (LPCSTR)(MAKEINTRESOURCE(offset));
+ commandInfo.lpParameters = NULL;
+ CSysString currentFolderSys = GetSystemString(_currentFolderPrefix);
+ commandInfo.lpDirectory = (LPCSTR)(LPCTSTR)(currentFolderSys);
+ commandInfo.nShow = SW_SHOW;
+ commandInfo.lpParameters = NULL;
+ #ifndef UNDER_CE
+ commandInfo.lpTitle = "";
+ commandInfo.lpVerbW = (LPCWSTR)(MAKEINTRESOURCEW(offset));
+ UString currentFolderUnicode = _currentFolderPrefix;
+ commandInfo.lpDirectoryW = currentFolderUnicode;
+ commandInfo.lpTitleW = L"";
+ // commandInfo.ptInvoke.x = xPos;
+ // commandInfo.ptInvoke.y = yPos;
+ commandInfo.ptInvoke.x = 0;
+ commandInfo.ptInvoke.y = 0;
+ #endif
+ HRESULT result;
+ if (isSystemMenu)
+ result = systemContextMenu->InvokeCommand(LPCMINVOKECOMMANDINFO(&commandInfo));
+ else
+ result = sevenZipContextMenu->InvokeCommand(LPCMINVOKECOMMANDINFO(&commandInfo));
+ if (result == NOERROR)
+ {
+ KillSelection();
+ return true;
+ }
+ return false;
+}
+
+bool CPanel::OnContextMenu(HANDLE windowHandle, int xPos, int yPos)
+{
+ if (::GetParent((HWND)windowHandle) == _listView)
+ {
+ ShowColumnsContextMenu(xPos, yPos);
+ return true;
+ }
+
+ if (windowHandle != _listView)
+ return false;
+ /*
+ POINT point;
+ point.x = xPos;
+ point.y = yPos;
+ if (!_listView.ScreenToClient(&point))
+ return false;
+
+ LVHITTESTINFO info;
+ info.pt = point;
+ int index = _listView.HitTest(&info);
+ */
+
+ CRecordVector<UInt32> operatedIndices;
+ GetOperatedItemIndices(operatedIndices);
+
+ if (xPos < 0 || yPos < 0)
+ {
+ if (operatedIndices.Size() == 0)
+ {
+ xPos = 0;
+ yPos = 0;
+ }
+ else
+ {
+ int itemIndex = _listView.GetNextItem(-1, LVNI_FOCUSED);
+ if (itemIndex == -1)
+ return false;
+ RECT rect;
+ if (!_listView.GetItemRect(itemIndex, &rect, LVIR_ICON))
+ return false;
+ xPos = (rect.left + rect.right) / 2;
+ yPos = (rect.top + rect.bottom) / 2;
+ }
+ POINT point = {xPos, yPos};
+ _listView.ClientToScreen(&point);
+ xPos = point.x;
+ yPos = point.y;
+ }
+
+ CMenu menu;
+ CMenuDestroyer menuDestroyer(menu);
+ menu.CreatePopup();
+
+ CMyComPtr<IContextMenu> sevenZipContextMenu;
+ CMyComPtr<IContextMenu> systemContextMenu;
+ CreateFileMenu(menu, sevenZipContextMenu, systemContextMenu, false);
+
+ int result = menu.Track(TPM_LEFTALIGN
+ #ifndef UNDER_CE
+ | TPM_RIGHTBUTTON
+ #endif
+ | TPM_RETURNCMD | TPM_NONOTIFY,
+ xPos, yPos, _listView);
+
+ if (result == 0)
+ return true;
+
+ if (result >= kPluginMenuStartID)
+ {
+ InvokePluginCommand(result, sevenZipContextMenu, systemContextMenu);
+ return true;
+ }
+ if (ExecuteFileCommand(result))
+ return true;
+ return true;
+}
+#endif
+
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelOperations.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelOperations.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelOperations.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelOperations.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,475 @@
+// PanelOperations.cpp
+
+#include "StdAfx.h"
+
+#include "Common/DynamicBuffer.h"
+#include "Common/StringConvert.h"
+
+#include "Windows/COM.h"
+#include "Windows/FileDir.h"
+#include "Windows/PropVariant.h"
+#include "Windows/ResourceString.h"
+#include "Windows/Thread.h"
+
+#include "ComboDialog.h"
+
+#include "FSFolder.h"
+#include "FormatUtils.h"
+#include "LangUtils.h"
+#include "Panel.h"
+#include "UpdateCallback100.h"
+
+#include "resource.h"
+
+using namespace NWindows;
+using namespace NFile;
+
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
+
+enum EFolderOpType
+{
+ FOLDER_TYPE_CREATE_FOLDER = 0,
+ FOLDER_TYPE_DELETE = 1,
+ FOLDER_TYPE_RENAME = 2
+};
+
+class CThreadFolderOperations: public CProgressThreadVirt
+{
+ HRESULT ProcessVirt();
+public:
+ EFolderOpType OpType;
+ UString Name;
+ UInt32 Index;
+ CRecordVector<UInt32> Indices;
+
+ CMyComPtr<IFolderOperations> FolderOperations;
+ CMyComPtr<IProgress> UpdateCallback;
+ CUpdateCallback100Imp *UpdateCallbackSpec;
+
+ HRESULT Result;
+
+ CThreadFolderOperations(EFolderOpType opType): OpType(opType), Result(E_FAIL) {};
+ HRESULT DoOperation(CPanel &panel, const UString &progressTitle, const UString &titleError);
+};
+
+HRESULT CThreadFolderOperations::ProcessVirt()
+{
+#ifdef _WIN32
+ NCOM::CComInitializer comInitializer;
+#endif
+ switch(OpType)
+ {
+ case FOLDER_TYPE_CREATE_FOLDER:
+ Result = FolderOperations->CreateFolder(Name, UpdateCallback);
+ break;
+ case FOLDER_TYPE_DELETE:
+ Result = FolderOperations->Delete(&Indices.Front(), Indices.Size(), UpdateCallback);
+ break;
+ case FOLDER_TYPE_RENAME:
+ Result = FolderOperations->Rename(Index, Name, UpdateCallback);
+ break;
+ default:
+ Result = E_FAIL;
+ }
+ return Result;
+};
+
+
+HRESULT CThreadFolderOperations::DoOperation(CPanel &panel, const UString &progressTitle, const UString &titleError)
+{
+ UpdateCallbackSpec = new CUpdateCallback100Imp;
+ UpdateCallback = UpdateCallbackSpec;
+ UpdateCallbackSpec->ProgressDialog = &ProgressDialog;
+
+ // FIXME ProgressDialog.WaitMode = true;
+ ProgressDialog.Sync.SetErrorMessageTitle(titleError);
+ Result = S_OK;
+
+ bool usePassword = false;
+ UString password;
+ if (panel._parentFolders.Size() > 0)
+ {
+ const CFolderLink &fl = panel._parentFolders.Back();
+ usePassword = fl.UsePassword;
+ password = fl.Password;
+ }
+
+ UpdateCallbackSpec->Init(usePassword, password);
+
+ ProgressDialog.MainWindow = panel._mainWindow; // panel.GetParent()
+ ProgressDialog.MainTitle = LangString(IDS_APP_TITLE, 0x03000000);
+ ProgressDialog.MainAddTitle = progressTitle + UString(L" ");
+
+ RINOK(Create(progressTitle, ProgressDialog.MainWindow));
+ return Result;
+}
+
+#ifndef _UNICODE
+typedef int (WINAPI * SHFileOperationWP)(LPSHFILEOPSTRUCTW lpFileOp);
+#endif
+
+void CPanel::DeleteItems(bool toRecycleBin)
+{
+ CPanel::CDisableTimerProcessing disableTimerProcessing2(*this);
+ CRecordVector<UInt32> indices;
+ GetOperatedItemIndices(indices);
+ if (indices.IsEmpty())
+ return;
+ CSelectedState state;
+ SaveSelectedState(state);
+
+ #ifndef UNDER_CE
+ // WM6 / SHFileOperationW doesn't ask user! So we use internal delete
+ bool useInternalDelete = false;
+ if (IsFSFolder() && toRecycleBin)
+ {
+ #ifndef _UNICODE
+ if (!g_IsNT)
+ {
+ CDynamicBuffer<CHAR> buffer;
+ size_t size = 0;
+ for (int i = 0; i < indices.Size(); i++)
+ {
+ const AString path = GetSystemString(GetFsPath() + GetItemRelPath(indices[i]));
+ buffer.EnsureCapacity(size + path.Length() + 1);
+ memmove(((CHAR *)buffer) + size, (const CHAR *)path, (path.Length() + 1) * sizeof(CHAR));
+ size += path.Length() + 1;
+ }
+ buffer.EnsureCapacity(size + 1);
+ ((CHAR *)buffer)[size] = 0;
+ SHFILEOPSTRUCTA fo;
+ fo.hwnd = GetParent();
+ fo.wFunc = FO_DELETE;
+ fo.pFrom = (const CHAR *)buffer;
+ fo.pTo = 0;
+ fo.fFlags = 0;
+ if (toRecycleBin)
+ fo.fFlags |= FOF_ALLOWUNDO;
+ // fo.fFlags |= FOF_NOCONFIRMATION;
+ // fo.fFlags |= FOF_NOERRORUI;
+ // fo.fFlags |= FOF_SILENT;
+ // fo.fFlags |= FOF_WANTNUKEWARNING;
+ fo.fAnyOperationsAborted = FALSE;
+ fo.hNameMappings = 0;
+ fo.lpszProgressTitle = 0;
+ /* int res = */ ::SHFileOperationA(&fo);
+ }
+ else
+ #endif
+ {
+ CDynamicBuffer<WCHAR> buffer;
+ size_t size = 0;
+ int maxLen = 0;
+ for (int i = 0; i < indices.Size(); i++)
+ {
+ // L"\\\\?\\") doesn't work here.
+ const UString path = GetFsPath() + GetItemRelPath(indices[i]);
+ if (path.Length() > maxLen)
+ maxLen = path.Length();
+ buffer.EnsureCapacity(size + path.Length() + 1);
+ memmove(((WCHAR *)buffer) + size, (const WCHAR *)path, (path.Length() + 1) * sizeof(WCHAR));
+ size += path.Length() + 1;
+ }
+ buffer.EnsureCapacity(size + 1);
+ ((WCHAR *)buffer)[size] = 0;
+#ifdef _WIN32
+ if (maxLen >= MAX_PATH)
+ {
+ if (toRecycleBin)
+ {
+ MessageBoxErrorLang(IDS_ERROR_LONG_PATH_TO_RECYCLE, 0x03020218);
+ return;
+ }
+ useInternalDelete = true;
+ }
+ else
+ {
+ SHFILEOPSTRUCTW fo;
+ fo.hwnd = GetParent();
+ fo.wFunc = FO_DELETE;
+ fo.pFrom = (const WCHAR *)buffer;
+ fo.pTo = 0;
+ fo.fFlags = 0;
+ if (toRecycleBin)
+ fo.fFlags |= FOF_ALLOWUNDO;
+ fo.fAnyOperationsAborted = FALSE;
+ fo.hNameMappings = 0;
+ fo.lpszProgressTitle = 0;
+ int res;
+ #ifdef _UNICODE
+ res = ::SHFileOperationW(&fo);
+ #else
+ SHFileOperationWP shFileOperationW = (SHFileOperationWP)
+ ::GetProcAddress(::GetModuleHandleW(L"shell32.dll"), "SHFileOperationW");
+ if (shFileOperationW == 0)
+ return;
+ res = shFileOperationW(&fo);
+ #endif
+ }
+#else
+ // FIXME - how to use the recycle bin undex Gnome or KDE ?
+ useInternalDelete = true;
+#endif
+ }
+ /*
+ if (fo.fAnyOperationsAborted)
+ MessageBoxError(result, LangString(IDS_ERROR_DELETING, 0x03020217));
+ */
+ }
+ else
+ useInternalDelete = true;
+ if (useInternalDelete)
+ #endif
+ DeleteItemsInternal(indices);
+ RefreshListCtrl(state);
+}
+
+void CPanel::MessageBoxErrorForUpdate(HRESULT errorCode, UINT resourceID, UInt32 langID)
+{
+ if (errorCode == E_NOINTERFACE)
+ MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
+ else
+ MessageBoxError(errorCode, LangString(resourceID, langID));
+}
+
+void CPanel::DeleteItemsInternal(CRecordVector<UInt32> &indices)
+{
+ CMyComPtr<IFolderOperations> folderOperations;
+ if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
+ {
+ MessageBoxErrorForUpdate(E_NOINTERFACE, IDS_ERROR_DELETING, 0x03020217);
+ return;
+ }
+
+ UString title;
+ UString message;
+ if (indices.Size() == 1)
+ {
+ int index = indices[0];
+ const UString itemName = GetItemRelPath(index);
+ if (IsItemFolder(index))
+ {
+ title = LangString(IDS_CONFIRM_FOLDER_DELETE, 0x03020211);
+ message = MyFormatNew(IDS_WANT_TO_DELETE_FOLDER, 0x03020214, itemName);
+ }
+ else
+ {
+ title = LangString(IDS_CONFIRM_FILE_DELETE, 0x03020210);
+ message = MyFormatNew(IDS_WANT_TO_DELETE_FILE, 0x03020213, itemName);
+ }
+ }
+ else
+ {
+ title = LangString(IDS_CONFIRM_ITEMS_DELETE, 0x03020212);
+ message = MyFormatNew(IDS_WANT_TO_DELETE_ITEMS, 0x03020215,
+ NumberToString(indices.Size()));
+ }
+ if (::MessageBoxW(GetParent(), message, title, MB_OKCANCEL | MB_ICONQUESTION) != IDOK)
+ return;
+
+ {
+ CThreadFolderOperations op(FOLDER_TYPE_DELETE);
+ op.FolderOperations = folderOperations;
+ op.Indices = indices;
+ op.DoOperation(*this,
+ LangString(IDS_DELETING, 0x03020216),
+ LangString(IDS_ERROR_DELETING, 0x03020217));
+ }
+ RefreshTitleAlways();
+}
+
+#ifdef _WIN32
+BOOL CPanel::OnBeginLabelEdit(LV_DISPINFOW * lpnmh)
+{
+ int realIndex = GetRealIndex(lpnmh->item);
+ if (realIndex == kParentIndex)
+ return TRUE;
+ CMyComPtr<IFolderOperations> folderOperations;
+ if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
+ return TRUE;
+ return FALSE;
+}
+
+BOOL CPanel::OnEndLabelEdit(LV_DISPINFOW * lpnmh)
+{
+ if (lpnmh->item.pszText == NULL)
+ return FALSE;
+ CMyComPtr<IFolderOperations> folderOperations;
+ if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
+ {
+ MessageBoxErrorForUpdate(E_NOINTERFACE, IDS_ERROR_RENAMING, 0x03020221);
+ return FALSE;
+ }
+ const UString newName = lpnmh->item.pszText;
+ CPanel::CDisableTimerProcessing disableTimerProcessing2(*this);
+
+ SaveSelectedState(_selectedState);
+
+ int realIndex = GetRealIndex(lpnmh->item);
+ if (realIndex == kParentIndex)
+ return FALSE;
+ const UString prefix = GetItemPrefix(realIndex);
+
+
+ {
+ CThreadFolderOperations op(FOLDER_TYPE_RENAME);
+ op.FolderOperations = folderOperations;
+ op.Index = realIndex;
+ op.Name = newName;
+ HRESULT res = op.DoOperation(*this,
+ LangString(IDS_RENAMING, 0x03020220),
+ LangString(IDS_ERROR_RENAMING, 0x03020221));
+ if (res != S_OK)
+ return FALSE;
+ }
+
+ // Can't use RefreshListCtrl here.
+ // RefreshListCtrlSaveFocused();
+ _selectedState.FocusedName = prefix + newName;
+ _selectedState.SelectFocused = true;
+
+ // We need clear all items to disable GetText before Reload:
+ // number of items can change.
+ // _listView.DeleteAllItems();
+ // But seems it can still call GetText (maybe for current item)
+ // so we can't delete items.
+
+ _dontShowMode = true;
+
+ PostMessage(kReLoadMessage);
+ return TRUE;
+}
+#endif
+
+void CPanel::CreateFolder()
+{
+ CMyComPtr<IFolderOperations> folderOperations;
+ if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
+ {
+ MessageBoxErrorForUpdate(E_NOINTERFACE, IDS_CREATE_FOLDER_ERROR, 0x03020233);
+ return;
+ }
+ CPanel::CDisableTimerProcessing disableTimerProcessing2(*this);
+ CSelectedState state;
+ SaveSelectedState(state);
+ CComboDialog comboDialog;
+ comboDialog.Title = LangString(IDS_CREATE_FOLDER, 0x03020230);
+ comboDialog.Static = LangString(IDS_CREATE_FOLDER_NAME, 0x03020231);
+ comboDialog.Value = LangString(IDS_CREATE_FOLDER_DEFAULT_NAME, /*0x03020232*/ (UInt32)-1);
+ if (comboDialog.Create(GetParent()) == IDCANCEL)
+ return;
+
+ UString newName = comboDialog.Value;
+
+ {
+ CThreadFolderOperations op(FOLDER_TYPE_CREATE_FOLDER);
+ op.FolderOperations = folderOperations;
+ op.Name = newName;
+ HRESULT res = op.DoOperation(*this,
+ LangString(IDS_CREATE_FOLDER, 0x03020230),
+ LangString(IDS_CREATE_FOLDER_ERROR, 0x03020233));
+ if (res != S_OK)
+ return;
+ }
+ int pos = newName.Find(WCHAR_PATH_SEPARATOR);
+ if (pos >= 0)
+ newName = newName.Left(pos);
+ if (!_mySelectMode)
+ state.SelectedNames.Clear();
+ state.FocusedName = newName;
+ state.SelectFocused = true;
+ RefreshTitleAlways();
+ RefreshListCtrl(state);
+}
+
+void CPanel::CreateFile()
+{
+ CMyComPtr<IFolderOperations> folderOperations;
+ if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
+ {
+ MessageBoxErrorForUpdate(E_NOINTERFACE, IDS_CREATE_FILE_ERROR, 0x03020243);
+ return;
+ }
+ CPanel::CDisableTimerProcessing disableTimerProcessing2(*this);
+ CSelectedState state;
+ SaveSelectedState(state);
+ CComboDialog comboDialog;
+ comboDialog.Title = LangString(IDS_CREATE_FILE, 0x03020240);
+ comboDialog.Static = LangString(IDS_CREATE_FILE_NAME, 0x03020241);
+ comboDialog.Value = LangString(IDS_CREATE_FILE_DEFAULT_NAME, /*0x03020242*/ (UInt32)-1);
+ if (comboDialog.Create(GetParent()) == IDCANCEL)
+ return;
+ UString newName = comboDialog.Value;
+ HRESULT result = folderOperations->CreateFile(newName, 0);
+ if (result != S_OK)
+ {
+ MessageBoxErrorForUpdate(result, IDS_CREATE_FILE_ERROR, 0x03020243);
+ return;
+ }
+ int pos = newName.Find(WCHAR_PATH_SEPARATOR);
+ if (pos >= 0)
+ newName = newName.Left(pos);
+ if (!_mySelectMode)
+ state.SelectedNames.Clear();
+ state.FocusedName = newName;
+ state.SelectFocused = true;
+ RefreshListCtrl(state);
+}
+
+void CPanel::RenameFile()
+{
+ int index = _listView.GetFocusedItem();
+ if (index >= 0)
+ _listView.EditLabel(index);
+}
+
+void CPanel::ChangeComment()
+{
+ CPanel::CDisableTimerProcessing disableTimerProcessing2(*this);
+ int index = _listView.GetFocusedItem();
+ if (index < 0)
+ return;
+ int realIndex = GetRealItemIndex(index);
+ if (realIndex == kParentIndex)
+ return;
+ CSelectedState state;
+ SaveSelectedState(state);
+ CMyComPtr<IFolderOperations> folderOperations;
+ if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK)
+ {
+ MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
+ return;
+ }
+
+ UString comment;
+ {
+ NCOM::CPropVariant propVariant;
+ if (_folder->GetProperty(realIndex, kpidComment, &propVariant) != S_OK)
+ return;
+ if (propVariant.vt == VT_BSTR)
+ comment = propVariant.bstrVal;
+ else if (propVariant.vt != VT_EMPTY)
+ return;
+ }
+ UString name = GetItemRelPath(realIndex);
+ CComboDialog comboDialog;
+ comboDialog.Title = name + L" " + LangString(IDS_COMMENT, 0x03020290);
+ comboDialog.Value = comment;
+ comboDialog.Static = LangString(IDS_COMMENT2, 0x03020291);
+ if (comboDialog.Create(GetParent()) == IDCANCEL)
+ return;
+ // FIXME NCOM::CPropVariant propVariant = comboDialog.Value;
+ NCOM::CPropVariant propVariant(comboDialog.Value);
+
+ HRESULT result = folderOperations->SetProperty(realIndex, kpidComment, &propVariant, NULL);
+ if (result != S_OK)
+ {
+ if (result == E_NOINTERFACE)
+ MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
+ else
+ MessageBoxError(result, L"Set Comment Error");
+ }
+ RefreshListCtrl(state);
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelSelect.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelSelect.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelSelect.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelSelect.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,305 @@
+// PanelSelect.cpp
+
+#include "StdAfx.h"
+
+#include "resource.h"
+
+#include "Common/StringConvert.h"
+#include "Common/Wildcard.h"
+
+#include "Panel.h"
+
+#include "ComboDialog.h"
+
+#include "LangUtils.h"
+
+void CPanel::OnShiftSelectMessage()
+{
+ if (!_mySelectMode)
+ return;
+ int focusedItem = _listView.GetFocusedItem();
+ if (focusedItem < 0)
+ return;
+ if (!_selectionIsDefined)
+ return;
+ int startItem = MyMin(focusedItem, _prevFocusedItem);
+ int finishItem = MyMax(focusedItem, _prevFocusedItem);
+ for (int i = 0; i < _listView.GetItemCount(); i++)
+ {
+ int realIndex = GetRealItemIndex(i);
+ if (realIndex == kParentIndex)
+ continue;
+ if (i >= startItem && i <= finishItem)
+ if (_selectedStatusVector[realIndex] != _selectMark)
+ {
+ _selectedStatusVector[realIndex] = _selectMark;
+ _listView.RedrawItem(i);
+ }
+ }
+ _prevFocusedItem = focusedItem;
+}
+
+#ifdef _WIN32
+void CPanel::OnArrowWithShift()
+{
+ if (!_mySelectMode)
+ return;
+ int focusedItem = _listView.GetFocusedItem();
+ if (focusedItem < 0)
+ return;
+ int realIndex = GetRealItemIndex(focusedItem);
+ if (_selectionIsDefined)
+ {
+ if (realIndex != kParentIndex)
+ _selectedStatusVector[realIndex] = _selectMark;
+ }
+ else
+ {
+ if (realIndex == kParentIndex)
+ {
+ _selectionIsDefined = true;
+ _selectMark = true;
+ }
+ else
+ {
+ _selectionIsDefined = true;
+ _selectMark = !_selectedStatusVector[realIndex];
+ _selectedStatusVector[realIndex] = _selectMark;
+ }
+ }
+ _prevFocusedItem = focusedItem;
+ PostMessage(kShiftSelectMessage);
+ _listView.RedrawItem(focusedItem);
+}
+
+void CPanel::OnInsert()
+{
+ /*
+ const int kState = CDIS_MARKED; // LVIS_DROPHILITED;
+ UINT state = (_listView.GetItemState(focusedItem, LVIS_CUT) == 0) ?
+ LVIS_CUT : 0;
+ _listView.SetItemState(focusedItem, state, LVIS_CUT);
+ // _listView.SetItemState(focusedItem, LVIS_SELECTED, LVIS_SELECTED);
+
+ */
+ int focusedItem = _listView.GetFocusedItem();
+ if (focusedItem < 0)
+ return;
+ int realIndex = GetRealItemIndex(focusedItem);
+ bool isSelected = !_selectedStatusVector[realIndex];
+ if (realIndex != kParentIndex)
+ _selectedStatusVector[realIndex] = isSelected;
+
+ if (!_mySelectMode)
+ _listView.SetItemState(focusedItem, isSelected ? LVIS_SELECTED: 0, LVIS_SELECTED);
+
+ _listView.RedrawItem(focusedItem);
+
+ int nextIndex = focusedItem + 1;
+ if (nextIndex < _listView.GetItemCount())
+ {
+ _listView.SetItemState(nextIndex, LVIS_FOCUSED | LVIS_SELECTED,
+ LVIS_FOCUSED | LVIS_SELECTED);
+ _listView.EnsureVisible(nextIndex, false);
+ }
+}
+#endif // _WIN32
+
+/*
+void CPanel::OnUpWithShift()
+{
+ int focusedItem = _listView.GetFocusedItem();
+ if (focusedItem < 0)
+ return;
+ int index = GetRealItemIndex(focusedItem);
+ _selectedStatusVector[index] = !_selectedStatusVector[index];
+ _listView.RedrawItem(index);
+}
+
+void CPanel::OnDownWithShift()
+{
+ int focusedItem = _listView.GetFocusedItem();
+ if (focusedItem < 0)
+ return;
+ int index = GetRealItemIndex(focusedItem);
+ _selectedStatusVector[index] = !_selectedStatusVector[index];
+ _listView.RedrawItem(index);
+}
+*/
+
+void CPanel::UpdateSelection()
+{
+printf("CPanel::UpdateSelection : _mySelectMode=%d\n",(int)_mySelectMode);
+ if (!_mySelectMode)
+ {
+ bool enableTemp = _enableItemChangeNotify;
+ _enableItemChangeNotify = false;
+ int numItems = _listView.GetItemCount();
+printf("CPanel::UpdateSelection : numItems=%d\n",(int)numItems);
+ for (int i = 0; i < numItems; i++)
+ {
+ int realIndex = GetRealItemIndex(i);
+ if (realIndex != kParentIndex)
+ {
+ UINT value = 0;
+ value = _selectedStatusVector[realIndex] ? LVIS_SELECTED: 0;
+printf("CPanel::UpdateSelection : SetItemState(%d,%d,LVIS_SELECTED)\n",(int)i,(unsigned)value);
+ _listView.SetItemState(i, value, LVIS_SELECTED);
+ }
+ }
+ _enableItemChangeNotify = enableTemp;
+ }
+ _listView.RedrawAllItems();
+}
+
+
+void CPanel::SelectSpec(bool selectMode)
+{
+ CComboDialog comboDialog;
+ comboDialog.Title = selectMode ?
+ LangString(IDS_SELECT, 0x03020250):
+ LangString(IDS_DESELECT, 0x03020251);
+ comboDialog.Static = LangString(IDS_SELECT_MASK, 0x03020252);
+ comboDialog.Value = L"*";
+ if (comboDialog.Create(GetParent()) == IDCANCEL)
+ return;
+ const UString &mask = comboDialog.Value;
+ for (int i = 0; i < _selectedStatusVector.Size(); i++)
+ if (CompareWildCardWithName(mask, GetItemName(i)))
+ _selectedStatusVector[i] = selectMode;
+ UpdateSelection();
+}
+
+void CPanel::SelectByType(bool selectMode)
+{
+ int focusedItem = _listView.GetFocusedItem();
+ if (focusedItem < 0)
+ return;
+ int realIndex = GetRealItemIndex(focusedItem);
+ UString name = GetItemName(realIndex);
+ bool isItemFolder = IsItemFolder(realIndex);
+
+ /*
+ UINT32 numItems;
+ _folder->GetNumberOfItems(&numItems);
+ if ((UInt32)_selectedStatusVector.Size() != numItems)
+ throw 11111;
+ */
+
+ if (isItemFolder)
+ {
+ for (int i = 0; i < _selectedStatusVector.Size(); i++)
+ if (IsItemFolder(i) == isItemFolder)
+ _selectedStatusVector[i] = selectMode;
+ }
+ else
+ {
+ int pos = name.ReverseFind(L'.');
+ if (pos < 0)
+ {
+ for (int i = 0; i < _selectedStatusVector.Size(); i++)
+ if (IsItemFolder(i) == isItemFolder && GetItemName(i).ReverseFind(L'.') < 0)
+ _selectedStatusVector[i] = selectMode;
+ }
+ else
+ {
+ UString mask = UString(L'*') + name.Mid(pos);
+ for (int i = 0; i < _selectedStatusVector.Size(); i++)
+ if (IsItemFolder(i) == isItemFolder && CompareWildCardWithName(mask, GetItemName(i)))
+ _selectedStatusVector[i] = selectMode;
+ }
+ }
+ UpdateSelection();
+}
+
+void CPanel::SelectAll(bool selectMode)
+{
+ for (int i = 0; i < _selectedStatusVector.Size(); i++)
+ _selectedStatusVector[i] = selectMode;
+ UpdateSelection();
+}
+
+void CPanel::InvertSelection()
+{
+ if (!_mySelectMode)
+ {
+ int numSelected = 0;
+ for (int i = 0; i < _selectedStatusVector.Size(); i++)
+ if (_selectedStatusVector[i])
+ numSelected++;
+ if (numSelected == 1)
+ {
+ int focused = _listView.GetFocusedItem();
+ if (focused >= 0)
+ {
+ int realIndex = GetRealItemIndex(focused);
+ if (realIndex >= 0)
+ if (_selectedStatusVector[realIndex])
+ _selectedStatusVector[realIndex] = false;
+ }
+ }
+ }
+ for (int i = 0; i < _selectedStatusVector.Size(); i++)
+ _selectedStatusVector[i] = !_selectedStatusVector[i];
+ UpdateSelection();
+}
+
+void CPanel::KillSelection()
+{
+ SelectAll(false);
+ if (!_mySelectMode)
+ {
+ int focused = _listView.GetFocusedItem();
+ if (focused >= 0)
+ _listView.SetItemState(focused, LVIS_SELECTED, LVIS_SELECTED);
+ }
+}
+
+#ifdef _WIN32
+void CPanel::OnLeftClick(LPNMITEMACTIVATE itemActivate)
+{
+ if(itemActivate->hdr.hwndFrom != HWND(_listView))
+ return;
+ // It will be work only for Version 4.71 (IE 4);
+ int indexInList = itemActivate->iItem;
+ if (indexInList < 0)
+ return;
+ if ((itemActivate->uKeyFlags & LVKF_SHIFT) != 0)
+ {
+ // int focusedIndex = _listView.GetFocusedItem();
+ int focusedIndex = _startGroupSelect;
+ if (focusedIndex < 0)
+ return;
+ int startItem = MyMin(focusedIndex, indexInList);
+ int finishItem = MyMax(focusedIndex, indexInList);
+ for (int i = 0; i < _selectedStatusVector.Size(); i++)
+ {
+ int realIndex = GetRealItemIndex(i);
+ if (realIndex == kParentIndex)
+ continue;
+ bool selected = (i >= startItem && i <= finishItem);
+ if (_selectedStatusVector[realIndex] != selected)
+ {
+ _selectedStatusVector[realIndex] = selected;
+ _listView.RedrawItem(i);
+ }
+ }
+ }
+ else
+ {
+ _startGroupSelect = indexInList;
+ if ((itemActivate->uKeyFlags & LVKF_CONTROL) != 0)
+ {
+ int realIndex = GetRealItemIndex(indexInList);
+ if (realIndex != kParentIndex)
+ {
+ _selectedStatusVector[realIndex] = !_selectedStatusVector[realIndex];
+ _listView.RedrawItem(indexInList);
+ }
+ }
+ }
+ return;
+}
+#endif
+
+
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelSort.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelSort.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelSort.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelSort.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,175 @@
+// PanelSort.cpp
+
+#include "StdAfx.h"
+
+#include "Windows/PropVariant.h"
+
+#include "../../PropID.h"
+
+#include "Panel.h"
+
+using namespace NWindows;
+
+static UString GetExtension(const UString &name)
+{
+ int dotPos = name.ReverseFind(L'.');
+ if (dotPos < 0)
+ return UString();
+ return name.Mid(dotPos);
+}
+
+static int CALLBACK CompareItems2(LPARAM lParam1, LPARAM lParam2, LPARAM lpData)
+{
+ if (lpData == 0) // FIXME NULL)
+ return 0;
+ CPanel *panel = (CPanel*)lpData;
+
+ switch(panel->_sortID)
+ {
+ // if (panel->_sortIndex == 0)
+ case kpidName:
+ {
+ const UString name1 = panel->GetItemName((int)lParam1);
+ const UString name2 = panel->GetItemName((int)lParam2);
+ int res = name1.CompareNoCase(name2);
+ /*
+ if (res != 0 || !panel->_flatMode)
+ return res;
+ const UString prefix1 = panel->GetItemPrefix(lParam1);
+ const UString prefix2 = panel->GetItemPrefix(lParam2);
+ return res = prefix1.CompareNoCase(prefix2);
+ */
+ return res;
+ }
+ case kpidNoProperty:
+ {
+ return MyCompare(lParam1, lParam2);
+ }
+ case kpidExtension:
+ {
+ const UString ext1 = GetExtension(panel->GetItemName((int)lParam1));
+ const UString ext2 = GetExtension(panel->GetItemName((int)lParam2));
+ return ext1.CompareNoCase(ext2);
+ }
+ }
+ /*
+ if (panel->_sortIndex == 1)
+ return MyCompare(file1.Size, file2.Size);
+ return ::CompareFileTime(&file1.MTime, &file2.MTime);
+ */
+
+ // PROPID propID = panel->_properties[panel->_sortIndex].ID;
+ PROPID propID = panel->_sortID;
+
+ NCOM::CPropVariant prop1, prop2;
+ // Name must be first property
+ panel->_folder->GetProperty((UINT32)lParam1, propID, &prop1);
+ panel->_folder->GetProperty((UINT32)lParam2, 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 0;
+}
+
+static int CALLBACK CompareItems(LPARAM lParam1, LPARAM lParam2, LPARAM lpData)
+{
+ if (lpData == 0) // FIXME NULL)
+ return 0;
+ if (lParam1 == kParentIndex) return -1;
+ if (lParam2 == kParentIndex) return 1;
+
+ CPanel *panel = (CPanel*)lpData;
+
+ bool isDir1 = panel->IsItemFolder((int)lParam1);
+ bool isDir2 = panel->IsItemFolder((int)lParam2);
+
+ if (isDir1 && !isDir2) return -1;
+ if (isDir2 && !isDir1) return 1;
+
+ int result = CompareItems2(lParam1, lParam2, lpData);
+ return panel->_ascending ? result: (-result);
+}
+
+
+int
+#if defined(__WIN32__) && !defined(__WXMICROWIN__) // FIXME
+ wxCALLBACK
+#endif
+ CompareItems_WX(long item1, long item2, long sortData)
+{
+ return CompareItems(item1,item2,sortData);
+}
+
+
+/*
+void CPanel::SortItems(int index)
+{
+ if (index == _sortIndex)
+ _ascending = !_ascending;
+ else
+ {
+ _sortIndex = index;
+ _ascending = true;
+ switch (_properties[_sortIndex].ID)
+ {
+ case kpidSize:
+ case kpidPackedSize:
+ case kpidCTime:
+ case kpidATime:
+ case kpidMTime:
+ _ascending = false;
+ break;
+ }
+ }
+ if (sizeof(long) != sizeof(LPARAM)) {
+ printf("INTERNAL ERROR : sizeof(long) != sizeof(LPARAM)\n");
+ exit(-1);
+ }
+ _listView.SortItems(CompareItems_WX, (LPARAM)this);
+ _listView.EnsureVisible(_listView.GetFocusedItem(), false);
+}
+void CPanel::SortItemsWithPropID(PROPID propID)
+{
+ int index = _properties.FindItemWithID(propID);
+ if (index >= 0)
+ SortItems(index);
+}
+*/
+void CPanel::SortItemsWithPropID(PROPID propID)
+{
+ if (propID == _sortID)
+ _ascending = !_ascending;
+ else
+ {
+ _sortID = propID;
+ _ascending = true;
+ switch (propID)
+ {
+ case kpidSize:
+ case kpidPackSize:
+ case kpidCTime:
+ case kpidATime:
+ case kpidMTime:
+ _ascending = false;
+ break;
+ }
+ }
+ _listView.SortItems(CompareItems, (LPARAM)this);
+ _listView.EnsureVisible(_listView.GetFocusedItem(), false);
+}
+
+
+void CPanel::OnColumnClick(LPNMLISTVIEW info)
+{
+ /*
+ int index = _properties.FindItemWithID(_visibleProperties[info->iSubItem].ID);
+ SortItems(index);
+ */
+ SortItemsWithPropID(_visibleProperties[info->iSubItem].ID);
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelSplitFile.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelSplitFile.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelSplitFile.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PanelSplitFile.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,494 @@
+// PanelSplitFile.cpp
+
+#include "StdAfx.h"
+
+#include "Common/IntToString.h"
+
+#include "Windows/Error.h"
+#include "Windows/FileIO.h"
+#include "Windows/FileFind.h"
+
+#include "../GUI/ExtractRes.h"
+
+#include "resource.h"
+
+#include "App.h"
+#include "CopyDialog.h"
+#include "FormatUtils.h"
+#include "LangUtils.h"
+#include "SplitDialog.h"
+#include "SplitUtils.h"
+
+using namespace NWindows;
+
+static const wchar_t *g_Message_FileWriteError = L"File write error";
+
+struct CVolSeqName
+{
+ UString UnchangedPart;
+ UString ChangedPart;
+ CVolSeqName(): ChangedPart(L"000") {};
+
+ void SetNumDigits(UInt64 numVolumes)
+ {
+ ChangedPart = L"000";
+ while (numVolumes > 999)
+ {
+ numVolumes /= 10;
+ ChangedPart += L'0';
+ }
+ }
+
+ bool ParseName(const UString &name)
+ {
+ if (name.Right(2) != L"01")
+ return false;
+ int numLetters = 2;
+ while (numLetters < name.Length())
+ {
+ if (name[name.Length() - numLetters - 1] != '0')
+ break;
+ numLetters++;
+ }
+ UnchangedPart = name.Left(name.Length() - numLetters);
+ ChangedPart = name.Right(numLetters);
+ return true;
+ }
+
+ UString GetNextName()
+ {
+ UString newName;
+ int i;
+ int numLetters = ChangedPart.Length();
+ for (i = numLetters - 1; i >= 0; i--)
+ {
+ wchar_t c = ChangedPart[i];
+ if (c == L'9')
+ {
+ c = L'0';
+ newName = c + newName;
+ if (i == 0)
+ newName = UString(L'1') + newName;
+ continue;
+ }
+ c++;
+ newName = c + newName;
+ i--;
+ for (; i >= 0; i--)
+ newName = ChangedPart[i] + newName;
+ break;
+ }
+ ChangedPart = newName;
+ return UnchangedPart + ChangedPart;
+ }
+};
+
+static const UInt32 kBufSize = (1 << 20);
+
+class CThreadSplit: public CProgressThreadVirt
+{
+ HRESULT ProcessVirt();
+public:
+ UString FilePath;
+ UString VolBasePath;
+ UInt64 NumVolumes;
+ CRecordVector<UInt64> VolumeSizes;
+};
+
+HRESULT CThreadSplit::ProcessVirt()
+{
+ NFile::NIO::CInFile inFile;
+ if (!inFile.Open(FilePath))
+ return GetLastError();
+ NFile::NIO::COutFile outFile;
+ CMyBuffer bufferObject;
+ if (!bufferObject.Allocate(kBufSize))
+ return E_OUTOFMEMORY;
+ Byte *buffer = (Byte *)(void *)bufferObject;
+ UInt64 curVolSize = 0;
+ CVolSeqName seqName;
+ seqName.SetNumDigits(NumVolumes);
+ UInt64 length;
+ if (!inFile.GetLength(length))
+ return GetLastError();
+
+ CProgressSync &sync = ProgressDialog.Sync;
+ sync.SetProgress(length, 0);
+ UInt64 pos = 0;
+
+ UInt64 numFiles = 0;
+ int volIndex = 0;
+
+ for (;;)
+ {
+ UInt64 volSize;
+ if (volIndex < VolumeSizes.Size())
+ volSize = VolumeSizes[volIndex];
+ else
+ volSize = VolumeSizes.Back();
+
+ UInt32 needSize = (UInt32)(MyMin((UInt64)kBufSize, volSize - curVolSize));
+ UInt32 processedSize;
+ if (!inFile.Read(buffer, needSize, processedSize))
+ return GetLastError();
+ if (processedSize == 0)
+ break;
+ needSize = processedSize;
+ if (curVolSize == 0)
+ {
+ UString name = VolBasePath;
+ name += L'.';
+ name += seqName.GetNextName();
+ sync.SetCurrentFileName(name);
+ sync.SetNumFilesCur(numFiles++);
+ if (!outFile.Create(name, false))
+ {
+ HRESULT res = GetLastError();
+ ErrorPath1 = name;
+ return res;
+ }
+ }
+ if (!outFile.Write(buffer, needSize, processedSize))
+ return GetLastError();
+ if (needSize != processedSize)
+ throw g_Message_FileWriteError;
+ curVolSize += processedSize;
+ if (curVolSize == volSize)
+ {
+ outFile.Close();
+ if (volIndex < VolumeSizes.Size())
+ volIndex++;
+ curVolSize = 0;
+ }
+ pos += processedSize;
+ RINOK(sync.SetPosAndCheckPaused(pos));
+ }
+ sync.SetNumFilesCur(numFiles);
+ return S_OK;
+}
+
+void CApp::Split()
+{
+ int srcPanelIndex = GetFocusedPanelIndex();
+ CPanel &srcPanel = Panels[srcPanelIndex];
+ if (!srcPanel.IsFSFolder())
+ {
+ srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
+ return;
+ }
+ CRecordVector<UInt32> indices;
+ srcPanel.GetOperatedItemIndices(indices);
+ if (indices.IsEmpty())
+ return;
+ if (indices.Size() != 1)
+ {
+ srcPanel.MessageBoxErrorLang(IDS_SELECT_ONE_FILE, 0x03020A02);
+ return;
+ }
+ int index = indices[0];
+ if (srcPanel.IsItemFolder(index))
+ {
+ srcPanel.MessageBoxErrorLang(IDS_SELECT_ONE_FILE, 0x03020A02);
+ return;
+ }
+ const UString itemName = srcPanel.GetItemName(index);
+
+ UString srcPath = srcPanel._currentFolderPrefix + srcPanel.GetItemPrefix(index);
+ UString path = srcPath;
+ int destPanelIndex = (NumPanels <= 1) ? srcPanelIndex : (1 - srcPanelIndex);
+ CPanel &destPanel = Panels[destPanelIndex];
+ if (NumPanels > 1)
+ if (destPanel.IsFSFolder())
+ path = destPanel._currentFolderPrefix;
+ CSplitDialog splitDialog;
+ splitDialog.FilePath = srcPanel.GetItemRelPath(index);
+ splitDialog.Path = path;
+ if (splitDialog.Create(srcPanel.GetParent()) == IDCANCEL)
+ return;
+
+ NFile::NFind::CFileInfoW fileInfo;
+ if (!fileInfo.Find(srcPath + itemName))
+ {
+ srcPanel.MessageBoxMyError(L"Can not find file");
+ return;
+ }
+ if (fileInfo.Size <= splitDialog.VolumeSizes.Front())
+ {
+ srcPanel.MessageBoxErrorLang(IDS_SPLIT_VOL_MUST_BE_SMALLER, 0x03020522);
+ return;
+ }
+ const UInt64 numVolumes = GetNumberOfVolumes(fileInfo.Size, splitDialog.VolumeSizes);
+ if (numVolumes >= 100)
+ {
+ wchar_t s[32];
+ ConvertUInt64ToString(numVolumes, s);
+ if (::MessageBoxW(srcPanel, MyFormatNew(IDS_SPLIT_CONFIRM_MESSAGE, 0x03020521, s),
+ LangString(IDS_SPLIT_CONFIRM_TITLE, 0x03020520),
+ MB_YESNOCANCEL | MB_ICONQUESTION) != IDYES)
+ return;
+ }
+
+ path = splitDialog.Path;
+ NFile::NName::NormalizeDirPathPrefix(path);
+ if (!NFile::NDirectory::CreateComplexDirectory(path))
+ {
+ srcPanel.MessageBoxMyError(MyFormatNew(IDS_CANNOT_CREATE_FOLDER, 0x02000603, path));
+ return;
+ }
+
+ {
+ CThreadSplit spliter;
+ spliter.NumVolumes = numVolumes;
+
+ CProgressDialog &progressDialog = spliter.ProgressDialog;
+
+ UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000);
+ UString title = LangString(IDS_SPLITTING, 0x03020510);
+
+ progressDialog.ShowCompressionInfo = false;
+
+ progressDialog.MainWindow = _window;
+ progressDialog.MainTitle = progressWindowTitle;
+ progressDialog.MainAddTitle = title + UString(L" ");
+ progressDialog.Sync.SetTitleFileName(itemName);
+
+
+ spliter.FilePath = srcPath + itemName;
+ spliter.VolBasePath = path + itemName;
+ spliter.VolumeSizes = splitDialog.VolumeSizes;
+
+ // if (splitDialog.VolumeSizes.Size() == 0) return;
+
+ // CPanel::CDisableTimerProcessing disableTimerProcessing1(srcPanel);
+ // CPanel::CDisableTimerProcessing disableTimerProcessing2(destPanel);
+
+ if (spliter.Create(title, _window) != 0)
+ return;
+ }
+ RefreshTitleAlways();
+
+
+ // disableTimerProcessing1.Restore();
+ // disableTimerProcessing2.Restore();
+ // srcPanel.SetFocusToList();
+ // srcPanel.RefreshListCtrlSaveFocused();
+}
+
+
+class CThreadCombine: public CProgressThreadVirt
+{
+ HRESULT ProcessVirt();
+public:
+ UString InputDirPrefix;
+ UStringVector Names;
+ UString OutputPath;
+ UInt64 TotalSize;
+};
+
+HRESULT CThreadCombine::ProcessVirt()
+{
+ NFile::NIO::COutFile outFile;
+ if (!outFile.Create(OutputPath, false))
+ {
+ HRESULT res = GetLastError();
+ ErrorPath1 = OutputPath;
+ return res;
+ }
+
+ CProgressSync &sync = ProgressDialog.Sync;
+ sync.SetProgress(TotalSize, 0);
+
+ CMyBuffer bufferObject;
+ if (!bufferObject.Allocate(kBufSize))
+ return E_OUTOFMEMORY;
+ Byte *buffer = (Byte *)(void *)bufferObject;
+ UInt64 pos = 0;
+ for (int i = 0; i < Names.Size(); i++)
+ {
+ NFile::NIO::CInFile inFile;
+ const UString nextName = InputDirPrefix + Names[i];
+ if (!inFile.Open(nextName))
+ {
+ HRESULT res = GetLastError();
+ ErrorPath1 = nextName;
+ return res;
+ }
+ sync.SetCurrentFileName(nextName);
+ for (;;)
+ {
+ UInt32 processedSize;
+ if (!inFile.Read(buffer, kBufSize, processedSize))
+ {
+ HRESULT res = GetLastError();
+ ErrorPath1 = nextName;
+ return res;
+ }
+ if (processedSize == 0)
+ break;
+ UInt32 needSize = processedSize;
+ if (!outFile.Write(buffer, needSize, processedSize))
+ {
+ HRESULT res = GetLastError();
+ ErrorPath1 = OutputPath;
+ return res;
+ }
+ if (needSize != processedSize)
+ throw g_Message_FileWriteError;
+ pos += processedSize;
+ RINOK(sync.SetPosAndCheckPaused(pos));
+ }
+ }
+ return S_OK;
+}
+
+extern void AddValuePair2(UINT resourceID, UInt32 langID, UInt64 num, UInt64 size, UString &s);
+
+static void AddInfoFileName(const UString &name, UString &dest)
+{
+ dest += L"\n ";
+ dest += name;
+}
+
+void CApp::Combine()
+{
+ int srcPanelIndex = GetFocusedPanelIndex();
+ CPanel &srcPanel = Panels[srcPanelIndex];
+ if (!srcPanel.IsFSFolder())
+ {
+ srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208);
+ return;
+ }
+ CRecordVector<UInt32> indices;
+ srcPanel.GetOperatedItemIndices(indices);
+ if (indices.IsEmpty())
+ return;
+ int index = indices[0];
+ if (indices.Size() != 1 || srcPanel.IsItemFolder(index))
+ {
+ srcPanel.MessageBoxErrorLang(IDS_COMBINE_SELECT_ONE_FILE, 0x03020620);
+ return;
+ }
+ const UString itemName = srcPanel.GetItemName(index);
+
+ UString srcPath = srcPanel._currentFolderPrefix + srcPanel.GetItemPrefix(index);
+ UString path = srcPath;
+ int destPanelIndex = (NumPanels <= 1) ? srcPanelIndex : (1 - srcPanelIndex);
+ CPanel &destPanel = Panels[destPanelIndex];
+ if (NumPanels > 1)
+ if (destPanel.IsFSFolder())
+ path = destPanel._currentFolderPrefix;
+
+ CVolSeqName volSeqName;
+ if (!volSeqName.ParseName(itemName))
+ {
+ srcPanel.MessageBoxErrorLang(IDS_COMBINE_CANT_DETECT_SPLIT_FILE, 0x03020621);
+ return;
+ }
+
+ {
+ CThreadCombine combiner;
+
+ UString nextName = itemName;
+ combiner.TotalSize = 0;
+ for (;;)
+ {
+ NFile::NFind::CFileInfoW fileInfo;
+ if (!fileInfo.Find(srcPath + nextName) || fileInfo.IsDir())
+ break;
+ combiner.Names.Add(nextName);
+ combiner.TotalSize += fileInfo.Size;
+ nextName = volSeqName.GetNextName();
+ }
+ if (combiner.Names.Size() == 1)
+ {
+ srcPanel.MessageBoxErrorLang(IDS_COMBINE_CANT_FIND_MORE_THAN_ONE_PART, 0x03020622);
+ return;
+ }
+
+ if (combiner.TotalSize == 0)
+ {
+ srcPanel.MessageBoxMyError(L"No data");
+ return;
+ }
+
+ UString info;
+ AddValuePair2(IDS_FILES_COLON, 0x02000320, combiner.Names.Size(), combiner.TotalSize, info);
+
+ info += L"\n";
+ info += srcPath;
+
+ int i;
+ for (i = 0; i < combiner.Names.Size() && i < 2; i++)
+ AddInfoFileName(combiner.Names[i], info);
+ if (i != combiner.Names.Size())
+ {
+ if (i + 1 != combiner.Names.Size())
+ AddInfoFileName(L"...", info);
+ AddInfoFileName(combiner.Names.Back(), info);
+ }
+
+ {
+ CCopyDialog copyDialog;
+ copyDialog.Value = path;
+ copyDialog.Title = LangString(IDS_COMBINE, 0x03020600);
+ copyDialog.Title += ' ';
+ copyDialog.Title += srcPanel.GetItemRelPath(index);
+ copyDialog.Static = LangString(IDS_COMBINE_TO, 0x03020601);
+ copyDialog.Info = info;
+ if (copyDialog.Create(srcPanel.GetParent()) == IDCANCEL)
+ return;
+ path = copyDialog.Value;
+ }
+
+ NFile::NName::NormalizeDirPathPrefix(path);
+ if (!NFile::NDirectory::CreateComplexDirectory(path))
+ {
+ srcPanel.MessageBoxMyError(MyFormatNew(IDS_CANNOT_CREATE_FOLDER, 0x02000603, path));
+ return;
+ }
+
+ UString outName = volSeqName.UnchangedPart;
+ while (!outName.IsEmpty())
+ {
+ int lastIndex = outName.Length() - 1;
+ if (outName[lastIndex] != L'.')
+ break;
+ outName.Delete(lastIndex);
+ }
+ if (outName.IsEmpty())
+ outName = L"file";
+
+ NFile::NFind::CFileInfoW fileInfo;
+ UString destFilePath = path + outName;
+ combiner.OutputPath = destFilePath;
+ if (fileInfo.Find(destFilePath))
+ {
+ srcPanel.MessageBoxMyError(MyFormatNew(IDS_FILE_EXIST, 0x03020A04, destFilePath));
+ return;
+ }
+
+ CProgressDialog &progressDialog = combiner.ProgressDialog;
+ progressDialog.ShowCompressionInfo = false;
+
+ UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000);
+ UString title = LangString(IDS_COMBINING, 0x03020610);
+
+ progressDialog.MainWindow = _window;
+ progressDialog.MainTitle = progressWindowTitle;
+ progressDialog.MainAddTitle = title + UString(L" ");
+
+ combiner.InputDirPrefix = srcPath;
+
+ // CPanel::CDisableTimerProcessing disableTimerProcessing1(srcPanel);
+ // CPanel::CDisableTimerProcessing disableTimerProcessing2(destPanel);
+
+ if (combiner.Create(title, _window) != 0)
+ return;
+ }
+ RefreshTitleAlways();
+
+ // disableTimerProcessing1.Restore();
+ // disableTimerProcessing2.Restore();
+ // srcPanel.SetFocusToList();
+ // srcPanel.RefreshListCtrlSaveFocused();
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PasswordDialog.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PasswordDialog.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PasswordDialog.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PasswordDialog.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,51 @@
+// PasswordDialog.cpp
+
+#include "StdAfx.h"
+
+#include "PasswordDialog.h"
+
+#ifdef LANG
+#include "LangUtils.h"
+#endif
+
+#ifdef LANG
+static CIDLangPair kIDLangPairs[] =
+{
+ { IDC_STATIC_PASSWORD_HEADER, 0x02000B01 },
+ { IDC_CHECK_PASSWORD_SHOW, 0x02000B02 },
+ { IDOK, 0x02000702 },
+ { IDCANCEL, 0x02000710 }
+};
+#endif
+
+
+bool CPasswordDialog::OnInit()
+{
+ #ifdef LANG
+ LangSetWindowText(HWND(*this), 0x02000B00);
+ LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
+ #endif
+ _passwordControl.Attach(GetItem(IDC_EDIT_PASSWORD));
+ _passwordControl.SetText(Password);
+ _passwordControl.SetPasswordChar(TEXT('*'));
+ return CModalDialog::OnInit();
+}
+
+bool CPasswordDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
+{
+ if (buttonID == IDC_CHECK_PASSWORD_SHOW)
+ {
+ _passwordControl.SetPasswordChar(IsButtonCheckedBool(IDC_CHECK_PASSWORD_SHOW) ? 0: TEXT('*'));
+ UString password;
+ _passwordControl.GetText(password);
+ _passwordControl.SetText(password);
+ return true;
+ }
+ return CDialog::OnButtonClicked(buttonID, buttonHWND);
+}
+
+void CPasswordDialog::OnOK()
+{
+ _passwordControl.GetText(Password);
+ CModalDialog::OnOK();
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PasswordDialog.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PasswordDialog.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PasswordDialog.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PasswordDialog.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,21 @@
+// PasswordDialog.h
+
+#ifndef __PASSWORDDIALOG_H
+#define __PASSWORDDIALOG_H
+
+#include "Windows/Control/Dialog.h"
+#include "Windows/Control/Edit.h"
+#include "PasswordDialogRes.h"
+
+class CPasswordDialog: public NWindows::NControl::CModalDialog
+{
+ NWindows::NControl::CEdit _passwordControl;
+ virtual void OnOK();
+ virtual bool OnInit();
+ virtual bool OnButtonClicked(int buttonID, HWND buttonHWND);
+public:
+ UString Password;
+ INT_PTR Create(HWND parentWindow = 0) { return CModalDialog::Create(IDD_DIALOG_PASSWORD, parentWindow); }
+};
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PasswordDialogRes.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PasswordDialogRes.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PasswordDialogRes.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PasswordDialogRes.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,4 @@
+#define IDD_DIALOG_PASSWORD 501
+#define IDC_STATIC_PASSWORD_HEADER 1000
+#define IDC_EDIT_PASSWORD 1001
+#define IDC_CHECK_PASSWORD_SHOW 1002
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PasswordDialog_rc.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PasswordDialog_rc.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PasswordDialog_rc.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PasswordDialog_rc.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,66 @@
+// PasswordDialog.cpp
+
+#include "StdAfx.h"
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+// for all others, include the necessary headers (this file is usually all you
+// need because it includes almost all "standard" wxWidgets headers)
+#ifndef WX_PRECOMP
+ #include "wx/wx.h"
+#endif
+
+#undef _WIN32
+
+#include "Windows/Control/DialogImpl.h"
+
+#include "PasswordDialogRes.h"
+
+class CPasswordDialogImpl : public NWindows::NControl::CModalDialogImpl
+{
+ public:
+ CPasswordDialogImpl(NWindows::NControl::CModalDialog *dialog,wxWindow * parent,int id) : CModalDialogImpl(dialog, parent, id, wxT("Enter password"))
+ {
+ bool bShowPassword = false;
+
+ wxBoxSizer* topsizer = new wxBoxSizer(wxVERTICAL);
+
+ {
+ wxStaticBoxSizer *passwdSizer = new wxStaticBoxSizer(new wxStaticBox(this,IDC_STATIC_PASSWORD_HEADER,_T("&Enter password:")),wxVERTICAL);
+
+ wxTextCtrl *TxtPasswd = new wxTextCtrl(this, IDC_EDIT_PASSWORD, L"",
+ wxDefaultPosition, wxSize(260,-1), bShowPassword?wxTE_LEFT:wxTE_PASSWORD );
+
+ wxCheckBox *ChkShowPasswd = new wxCheckBox(this, IDC_CHECK_PASSWORD_SHOW, wxT("&Show password"));
+
+ ChkShowPasswd->SetValue(bShowPassword);
+ passwdSizer->Add(TxtPasswd, 0, wxALL, 5);
+ passwdSizer->Add(ChkShowPasswd, 0, wxALL, 5);
+
+ topsizer->Add(passwdSizer, 0, wxALL, 5);
+ }
+ topsizer->Add(CreateButtonSizer(wxOK|wxCANCEL), 0, wxALL|wxEXPAND, 5);
+
+ this->OnInit();
+
+ SetSizer(topsizer); // use the sizer for layout
+ topsizer->SetSizeHints(this); // set size hints to honour minimum size
+ }
+private:
+ // Any class wishing to process wxWindows events must use this macro
+ DECLARE_EVENT_TABLE()
+};
+
+REGISTER_DIALOG(IDD_DIALOG_PASSWORD,CPasswordDialog,0)
+
+BEGIN_EVENT_TABLE(CPasswordDialogImpl, wxDialog)
+ EVT_BUTTON(wxID_ANY, CModalDialogImpl::OnAnyButton)
+ EVT_CHECKBOX(wxID_ANY, CModalDialogImpl::OnAnyButton)
+ EVT_MENU(WORKER_EVENT, CModalDialogImpl::OnWorkerEvent)
+END_EVENT_TABLE()
+
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PluginInterface.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PluginInterface.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PluginInterface.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PluginInterface.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,31 @@
+// PluginInterface.h
+
+#ifndef __PLUGIN_INTERFACE_H
+#define __PLUGIN_INTERFACE_H
+
+/*
+#include "../../../Common/Types.h"
+#include "../../IDecl.h"
+
+#define PLUGIN_INTERFACE(i, x) DECL_INTERFACE(i, 0x0A, x)
+
+PLUGIN_INTERFACE(IInitContextMenu, 0x00)
+{
+ STDMETHOD(InitContextMenu)(const wchar_t *folder, const wchar_t **names, UINT32 numFiles) PURE;
+};
+
+PLUGIN_INTERFACE(IPluginOptionsCallback, 0x01)
+{
+ STDMETHOD(GetProgramFolderPath)(BSTR *value) PURE;
+ STDMETHOD(GetProgramPath)(BSTR *value) PURE;
+ STDMETHOD(GetRegistryCUPath)(BSTR *value) PURE;
+};
+
+PLUGIN_INTERFACE(IPluginOptions, 0x02)
+{
+ STDMETHOD(PluginOptions)(HWND hWnd, IPluginOptionsCallback *callback) PURE;
+ // STDMETHOD(GetFileExtensions)(BSTR *extensions) PURE;
+};
+*/
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PluginLoader.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PluginLoader.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PluginLoader.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PluginLoader.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,28 @@
+// PluginLoader.h
+
+#ifndef __PLUGIN_LOADER_H
+#define __PLUGIN_LOADER_H
+
+#include "Windows/DLL.h"
+
+typedef UINT32 (WINAPI * CreateObjectPointer)(const GUID *clsID, const GUID *interfaceID, void **outObject);
+
+class CPluginLibrary: public NWindows::NDLL::CLibrary
+{
+public:
+ HRESULT CreateManager(REFGUID clsID, IFolderManager **manager)
+ {
+ CreateObjectPointer createObject = (CreateObjectPointer)GetProc("CreateObject");
+ if (createObject == NULL)
+ return GetLastError();
+ return createObject(&clsID, &IID_IFolderManager, (void **)manager);
+ }
+ HRESULT LoadAndCreateManager(LPCWSTR filePath, REFGUID clsID, IFolderManager **manager)
+ {
+ if (!Load(filePath))
+ return GetLastError();
+ return CreateManager(clsID, manager);
+ }
+};
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ProgramLocation.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ProgramLocation.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ProgramLocation.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ProgramLocation.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,20 @@
+// ProgramLocation.h
+
+#include "StdAfx.h"
+
+#include "ProgramLocation.h"
+
+// #include "Windows/FileName.h"
+#include "Common/StringConvert.h"
+
+
+bool GetProgramFolderPath(UString &folder)
+{
+ const char *p7zip_home_dir = getenv("P7ZIP_HOME_DIR");
+ if (p7zip_home_dir == 0) p7zip_home_dir="./";
+
+ folder = MultiByteToUnicodeString(p7zip_home_dir);
+
+ return true;
+}
+
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ProgramLocation.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ProgramLocation.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ProgramLocation.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ProgramLocation.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,10 @@
+// ProgramLocation.h
+
+#ifndef __PROGRAM_LOCATION_H
+#define __PROGRAM_LOCATION_H
+
+#include "Common/MyString.h"
+
+bool GetProgramFolderPath(UString &folder); // normalized
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ProgressDialog2.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ProgressDialog2.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ProgressDialog2.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ProgressDialog2.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,1049 @@
+// ProgressDialog2.cpp
+
+#include "StdAfx.h"
+
+#include "Common/IntToString.h"
+#include "Common/StringConvert.h"
+
+#include "Windows/Control/Static.h"
+#include "Windows/Error.h"
+
+#include "ProgressDialog2.h"
+#include "DialogSize.h"
+
+#include "ProgressDialog2Res.h"
+
+#include "../GUI/ExtractRes.h"
+
+using namespace NWindows;
+
+extern HINSTANCE g_hInstance;
+
+static const UINT_PTR kTimerID = 3;
+
+static const UINT kCloseMessage = WM_USER + 1;
+
+static const UINT kTimerElapse =
+ #ifdef UNDER_CE
+ 500
+ #else
+ 100
+ #endif
+ ;
+
+#include "LangUtils.h"
+
+#ifdef LANG
+static CIDLangPair kIDLangPairs[] =
+{
+ { IDCANCEL, 0x02000C00 },
+ { IDC_PROGRESS_ELAPSED, 0x02000C01 },
+ { IDC_PROGRESS_REMAINING, 0x02000C02 },
+ { IDC_PROGRESS_TOTAL, 0x02000C03 },
+ { IDC_PROGRESS_SPEED, 0x02000C04 },
+ { IDC_PROGRESS_UNPACKED, 0x02000C05 },
+ { IDC_PROGRESS_PACKED, 0x02000323 },
+ { IDC_PROGRESS_RATIO, 0x02000C06 },
+ { IDC_PROGRESS_SPEED, 0x02000C04 },
+ { IDC_PROGRESS_FILES, 0x02000320 },
+ { IDC_PROGRESS_ERRORS, 0x0308000A },
+ { IDC_BUTTON_PROGRESS_PRIORITY, 0x02000C10 },
+ { IDC_BUTTON_PAUSE, 0x02000C12 },
+ { IDCANCEL, 0x02000711 },
+};
+#endif
+
+HRESULT CProgressSync::ProcessStopAndPause()
+{
+ for (;;)
+ {
+ if (GetStopped())
+ return E_ABORT;
+ if (!GetPaused())
+ break;
+ ::Sleep(100);
+ }
+ return S_OK;
+}
+
+HRESULT CProgressSync::SetPosAndCheckPaused(UInt64 completed)
+{
+ RINOK(ProcessStopAndPause());
+ SetPos(completed);
+ return S_OK;
+}
+
+
+CProgressDialog::CProgressDialog(): _timer(0), CompressingMode(true)
+ #ifndef _SFX
+ , MainWindow(0)
+ #endif
+ {
+ IconID = -1;
+ MessagesDisplayed = false;
+ _wasCreated = false;
+ _needClose = false;
+ _inCancelMessageBox = false;
+ _externalCloseMessageWasReceived = false;
+
+ _numPostedMessages = 0;
+ _numAutoSizeMessages = 0;
+ _errorsWereDisplayed = false;
+ _waitCloseByCancelButton = false;
+ _cancelWasPressed = false;
+ ShowCompressionInfo = true;
+ // FIXME not supported WaitMode = false;
+ if (_dialogCreatedEvent.Create() != S_OK)
+ throw 1334987;
+ if (_createDialogEvent.Create() != S_OK)
+ throw 1334987;
+ }
+
+#ifndef _SFX
+CProgressDialog::~CProgressDialog()
+{
+ AddToTitle(L"");
+}
+void CProgressDialog::AddToTitle(LPCWSTR s)
+{
+ if (MainWindow != 0)
+ {
+ CWindow window(MainWindow);
+ window.SetText(s + UString(MainTitle));
+ }
+}
+
+#endif
+
+static const int kTitleFileNameSizeLimit = 36;
+static const int kCurrentFileNameSizeLimit = 82;
+
+static void ReduceString(UString &s, int size)
+{
+ if (s.Length() > size)
+ s = s.Left(size / 2) + UString(L" ... ") + s.Right(size / 2);
+}
+
+void CProgressDialog::EnableErrorsControls(bool enable)
+{
+ int cmdShow = enable ? SW_SHOW : SW_HIDE;
+ ShowItem(IDC_PROGRESS_ERRORS, cmdShow);
+ ShowItem(IDC_PROGRESS_ERRORS_VALUE, cmdShow);
+ ShowItem(IDC_PROGRESS_LIST, cmdShow);
+}
+
+bool CProgressDialog::OnInit()
+{
+ _range = (UInt64)(Int64)-1;
+ _prevPercentValue = (UInt32)-1;
+ _prevElapsedSec = (UInt32)-1;
+ _prevRemainingSec = (UInt32)-1;
+ _prevSpeed = (UInt32)-1;
+ _prevMode = kSpeedBytes;
+ _prevTime = ::GetTickCount();
+ _elapsedTime = 0;
+ _foreground = true;
+
+ m_ProgressBar.Attach(GetItem(IDC_PROGRESS1));
+ // FIXME _messageList.Attach(GetItem(IDC_PROGRESS_LIST));
+
+ _wasCreated = true;
+ _dialogCreatedEvent.Set();
+
+ #ifdef LANG
+ LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
+ #endif
+
+
+ CWindow window(GetItem(IDC_BUTTON_PROGRESS_PRIORITY));
+ window.GetText(backgroundString);
+ backgroundedString = backgroundString;
+ backgroundedString.Replace(L"&", L"");
+
+ window = GetItem(IDC_BUTTON_PAUSE);
+ window.GetText(pauseString);
+
+ foregroundString = LangStringSpec(IDS_PROGRESS_FOREGROUND, 0x02000C11);
+ continueString = LangStringSpec(IDS_PROGRESS_CONTINUE, 0x02000C13);
+ pausedString = LangStringSpec(IDS_PROGRESS_PAUSED, 0x02000C20);
+
+ SetText(_title);
+ SetPauseText();
+ SetPriorityText();
+
+
+ #ifndef UNDER_CE
+ // FIXME _messageList.SetUnicodeFormat(true);
+ #endif
+
+ // FIXME _messageList.InsertColumn(0, L"", 30);
+
+ const UString s = LangStringSpec(IDS_MESSAGES_DIALOG_MESSAGE_COLUMN, 0x02000A80);
+
+ // FIXME _messageList.InsertColumn(1, s, 600);
+
+ // FIXME _messageList.SetColumnWidthAuto(0);
+ // FIXME _messageList.SetColumnWidthAuto(1);
+
+
+ EnableErrorsControls(false);
+
+#ifdef _WIN32
+ GetItemSizes(IDCANCEL, buttonSizeX, buttonSizeY);
+#endif
+ _numReduceSymbols = kCurrentFileNameSizeLimit;
+ NormalizeSize(true);
+
+ if (!ShowCompressionInfo)
+ {
+ HideItem(IDC_PROGRESS_PACKED);
+ HideItem(IDC_PROGRESS_PACKED_VALUE);
+ HideItem(IDC_PROGRESS_RATIO);
+ HideItem(IDC_PROGRESS_RATIO_VALUE);
+ }
+
+#ifdef _WIN32
+ if (IconID >= 0)
+ {
+ HICON icon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IconID));
+ // SetIcon(ICON_SMALL, icon);
+ SetIcon(ICON_BIG, icon);
+ }
+#endif
+ _timer = SetTimer(kTimerID, kTimerElapse);
+ #ifdef UNDER_CE
+ Foreground();
+ #endif
+
+ CheckNeedClose();
+
+ return CModalDialog::OnInit();
+}
+
+bool CProgressDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize)
+{
+#ifdef _WIN32
+ int sY;
+ int sStep;
+ int mx, my;
+ {
+ RECT rect;
+ GetClientRectOfItem(IDC_PROGRESS_ELAPSED, rect);
+ mx = rect.left;
+ my = rect.top;
+ sY = rect.bottom - rect.top;
+ GetClientRectOfItem(IDC_PROGRESS_REMAINING, rect);
+ sStep = rect.top - my;
+ }
+
+
+ InvalidateRect(NULL);
+
+ int xSizeClient = xSize - mx * 2;
+
+ {
+ int i;
+ for (i = 800; i > 40; i = i * 9 / 10)
+ if (Units_To_Pixels_X(i) <= xSizeClient)
+ break;
+ _numReduceSymbols = i / 4;
+ }
+
+ int yPos = ySize - my - buttonSizeY;
+
+ ChangeSubWindowSizeX(GetItem(IDC_PROGRESS_FILE_NAME), xSize - mx * 2);
+ ChangeSubWindowSizeX(GetItem(IDC_PROGRESS1), xSize - mx * 2);
+
+ int bSizeX = buttonSizeX;
+ int mx2 = mx;
+ for (;; mx2--)
+ {
+ int bSize2 = bSizeX * 3 + mx2 * 2;
+ if (bSize2 <= xSizeClient)
+ break;
+ if (mx2 < 5)
+ {
+ bSizeX = (xSizeClient - mx2 * 2) / 3;
+ break;
+ }
+ }
+ if (bSizeX < 2)
+ bSizeX = 2;
+
+ {
+ RECT rect;
+ GetClientRectOfItem(IDC_PROGRESS_LIST, rect);
+ int y = rect.top;
+ int ySize2 = yPos - my - y;
+ const int kMinYSize = buttonSizeY + buttonSizeY * 3 / 4;
+ int xx = xSize - mx * 2;
+ if (ySize2 < kMinYSize)
+ {
+ ySize2 = kMinYSize;
+ if (xx > bSizeX * 2)
+ xx -= bSizeX;
+ }
+
+ // FIXME _messageList.Move(mx, y, xx, ySize2);
+ }
+
+ {
+ int xPos = xSize - mx;
+ xPos -= bSizeX;
+ MoveItem(IDCANCEL, xPos, yPos, bSizeX, buttonSizeY);
+ xPos -= (mx2 + bSizeX);
+ MoveItem(IDC_BUTTON_PAUSE, xPos, yPos, bSizeX, buttonSizeY);
+ xPos -= (mx2 + bSizeX);
+ MoveItem(IDC_BUTTON_PROGRESS_PRIORITY, xPos, yPos, bSizeX, buttonSizeY);
+ }
+
+ int valueSize;
+ int labelSize;
+ int padSize;
+
+ labelSize = Units_To_Pixels_X(MY_PROGRESS_LABEL_UNITS_MIN);
+ valueSize = Units_To_Pixels_X(MY_PROGRESS_VALUE_UNITS);
+ padSize = Units_To_Pixels_X(MY_PROGRESS_PAD_UNITS);
+ int requiredSize = (labelSize + valueSize) * 2 + padSize;
+
+ int gSize;
+ {
+ if (requiredSize < xSizeClient)
+ {
+ int incr = (xSizeClient - requiredSize) / 3;
+ labelSize += incr;
+ }
+ else
+ labelSize = (xSizeClient - valueSize * 2 - padSize) / 2;
+ if (labelSize < 0)
+ labelSize = 0;
+
+ gSize = labelSize + valueSize;
+ padSize = xSizeClient - gSize * 2;
+ }
+
+ labelSize = gSize - valueSize;
+
+ UINT IDs[] =
+ {
+ IDC_PROGRESS_ELAPSED, IDC_PROGRESS_ELAPSED_VALUE,
+ IDC_PROGRESS_REMAINING, IDC_PROGRESS_REMAINING_VALUE,
+ IDC_PROGRESS_FILES, IDC_PROGRESS_FILES_VALUE,
+ IDC_PROGRESS_RATIO, IDC_PROGRESS_RATIO_VALUE,
+ IDC_PROGRESS_ERRORS, IDC_PROGRESS_ERRORS_VALUE,
+
+ IDC_PROGRESS_TOTAL, IDC_PROGRESS_TOTAL_VALUE,
+ IDC_PROGRESS_SPEED, IDC_PROGRESS_SPEED_VALUE,
+ IDC_PROGRESS_UNPACKED, IDC_PROGRESS_UNPACKED_VALUE,
+ IDC_PROGRESS_PACKED, IDC_PROGRESS_PACKED_VALUE
+ };
+
+ yPos = my;
+ for (int i = 0; i < sizeof(IDs) / sizeof(IDs[0]); i += 2)
+ {
+ int x = mx;
+ const int kNumColumn1Items = 5 * 2;
+ if (i >= kNumColumn1Items)
+ {
+ if (i == kNumColumn1Items)
+ yPos = my;
+ x = mx + gSize + padSize;
+ }
+ MoveItem(IDs[i], x, yPos, labelSize, sY);
+ MoveItem(IDs[i + 1], x + labelSize, yPos, valueSize, sY);
+ yPos += sStep;
+ }
+#endif // ifdef _WIN32
+ return false;
+}
+
+void CProgressDialog::OnCancel() { Sync.SetStopped(true); }
+void CProgressDialog::OnOK() { }
+
+static void ConvertSizeToString(UInt64 value, wchar_t *s)
+{
+ const wchar_t *kModif = L" KM";
+ for (int i = 0; ; i++)
+ if (i == 2 || value < (UInt64(10000) << (i * 10)))
+ {
+ ConvertUInt64ToString(value >> (i * 10), s);
+ s += wcslen(s);
+ *s++ = ' ';
+ if (i != 0)
+ *s++ = kModif[i];
+ *s++ = L'B';
+ *s++ = L'\0';
+ return;
+ }
+}
+
+void CProgressDialog::SetRange(UInt64 range)
+{
+ _range = range;
+ _previousPos = (UInt64)(Int64)-1;
+ _converter.Init(range);
+ m_ProgressBar.SetRange32(0, _converter.Count(range));
+}
+
+void CProgressDialog::SetPos(UInt64 pos)
+{
+ bool redraw = true;
+ if (pos < _range && pos > _previousPos)
+ {
+ if (pos - _previousPos < (_range >> 10))
+ redraw = false;
+ }
+ if(redraw)
+ {
+ m_ProgressBar.SetPos(_converter.Count(pos)); // Test it for 100%
+ _previousPos = pos;
+ }
+}
+
+static void GetTimeString(UInt64 timeValue, TCHAR *s)
+{
+ wsprintf(s, TEXT("%02d:%02d:%02d"),
+ UInt32(timeValue / 3600),
+ UInt32((timeValue / 60) % 60),
+ UInt32(timeValue % 60));
+}
+
+void CProgressDialog::ShowSize(int id, UInt64 value)
+{
+ wchar_t s[40];
+ s[0] = 0;
+ if (value != (UInt64)(Int64)-1)
+ ConvertSizeToString(value, s);
+ SetItemText(id, s);
+}
+
+void CProgressDialog::UpdateStatInfo(bool showAll)
+{
+ UInt64 total, completed, totalFiles, completedFiles, inSize, outSize;
+ bool bytesProgressMode;
+ Sync.GetProgress(total, completed, totalFiles, completedFiles, inSize, outSize, bytesProgressMode);
+
+ UInt32 curTime = ::GetTickCount();
+
+ UInt64 progressTotal = bytesProgressMode ? total : totalFiles;
+ UInt64 progressCompleted = bytesProgressMode ? completed : completedFiles;
+
+ if (progressTotal != _range)
+ SetRange(progressTotal);
+ if (progressTotal == (UInt64)(Int64)-1)
+ {
+ SetPos(0);
+ SetRange(progressCompleted);
+ }
+ else
+ SetPos(progressCompleted);
+
+ wchar_t s[32] = { 0 };
+ if (total != (UInt64)(Int64)-1)
+ ConvertSizeToString(total, s);
+ SetItemText(IDC_PROGRESS_TOTAL_VALUE, s);
+
+ _elapsedTime += (curTime - _prevTime);
+ _prevTime = curTime;
+
+ UInt32 elapsedSec = _elapsedTime / 1000;
+
+ bool elapsedChanged = false;
+ if (elapsedSec != _prevElapsedSec)
+ {
+ TCHAR s[40];
+ GetTimeString(elapsedSec, s);
+ SetItemText(IDC_PROGRESS_ELAPSED_VALUE, s);
+ _prevElapsedSec = elapsedSec;
+ elapsedChanged = true;
+ }
+
+ if (elapsedChanged || showAll)
+ {
+ {
+ UInt64 numErrors;
+
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(Sync._cs);
+ numErrors = Sync.Messages.Size();
+ }
+ if (numErrors > 0)
+ {
+ UpdateMessagesDialog();
+ TCHAR s[40];
+ ConvertUInt64ToString(numErrors, s);
+ SetItemText(IDC_PROGRESS_ERRORS_VALUE, s);
+ if (!_errorsWereDisplayed)
+ {
+ _errorsWereDisplayed = true;
+ EnableErrorsControls(true);
+ }
+ }
+ }
+
+ if (completed != 0)
+ {
+
+ if (total == (UInt64)(Int64)-1)
+ {
+ SetItemText(IDC_PROGRESS_REMAINING_VALUE, L"");
+ }
+ else
+ {
+ UInt64 remainingTime = 0;
+ if (completed < total)
+ remainingTime = _elapsedTime * (total - completed) / completed;
+ UInt64 remainingSec = remainingTime / 1000;
+ if (remainingSec != _prevRemainingSec)
+ {
+ TCHAR s[40];
+ GetTimeString(remainingSec, s);
+ SetItemText(IDC_PROGRESS_REMAINING_VALUE, s);
+ _prevRemainingSec = remainingSec;
+ }
+ }
+ {
+ UInt32 elapsedTime = (_elapsedTime == 0) ? 1 : _elapsedTime;
+ UInt64 speedB = (completed * 1000) / elapsedTime;
+ UInt64 speedKB = speedB / 1024;
+ UInt64 speedMB = speedKB / 1024;
+ const UInt32 kLimit1 = 10;
+ TCHAR s[40];
+ bool needRedraw = false;
+ if (speedMB >= kLimit1)
+ {
+ if (_prevMode != kSpeedMBytes || speedMB != _prevSpeed)
+ {
+ ConvertUInt64ToString(speedMB, s);
+ lstrcat(s, TEXT(" MB/s"));
+ _prevMode = kSpeedMBytes;
+ _prevSpeed = speedMB;
+ needRedraw = true;
+ }
+ }
+ else if (speedKB >= kLimit1)
+ {
+ if (_prevMode != kSpeedKBytes || speedKB != _prevSpeed)
+ {
+ ConvertUInt64ToString(speedKB, s);
+ lstrcat(s, TEXT(" KB/s"));
+ _prevMode = kSpeedKBytes;
+ _prevSpeed = speedKB;
+ needRedraw = true;
+ }
+ }
+ else
+ {
+ if (_prevMode != kSpeedBytes || speedB != _prevSpeed)
+ {
+ ConvertUInt64ToString(speedB, s);
+ lstrcat(s, TEXT(" B/s"));
+ _prevMode = kSpeedBytes;
+ _prevSpeed = speedB;
+ needRedraw = true;
+ }
+ }
+ if (needRedraw)
+ SetItemText(IDC_PROGRESS_SPEED_VALUE, s);
+ }
+ }
+
+ if (total == 0)
+ total = 1;
+ UInt32 percentValue = (UInt32)(completed * 100 / total);
+ UString titleName;
+ Sync.GetTitleFileName(titleName);
+ if (percentValue != _prevPercentValue || _prevTitleName != titleName)
+ {
+ _prevPercentValue = percentValue;
+ SetTitleText();
+ _prevTitleName = titleName;
+ }
+
+ TCHAR s[64];
+ ConvertUInt64ToString(completedFiles, s);
+ if (totalFiles != (UInt64)(Int64)-1)
+ {
+ lstrcat(s, TEXT(" / "));
+ ConvertUInt64ToString(totalFiles, s + lstrlen(s));
+ }
+
+ SetItemText(IDC_PROGRESS_FILES_VALUE, s);
+
+ const UInt64 packSize = CompressingMode ? outSize : inSize;
+ const UInt64 unpackSize = CompressingMode ? inSize : outSize;
+
+ if (unpackSize == (UInt64)(Int64)-1 && packSize == (UInt64)(Int64)-1)
+ {
+ ShowSize(IDC_PROGRESS_UNPACKED_VALUE, completed);
+ SetItemText(IDC_PROGRESS_PACKED_VALUE, L"");
+ }
+ else
+ {
+ ShowSize(IDC_PROGRESS_UNPACKED_VALUE, unpackSize);
+ ShowSize(IDC_PROGRESS_PACKED_VALUE, packSize);
+
+ if (packSize != (UInt64)(Int64)-1 && unpackSize != (UInt64)(Int64)-1 && unpackSize != 0)
+ {
+ UInt64 ratio = packSize * 100 / unpackSize;
+ ConvertUInt64ToString(ratio, s);
+ lstrcat(s, TEXT("%"));
+ SetItemText(IDC_PROGRESS_RATIO_VALUE, s);
+ }
+ }
+ }
+
+
+ UString fileName;
+ Sync.GetCurrentFileName(fileName);
+ if (_prevFileName != fileName)
+ {
+ int slashPos = fileName.ReverseFind(WCHAR_PATH_SEPARATOR);
+ UString s1, s2;
+ if (slashPos >= 0)
+ {
+ s1 = fileName.Left(slashPos + 1);
+ s2 = fileName.Mid(slashPos + 1);
+ }
+ else
+ s2 = fileName;
+ ReduceString(s1, _numReduceSymbols);
+ ReduceString(s2, _numReduceSymbols);
+ UString s = s1 + L"\n" + s2;
+ SetItemText(IDC_PROGRESS_FILE_NAME, s);
+ _prevFileName == fileName;
+ }
+}
+
+bool CProgressDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */)
+{
+ if (Sync.GetPaused())
+ return true;
+
+ CheckNeedClose();
+
+ UpdateStatInfo(false);
+ return true;
+}
+
+#ifdef _WIN32 // FIXME
+struct CWaitCursor
+{
+ HCURSOR _waitCursor;
+ HCURSOR _oldCursor;
+ CWaitCursor()
+ {
+ _waitCursor = LoadCursor(NULL, IDC_WAIT);
+ if (_waitCursor != NULL)
+ _oldCursor = SetCursor(_waitCursor);
+ }
+ ~CWaitCursor()
+ {
+ if (_waitCursor != NULL)
+ SetCursor(_oldCursor);
+ }
+};
+#endif
+
+INT_PTR CProgressDialog::Create(const UString &title, NWindows::CThread &thread, HWND wndParent)
+{
+ INT_PTR res = 0;
+ try
+ {
+#ifdef _WIN32
+ if (WaitMode)
+ {
+ CWaitCursor waitCursor;
+ HANDLE h[] = { thread, _createDialogEvent };
+
+ WRes res = WaitForMultipleObjects(sizeof(h) / sizeof(h[0]), h, FALSE,
+ #ifdef UNDER_CE
+ 2500
+ #else
+ 1000
+ #endif
+ );
+ if (res == WAIT_OBJECT_0 && !Sync.ThereIsMessage())
+ return 0;
+ }
+#endif
+ _title = title;
+ BIG_DIALOG_SIZE(360, 192);
+ res = CModalDialog::Create(SIZED_DIALOG(IDD_DIALOG_PROGRESS), wndParent);
+ }
+ catch(...)
+ {
+ _wasCreated = true;
+ _dialogCreatedEvent.Set();
+ res = res;
+ }
+ thread.Wait();
+ if (!MessagesDisplayed)
+ MessageBoxW(wndParent, L"Progress Error", L"7-Zip", MB_ICONERROR | MB_OK);
+ return res;
+}
+
+bool CProgressDialog::OnExternalCloseMessage()
+{
+ UpdateStatInfo(true);
+
+ HideItem(IDC_BUTTON_PROGRESS_PRIORITY);
+ HideItem(IDC_BUTTON_PAUSE);
+ SetItemText(IDCANCEL, LangStringSpec(IDS_CLOSE, 0x02000713));
+
+ bool thereAreMessages;
+ UString okMessage;
+ UString okMessageTitle;
+ UString errorMessage;
+ UString errorMessageTitle;
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(Sync._cs);
+ errorMessage = Sync.ErrorMessage;
+ errorMessageTitle = Sync.ErrorMessageTitle;
+ okMessage = Sync.OkMessage;
+ okMessageTitle = Sync.OkMessageTitle;
+ thereAreMessages = !Sync.Messages.IsEmpty();
+ }
+ if (!errorMessage.IsEmpty())
+ {
+ MessagesDisplayed = true;
+ if (errorMessageTitle.IsEmpty())
+ errorMessageTitle = L"7-Zip";
+ MessageBoxW(*this, errorMessage, errorMessageTitle, MB_ICONERROR | MB_OK);
+ }
+ else if (!thereAreMessages)
+ {
+ MessagesDisplayed = true;
+ if (!okMessage.IsEmpty())
+ {
+ if (okMessageTitle.IsEmpty())
+ okMessageTitle = L"7-Zip";
+ MessageBoxW(*this, okMessage, okMessageTitle, MB_OK);
+ }
+ }
+
+ if (thereAreMessages && !_cancelWasPressed)
+ {
+
+#ifdef _WIN32
+ _waitCloseByCancelButton = true;
+ UpdateMessagesDialog();
+ return true;
+#else
+
+ // FIXME : p7zip does not have a messages zone
+ // FIXME : even if so, the close button does not close the main window
+ // So p7zip uses a MessageBoxW ...
+ UStringVector messages;
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(Sync._cs);
+ for (int i = 0; i < Sync.Messages.Size(); i++)
+ messages.Add(Sync.Messages[i]);
+ _numPostedMessages = Sync.Messages.Size();
+ }
+
+ if (!messages.IsEmpty())
+ {
+ for (int i = 0; i < messages.Size(); i++)
+ errorMessage = errorMessage + messages[i] + L"\n";
+ }
+ else
+ errorMessage = L"Error(s) in the archive";
+
+ MessageBoxW(*this, errorMessage, L"7-Zip - ERROR", MB_ICONERROR | MB_OK);
+
+ MessagesDisplayed = true;
+
+#endif
+ }
+
+ End(0);
+ return true;
+}
+
+bool CProgressDialog::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
+{
+ switch(message)
+ {
+ case kCloseMessage:
+ {
+ KillTimer(_timer);
+ _timer = 0;
+ if (_inCancelMessageBox)
+ {
+ _externalCloseMessageWasReceived = true;
+ break;
+ }
+ return OnExternalCloseMessage();
+ }
+ /*
+ case WM_SETTEXT:
+ {
+ if (_timer == 0)
+ return true;
+ break;
+ }
+ */
+ }
+ return CModalDialog::OnMessage(message, wParam, lParam);
+}
+
+void CProgressDialog::SetTitleText()
+{
+ UString title;
+ if (Sync.GetPaused())
+ {
+ title = pausedString;
+ title += L' ';
+ }
+ if (_prevPercentValue != (UInt32)-1)
+ {
+ wchar_t s[64];
+ ConvertUInt64ToString(_prevPercentValue, s);
+ title += s;
+ title += L'%';
+ }
+ if (!_foreground)
+ {
+ title += L' ';
+ title += backgroundedString;
+ }
+ title += L' ';
+ UString totalTitle = title + _title;
+ UString fileName;
+ Sync.GetTitleFileName(fileName);
+ if (!fileName.IsEmpty())
+ {
+ ReduceString(fileName, kTitleFileNameSizeLimit);
+ totalTitle += L' ';
+ totalTitle += fileName;
+ }
+ SetText(totalTitle);
+ #ifndef _SFX
+ AddToTitle(title + MainAddTitle);
+ #endif
+}
+
+void CProgressDialog::SetPauseText()
+{
+ SetItemText(IDC_BUTTON_PAUSE, Sync.GetPaused() ?
+ continueString : pauseString);
+ SetTitleText();
+}
+
+void CProgressDialog::OnPauseButton()
+{
+ bool paused = !Sync.GetPaused();
+ Sync.SetPaused(paused);
+ UInt32 curTime = ::GetTickCount();
+ if (paused)
+ _elapsedTime += (curTime - _prevTime);
+ _prevTime = curTime;
+ SetPauseText();
+}
+
+void CProgressDialog::SetPriorityText()
+{
+ SetItemText(IDC_BUTTON_PROGRESS_PRIORITY, _foreground ?
+ backgroundString :
+ foregroundString);
+ SetTitleText();
+}
+
+void CProgressDialog::OnPriorityButton()
+{
+ _foreground = !_foreground;
+ #ifndef UNDER_CE
+ SetPriorityClass(GetCurrentProcess(), _foreground ?
+ NORMAL_PRIORITY_CLASS: IDLE_PRIORITY_CLASS);
+ #endif
+ SetPriorityText();
+}
+
+void CProgressDialog::AddMessageDirect(LPCWSTR message)
+{
+#ifdef _WIN32 // FIXME
+ int itemIndex = _messageList.GetItemCount();
+ wchar_t sz[32];
+ ConvertInt64ToString(itemIndex, sz);
+ _messageList.InsertItem(itemIndex, sz);
+ _messageList.SetSubItem(itemIndex, 1, message);
+#endif
+}
+
+void CProgressDialog::AddMessage(LPCWSTR message)
+{
+ UString s = message;
+ while (!s.IsEmpty())
+ {
+ int pos = s.Find(L'\n');
+ if (pos < 0)
+ break;
+ AddMessageDirect(s.Left(pos));
+ s.Delete(0, pos + 1);
+ }
+ AddMessageDirect(s);
+}
+
+static unsigned GetNumDigits(UInt32 value)
+{
+ unsigned i;
+ for (i = 0; value >= 10; i++)
+ value /= 10;
+ return i;
+}
+
+void CProgressDialog::UpdateMessagesDialog()
+{
+ UStringVector messages;
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(Sync._cs);
+ for (int i = _numPostedMessages; i < Sync.Messages.Size(); i++)
+ messages.Add(Sync.Messages[i]);
+ _numPostedMessages = Sync.Messages.Size();
+ }
+ if (!messages.IsEmpty())
+ {
+ for (int i = 0; i < messages.Size(); i++)
+ AddMessage(messages[i]);
+ if (_numAutoSizeMessages < 256 || GetNumDigits(_numPostedMessages) > GetNumDigits(_numAutoSizeMessages))
+ {
+ // FIXME_messageList.SetColumnWidthAuto(0);
+ // FIXME_messageList.SetColumnWidthAuto(1);
+ _numAutoSizeMessages = _numPostedMessages;
+ }
+ }
+}
+
+
+bool CProgressDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
+{
+ switch(buttonID)
+ {
+ // case IDOK: // if IDCANCEL is not DEFPUSHBUTTON
+ case IDCANCEL:
+ {
+ if (_waitCloseByCancelButton)
+ {
+ MessagesDisplayed = true;
+ End(IDCLOSE);
+ break;
+ }
+
+ bool paused = Sync.GetPaused();
+ if (!paused)
+ OnPauseButton();
+ _inCancelMessageBox = true;
+ int res = ::MessageBoxW(HWND(*this),
+ LangStringSpec(IDS_PROGRESS_ASK_CANCEL, 0x02000C30),
+ _title, MB_YESNOCANCEL);
+ _inCancelMessageBox = false;
+ if (!paused)
+ OnPauseButton();
+ if (res == IDCANCEL || res == IDNO)
+ {
+ if (_externalCloseMessageWasReceived)
+ OnExternalCloseMessage();
+ return true;
+ }
+
+ _cancelWasPressed = true;
+ MessagesDisplayed = true;
+ break;
+ }
+
+ case IDC_BUTTON_PAUSE:
+ OnPauseButton();
+ return true;
+ case IDC_BUTTON_PROGRESS_PRIORITY:
+ OnPriorityButton();
+ return true;
+ }
+ return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
+}
+
+void CProgressDialog::CheckNeedClose()
+{
+ if (_needClose)
+ {
+ PostMessage(kCloseMessage);
+ _needClose = false;
+ }
+}
+
+void CProgressDialog::ProcessWasFinished()
+{
+ // Set Window title here.
+ // FIXME - not supported if (!WaitMode)
+ WaitCreating();
+
+ if (_wasCreated)
+ PostMessage(kCloseMessage);
+ else
+ _needClose = true;
+}
+
+
+HRESULT CProgressThreadVirt::Create(const UString &title, HWND parentWindow)
+{
+ NWindows::CThread thread;
+ RINOK(thread.Create(MyThreadFunction, this));
+ ProgressDialog.Create(title, thread, parentWindow);
+ return S_OK;
+}
+
+UString HResultToMessage(HRESULT errorCode)
+{
+ UString message;
+ if (errorCode == E_OUTOFMEMORY)
+ message = LangStringSpec(IDS_MEM_ERROR, 0x0200060B);
+ else if (!NError::MyFormatMessage(errorCode, message))
+ message.Empty();
+ if (message.IsEmpty())
+ message = L"Error";
+ return message;
+}
+
+static void AddMessageToString(UString &dest, const UString &src)
+{
+ if (!src.IsEmpty())
+ {
+ if (!dest.IsEmpty())
+ dest += L'\n';
+ dest += src;
+ }
+}
+
+void CProgressThreadVirt::Process()
+{
+ CProgressCloser closer(ProgressDialog);
+ UString m;
+ try { Result = ProcessVirt(); }
+ catch(const wchar_t *s) { m = s; }
+ catch(const UString &s) { m = s; }
+ catch(const char *s) { m = GetUnicodeString(s); }
+ catch(...) { m = L"Error"; }
+ if (Result != E_ABORT)
+ {
+ if (m.IsEmpty() && Result != S_OK)
+ m = HResultToMessage(Result);
+ }
+ AddMessageToString(m, ErrorMessage);
+ AddMessageToString(m, ErrorPath1);
+ AddMessageToString(m, ErrorPath2);
+
+ if (m.IsEmpty())
+ {
+ if (!OkMessage.IsEmpty())
+ {
+ ProgressDialog.Sync.SetOkMessageTitle(OkMessageTitle);
+ ProgressDialog.Sync.SetOkMessage(OkMessage);
+ }
+ }
+ else
+ {
+ ProgressDialog.Sync.SetErrorMessage(m);
+ if (Result == S_OK)
+ Result = E_FAIL;
+ }
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ProgressDialog2.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ProgressDialog2.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ProgressDialog2.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ProgressDialog2.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,359 @@
+// ProgressDialog2.h
+
+#ifndef __PROGRESS_DIALOG2_H
+#define __PROGRESS_DIALOG2_H
+
+#include "Windows/Synchronization.h"
+#include "Windows/Thread.h"
+
+#include "Windows/Control/Dialog.h"
+#include "Windows/Control/ListView.h"
+#include "Windows/Control/ProgressBar.h"
+
+class CProgressSync
+{
+ bool _stopped;
+ bool _paused;
+ bool _bytesProgressMode;
+
+ UInt64 _totalBytes;
+ UInt64 _curBytes;
+ UInt64 _totalFiles;
+ UInt64 _curFiles;
+ UInt64 _inSize;
+ UInt64 _outSize;
+
+ UString _titleFileName;
+ UString _currentFileName;
+
+public:
+ UStringVector Messages;
+ UString ErrorMessage;
+ UString ErrorMessageTitle;
+
+ UString OkMessage;
+ UString OkMessageTitle;
+
+ NWindows::NSynchronization::CCriticalSection _cs;
+
+ CProgressSync():
+ _stopped(false), _paused(false),
+ _totalBytes((UInt64)(Int64)-1), _curBytes(0),
+ _totalFiles((UInt64)(Int64)-1), _curFiles(0),
+ _inSize((UInt64)(Int64)-1),
+ _outSize((UInt64)(Int64)-1),
+ _bytesProgressMode(true)
+ {}
+
+ bool GetStopped()
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_cs);
+ return _stopped;
+ }
+ void SetStopped(bool value)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_cs);
+ _stopped = value;
+ }
+ bool GetPaused()
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_cs);
+ return _paused;
+ }
+ void SetPaused(bool value)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_cs);
+ _paused = value;
+ }
+ void SetBytesProgressMode(bool bytesProgressMode)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_cs);
+ _bytesProgressMode = bytesProgressMode;
+ }
+ void SetProgress(UInt64 total, UInt64 completed)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_cs);
+ _totalBytes = total;
+ _curBytes = completed;
+ }
+ void SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_cs);
+ if (inSize)
+ _inSize = *inSize;
+ if (outSize)
+ _outSize = *outSize;
+ }
+ void SetPos(UInt64 completed)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_cs);
+ _curBytes = completed;
+ }
+ void SetNumBytesTotal(UInt64 value)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_cs);
+ _totalBytes = value;
+ }
+ void SetNumFilesTotal(UInt64 value)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_cs);
+ _totalFiles = value;
+ }
+ void SetNumFilesCur(UInt64 value)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_cs);
+ _curFiles = value;
+ }
+ HRESULT ProcessStopAndPause();
+ HRESULT SetPosAndCheckPaused(UInt64 completed);
+ void GetProgress(UInt64 &total, UInt64 &completed,
+ UInt64 &totalFiles, UInt64 &curFiles,
+ UInt64 &inSize, UInt64 &outSize,
+ bool &bytesProgressMode)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_cs);
+ total = _totalBytes;
+ completed = _curBytes;
+ totalFiles = _totalFiles;
+ curFiles = _curFiles;
+ inSize = _inSize;
+ outSize = _outSize;
+ bytesProgressMode = _bytesProgressMode;
+ }
+ void SetTitleFileName(const UString &fileName)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_cs);
+ _titleFileName = fileName;
+ }
+ void GetTitleFileName(UString &fileName)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_cs);
+ fileName = _titleFileName;
+ }
+ void SetCurrentFileName(const UString &fileName)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_cs);
+ _currentFileName = fileName;
+ }
+ void GetCurrentFileName(UString &fileName)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_cs);
+ fileName = _currentFileName;
+ }
+
+ void AddErrorMessage(LPCWSTR message)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_cs);
+ Messages.Add(message);
+ }
+
+ void SetErrorMessage(const UString &message)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_cs);
+ ErrorMessage = message;
+ }
+
+ void SetOkMessage(const UString &message)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_cs);
+ OkMessage = message;
+ }
+
+ void SetOkMessageTitle(const UString &title)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_cs);
+ OkMessageTitle = title;
+ }
+
+ void SetErrorMessageTitle(const UString &title)
+ {
+ NWindows::NSynchronization::CCriticalSectionLock lock(_cs);
+ ErrorMessageTitle = title;
+ }
+
+ bool ThereIsMessage() const
+ {
+ return !Messages.IsEmpty() || !ErrorMessage.IsEmpty() || !OkMessage.IsEmpty();
+ }
+};
+
+class CU64ToI32Converter
+{
+ UInt64 _numShiftBits;
+public:
+ void Init(UInt64 range)
+ {
+ // Windows CE doesn't like big number here.
+ for (_numShiftBits = 0; range > (1 << 15); _numShiftBits++)
+ range >>= 1;
+ }
+ int Count(UInt64 value) { return int(value >> _numShiftBits); }
+};
+
+enum ESpeedMode
+{
+ kSpeedBytes,
+ kSpeedKBytes,
+ kSpeedMBytes
+};
+
+class CProgressDialog: public NWindows::NControl::CModalDialog
+{
+ UString _prevFileName;
+ UString _prevTitleName;
+private:
+ UString backgroundString;
+ UString backgroundedString;
+ UString foregroundString;
+ UString pauseString;
+ UString continueString;
+ UString pausedString;
+
+ int buttonSizeX;
+ int buttonSizeY;
+
+ UINT_PTR _timer;
+
+ UString _title;
+ CU64ToI32Converter _converter;
+ UInt64 _previousPos;
+ UInt64 _range;
+ NWindows::NControl::CProgressBar m_ProgressBar;
+ // FIXME NWindows::NControl::CListView _messageList;
+
+ UInt32 _prevPercentValue;
+ UInt32 _prevTime;
+ UInt32 _elapsedTime;
+ UInt32 _prevElapsedSec;
+ UInt64 _prevRemainingSec;
+ ESpeedMode _prevMode;
+ UInt64 _prevSpeed;
+
+ bool _foreground;
+
+ int _numReduceSymbols;
+
+ bool _wasCreated;
+ bool _needClose;
+
+ UInt32 _numPostedMessages;
+ UInt32 _numAutoSizeMessages;
+
+ bool _errorsWereDisplayed;
+
+ bool _waitCloseByCancelButton;
+ bool _cancelWasPressed;
+
+ bool _inCancelMessageBox;
+ bool _externalCloseMessageWasReceived;
+
+ void UpdateStatInfo(bool showAll);
+ bool OnTimer(WPARAM timerID, LPARAM callback);
+ void SetRange(UInt64 range);
+ void SetPos(UInt64 pos);
+ virtual bool OnInit();
+ virtual bool OnSize(WPARAM wParam, int xSize, int ySize);
+ virtual void OnCancel();
+ virtual void OnOK();
+ NWindows::NSynchronization::CManualResetEvent _createDialogEvent;
+ NWindows::NSynchronization::CManualResetEvent _dialogCreatedEvent;
+ #ifndef _SFX
+ void AddToTitle(LPCWSTR string);
+ #endif
+
+ void SetPauseText();
+ void SetPriorityText();
+ void OnPauseButton();
+ void OnPriorityButton();
+ bool OnButtonClicked(int buttonID, HWND buttonHWND);
+
+ void SetTitleText();
+ void ShowSize(int id, UInt64 value);
+
+ void UpdateMessagesDialog();
+
+ void AddMessageDirect(LPCWSTR message);
+ void AddMessage(LPCWSTR message);
+
+ bool OnExternalCloseMessage();
+ void EnableErrorsControls(bool enable);
+
+ void ShowAfterMessages(HWND wndParent);
+
+ void CheckNeedClose();
+public:
+ CProgressSync Sync;
+ bool CompressingMode;
+ // FIXME - not supported bool WaitMode;
+ bool ShowCompressionInfo;
+ bool MessagesDisplayed; // = true if user pressed OK on all messages or there are no messages.
+ int IconID;
+
+ #ifndef _SFX
+ HWND MainWindow;
+ UString MainTitle;
+ UString MainAddTitle;
+ ~CProgressDialog();
+ #endif
+
+ CProgressDialog();
+ void WaitCreating()
+ {
+ _createDialogEvent.Set();
+ _dialogCreatedEvent.Lock();
+ }
+
+
+ INT_PTR Create(const UString &title, NWindows::CThread &thread, HWND wndParent = 0);
+
+
+ virtual bool OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
+
+ void ProcessWasFinished();
+};
+
+
+class CProgressCloser
+{
+ CProgressDialog *_p;
+public:
+ CProgressCloser(CProgressDialog &p) : _p(&p) {}
+ ~CProgressCloser() { _p->ProcessWasFinished(); }
+};
+
+class CProgressThreadVirt
+{
+protected:
+ UString ErrorMessage;
+ UString ErrorPath1;
+ UString ErrorPath2;
+ UString OkMessage;
+ UString OkMessageTitle;
+
+ // error if any of HRESULT, ErrorMessage, ErrorPath
+ virtual HRESULT ProcessVirt() = 0;
+ void Process();
+public:
+ HRESULT Result;
+ bool ThreadFinishedOK; // if there is no fatal exception
+ CProgressDialog ProgressDialog;
+
+ static THREAD_FUNC_DECL MyThreadFunction(void *param)
+ {
+ CProgressThreadVirt *p = (CProgressThreadVirt *)param;
+ try
+ {
+ p->Process();
+ p->ThreadFinishedOK = true;
+ }
+ catch (...) { p->Result = E_FAIL; }
+ return 0;
+ }
+
+ HRESULT Create(const UString &title, HWND parentWindow = 0);
+ CProgressThreadVirt(): Result(E_FAIL), ThreadFinishedOK(false) {}
+};
+
+UString HResultToMessage(HRESULT errorCode);
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ProgressDialog2Res.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ProgressDialog2Res.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ProgressDialog2Res.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ProgressDialog2Res.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,41 @@
+#define IDD_DIALOG_PROGRESS 500
+#define IDD_DIALOG_PROGRESS_2 600
+
+#define IDC_BUTTON_PAUSE 50
+#define IDC_BUTTON_PROGRESS_PRIORITY 51
+
+#define IDS_PROGRESS_PAUSED 700
+#define IDS_PROGRESS_FOREGROUND 701
+#define IDS_PROGRESS_CONTINUE 702
+#define IDS_PROGRESS_ASK_CANCEL 703
+#define IDS_CLOSE 704
+#define IDS_MESSAGES_DIALOG_MESSAGE_COLUMN 503
+
+#define IDC_PROGRESS1 1000
+#define IDC_PROGRESS_ELAPSED 1002
+#define IDC_PROGRESS_ELAPSED_VALUE 1003
+#define IDC_PROGRESS_REMAINING 1004
+#define IDC_PROGRESS_REMAINING_VALUE 1005
+#define IDC_PROGRESS_SPEED 1006
+#define IDC_PROGRESS_SPEED_VALUE 1007
+#define IDC_PROGRESS_TOTAL 1008
+#define IDC_PROGRESS_TOTAL_VALUE 1009
+#define IDC_PROGRESS_FILE_NAME 1010
+
+#define IDC_PROGRESS_FILES 1012
+#define IDC_PROGRESS_FILES_VALUE 1013
+#define IDC_PROGRESS_RATIO 1014
+#define IDC_PROGRESS_RATIO_VALUE 1015
+#define IDC_PROGRESS_PACKED 1016
+#define IDC_PROGRESS_PACKED_VALUE 1017
+#define IDC_PROGRESS_UNPACKED 1018
+#define IDC_PROGRESS_UNPACKED_VALUE 1019
+
+#define IDC_PROGRESS_ERRORS 1030
+#define IDC_PROGRESS_ERRORS_VALUE 1031
+#define IDC_PROGRESS_LIST 1032
+
+#define MY_PROGRESS_VALUE_UNITS 44
+#define MY_PROGRESS_LABEL_UNITS_MIN 60
+#define MY_PROGRESS_LABEL_UNITS_START 90
+#define MY_PROGRESS_PAD_UNITS 4
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ProgressDialog2_rc.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ProgressDialog2_rc.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ProgressDialog2_rc.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ProgressDialog2_rc.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,180 @@
+// ProgressDialog2_rc.cpp
+
+#include "StdAfx.h"
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+// for all others, include the necessary headers (this file is usually all you
+// need because it includes almost all "standard" wxWidgets headers)
+#ifndef WX_PRECOMP
+ #include "wx/wx.h"
+#endif
+
+#undef _WIN32
+
+#include "ProgressDialog2Res.h"
+
+#include "Windows/Control/DialogImpl.h"
+
+/*
+IDD_DIALOG_PROGRESS DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE | WS_MINIMIZEBOX
+CAPTION "Progress"
+MY_FONT
+BEGIN
+ PUSHBUTTON "&Background", IDC_BUTTON_PROGRESS_PRIORITY, bXPos3, bYPos, bXSize, bYSize
+ PUSHBUTTON "&Pause", IDC_BUTTON_PAUSE, bXPos2, bYPos, bXSize, bYSize
+ PUSHBUTTON "Cancel", IDCANCEL, bXPos1, bYPos, bXSize, bYSize
+ LTEXT "Elapsed time:", IDC_PROGRESS_ELAPSED, marg, y0, x0Size, 8
+ LTEXT "Remaining time:", IDC_PROGRESS_REMAINING, marg, y1, x0Size, 8
+ LTEXT "Files:", IDC_PROGRESS_FILES, marg, y2, x0Size, 8
+ LTEXT "Compression ratio:",IDC_PROGRESS_RATIO, marg, y3, x0Size, 8
+
+ LTEXT "Total size:", IDC_PROGRESS_TOTAL, x2, y0, x2Size, 8
+ LTEXT "Speed:", IDC_PROGRESS_SPEED, x2, y1, x2Size, 8
+ LTEXT "Processed:", IDC_PROGRESS_UNPACKED, x2, y2, x2Size, 8
+ LTEXT "Compressed size:", IDC_PROGRESS_PACKED, x2, y3, x2Size, 8
+
+ RTEXT "00:00:00", IDC_PROGRESS_ELAPSED_VALUE, x1, y0, x1Size, 8
+ RTEXT "", IDC_PROGRESS_REMAINING_VALUE, x1, y1, x1Size, 8
+ RTEXT "", IDC_PROGRESS_FILES_VALUE, x1, y2, x1Size, 8
+ RTEXT "", IDC_PROGRESS_RATIO_VALUE, x1, y3, x1Size, 8
+
+ RTEXT "", IDC_PROGRESS_TOTAL_VALUE, x3, y0, x3Size, 8
+ RTEXT "", IDC_PROGRESS_SPEED_VALUE, x3, y1, x3Size, 8
+ RTEXT "", IDC_PROGRESS_UNPACKED_VALUE, x3, y2, x3Size, 8
+ RTEXT "", IDC_PROGRESS_PACKED_VALUE, x3, y3, x3Size, 8
+
+ LTEXT "", IDC_PROGRESS_FILE_NAME, marg, bYPos - 30, xSize2, 8, SS_NOPREFIX
+ CONTROL "Progress1", IDC_PROGRESS1, "msctls_progress32", PBS_SMOOTH | WS_BORDER, marg, bYPos - 20, xSize2, 13
+END
+
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ IDS_PROGRESS_PAUSED "Paused"
+ IDS_PROGRESS_FOREGROUND "&Foreground"
+ IDS_PROGRESS_CONTINUE "&Continue"
+ IDS_PROGRESS_ASK_CANCEL "Are you sure you want to cancel?"
+END
+
+*/
+class CProgressDialogImpl : public NWindows::NControl::CModalDialogImpl
+{
+ public:
+ CProgressDialogImpl(NWindows::NControl::CModalDialog *dialog,wxWindow * parent , int id) : CModalDialogImpl(dialog,parent, id, wxT("Progress"))
+ {
+// FIXME : ProgressDialog2 but ProgressDialog ...
+
+ ///Sizer for adding the controls created by users
+ wxBoxSizer* topsizer = new wxBoxSizer(wxVERTICAL);
+
+ wxStaticText *pStaticTextElapsedTime = new wxStaticText(this, IDC_PROGRESS_ELAPSED, wxT("Elapsed time:"));
+ wxStaticText *m_pStaticTextElapsedTime = new wxStaticText(this, IDC_PROGRESS_ELAPSED_VALUE, wxT("00:00:00"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
+ wxStaticText *pStaticTextRemainingTime = new wxStaticText(this, IDC_PROGRESS_REMAINING, wxT("Remaining time"));
+ wxStaticText *m_pStaticTextRemainingTime = new wxStaticText(this, IDC_PROGRESS_REMAINING_VALUE, wxT("00:00:00"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
+
+ wxStaticText *pStaticTextFiles = new wxStaticText(this, IDC_PROGRESS_FILES, wxT("Files:"));
+ wxStaticText *m_pStaticTextFiles = new wxStaticText(this, IDC_PROGRESS_FILES_VALUE, wxT(" "), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
+
+ wxStaticText *pStaticTextRatio = new wxStaticText(this, IDC_PROGRESS_RATIO, wxT("Compression ratio:"));
+ wxStaticText *m_pStaticTextRatio = new wxStaticText(this, IDC_PROGRESS_RATIO_VALUE, wxT(" "), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
+
+
+ wxStaticText *pStaticTextSize = new wxStaticText(this, IDC_PROGRESS_TOTAL, wxT("Total Size:"));
+ wxStaticText *m_pStaticTextSize = new wxStaticText(this, IDC_PROGRESS_TOTAL_VALUE, wxT(" "), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
+ wxStaticText *pStaticTextSpeed = new wxStaticText(this, IDC_PROGRESS_SPEED, wxT("Speed:"));
+ wxStaticText *m_pStaticTextSpeed = new wxStaticText(this, IDC_PROGRESS_SPEED_VALUE, wxT(" "), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
+
+ wxStaticText *pStaticTextUnpacked = new wxStaticText(this, IDC_PROGRESS_UNPACKED, wxT("Processed:"));
+ wxStaticText *m_pStaticTextUnpacked = new wxStaticText(this, IDC_PROGRESS_UNPACKED, wxT(" "), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
+
+ wxStaticText *pStaticTextPacked = new wxStaticText(this, IDC_PROGRESS_PACKED, wxT("Compressed size:"));
+ wxStaticText *m_pStaticTextPacked = new wxStaticText(this, IDC_PROGRESS_PACKED_VALUE, wxT(" "), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
+
+ wxBoxSizer *pInfoSizer = new wxBoxSizer(wxHORIZONTAL);
+ wxBoxSizer *pTimeSizer = new wxBoxSizer(wxHORIZONTAL);
+ wxBoxSizer *pTimeLabelSizer = new wxBoxSizer(wxVERTICAL);
+ pTimeLabelSizer->Add(pStaticTextElapsedTime , 0, wxALL|wxEXPAND, 5);
+ pTimeLabelSizer->Add(pStaticTextRemainingTime, 0, wxALL|wxEXPAND, 5);
+ pTimeLabelSizer->Add(pStaticTextFiles , 0, wxALL|wxEXPAND, 5);
+ pTimeLabelSizer->Add(pStaticTextRatio , 0, wxALL|wxEXPAND, 5);
+ wxBoxSizer *pTimeInfoSizer = new wxBoxSizer(wxVERTICAL);
+ pTimeInfoSizer->Add(m_pStaticTextElapsedTime , 0, wxALL|wxEXPAND, 5);
+ pTimeInfoSizer->Add(m_pStaticTextRemainingTime, 0, wxALL|wxEXPAND, 5);
+ pTimeInfoSizer->Add(m_pStaticTextFiles , 0, wxALL|wxEXPAND, 5);
+ pTimeInfoSizer->Add(m_pStaticTextRatio , 0, wxALL|wxEXPAND, 5);
+ pTimeSizer->Add(pTimeLabelSizer , 0, wxALL|wxEXPAND, 5);
+ pTimeSizer->Add(pTimeInfoSizer , 0, wxALL|wxEXPAND, 5);
+ wxBoxSizer *pSizeSpeedSizer = new wxBoxSizer(wxHORIZONTAL);
+ wxBoxSizer *pSizeSpeedLabelSizer = new wxBoxSizer(wxVERTICAL);
+ pSizeSpeedLabelSizer->Add(pStaticTextSize , 0, wxALL|wxEXPAND, 5);
+ pSizeSpeedLabelSizer->Add(pStaticTextSpeed , 0, wxALL|wxEXPAND, 5);
+ pSizeSpeedLabelSizer->Add(pStaticTextUnpacked , 0, wxALL|wxEXPAND, 5);
+ pSizeSpeedLabelSizer->Add(pStaticTextPacked , 0, wxALL|wxEXPAND, 5);
+
+ wxBoxSizer *pSizeSpeedInfoSizer = new wxBoxSizer(wxVERTICAL);
+ pSizeSpeedInfoSizer->Add(m_pStaticTextSize , 0, wxALL|wxEXPAND, 5);
+ pSizeSpeedInfoSizer->Add(m_pStaticTextSpeed , 0, wxALL|wxEXPAND, 5);
+ pSizeSpeedInfoSizer->Add(m_pStaticTextUnpacked, 0, wxALL|wxEXPAND, 5);
+ pSizeSpeedInfoSizer->Add(m_pStaticTextPacked , 0, wxALL|wxEXPAND, 5);
+
+ pSizeSpeedSizer->Add(pSizeSpeedLabelSizer, 1, wxALL|wxEXPAND, 5);
+ pSizeSpeedSizer->Add(pSizeSpeedInfoSizer, 1, wxALL|wxEXPAND, 5);
+ pInfoSizer->Add(pTimeSizer, 0, wxALL|wxEXPAND, 5);
+ pInfoSizer->Add(pSizeSpeedSizer, 0, wxALL|wxEXPAND, 5);
+
+ // wxStaticText *m_pStaticArchiveName = new wxStaticText(this, IDC_PROGRESS_FILE_NAME, wxT(" \n "));
+ wxStaticText *m_pStaticArchiveName = new wxStaticText(this, IDC_PROGRESS_FILE_NAME, wxT(""));
+ // m_pStaticArchiveName->Wrap( -1 ); // No Wrapping
+
+ wxGauge *m_pGaugeProgress = new wxGauge(this, IDC_PROGRESS1, 100);
+
+ wxBoxSizer *pButtonSizer = new wxBoxSizer(wxHORIZONTAL);
+ wxButton *m_pButtonBackground = new wxButton(this, IDC_BUTTON_PROGRESS_PRIORITY, wxT("&Background"));
+ wxButton *m_pButtonPause = new wxButton(this, IDC_BUTTON_PAUSE, wxT("&Pause"));
+ wxButton *m_pButtonCancel = new wxButton(this, wxID_CANCEL, wxT("&Cancel"));
+ // FIXME pButtonSizer->AddStretchSpacer(1);
+ pButtonSizer->Add(m_pButtonBackground, 0, wxALL|wxEXPAND, 5);
+ pButtonSizer->Add(m_pButtonPause, 0, wxALL|wxEXPAND, 5);
+ pButtonSizer->Add(m_pButtonCancel, 0, wxALL|wxEXPAND, 5);
+
+ topsizer->Add(pInfoSizer, 0, wxBOTTOM|wxEXPAND, 5);
+ topsizer->Add(m_pStaticArchiveName, 0, wxEXPAND | wxALL | wxALIGN_LEFT, 10);
+ topsizer->Add(m_pGaugeProgress, 0, wxALL|wxEXPAND, 10);
+ topsizer->Add(pButtonSizer, 0, wxALL|wxEXPAND, 5);
+
+ this->OnInit();
+
+ SetSizer(topsizer); // use the sizer for layout
+ topsizer->SetSizeHints(this); // set size hints to honour minimum size
+ }
+
+private:
+ // Any class wishing to process wxWindows events must use this macro
+ DECLARE_EVENT_TABLE()
+};
+
+static CStringTable g_stringTable[] =
+{
+ { IDS_PROGRESS_PAUSED , L"Paused" },
+ { IDS_PROGRESS_FOREGROUND , L"&Foreground" },
+ { IDS_PROGRESS_CONTINUE , L"&Continue" },
+ { IDS_PROGRESS_ASK_CANCEL , L"Are you sure you want to cancel?" },
+ { IDS_CLOSE , L"&Close" },
+ { IDS_MESSAGES_DIALOG_MESSAGE_COLUMN , L"Message"},
+ { 0 , 0 }
+};
+
+REGISTER_DIALOG(IDD_DIALOG_PROGRESS,CProgressDialog,g_stringTable)
+
+BEGIN_EVENT_TABLE(CProgressDialogImpl, wxDialog)
+ EVT_TIMER(wxID_ANY, CModalDialogImpl::OnAnyTimer)
+ EVT_BUTTON(wxID_ANY, CModalDialogImpl::OnAnyButton)
+ EVT_MENU(WORKER_EVENT, CModalDialogImpl::OnWorkerEvent)
+END_EVENT_TABLE()
+
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ProgressDialogRes.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ProgressDialogRes.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ProgressDialogRes.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ProgressDialogRes.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,3 @@
+#define IDD_DIALOG_PROGRESS 500
+
+#define IDC_PROGRESS1 1000
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PropertyName.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PropertyName.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PropertyName.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PropertyName.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,110 @@
+// PropertyName.cpp
+
+#include "StdAfx.h"
+
+#include "Common/IntToString.h"
+
+#include "Windows/ResourceString.h"
+
+#include "../../PropID.h"
+
+#include "LangUtils.h"
+#include "PropertyName.h"
+
+#include "resource.h"
+#include "PropertyNameRes.h"
+
+struct CPropertyIDNamePair
+{
+ PROPID PropID;
+ UINT ResourceID;
+ UInt32 LangID;
+};
+
+static CPropertyIDNamePair kPropertyIDNamePairs[] =
+{
+ { kpidPath, IDS_PROP_PATH, 0x02000203 },
+ { kpidName, IDS_PROP_NAME, 0x02000204 },
+ { kpidExtension, IDS_PROP_EXTENSION, 0x02000205 },
+ { kpidIsDir, IDS_PROP_IS_FOLDER, 0x02000206},
+ { kpidSize, IDS_PROP_SIZE, 0x02000207},
+ { kpidPackSize, IDS_PROP_PACKED_SIZE, 0x02000208 },
+ { kpidAttrib, IDS_PROP_ATTRIBUTES, 0x02000209 },
+ { kpidCTime, IDS_PROP_CTIME, 0x0200020A },
+ { kpidATime, IDS_PROP_ATIME, 0x0200020B },
+ { kpidMTime, IDS_PROP_MTIME, 0x0200020C },
+ { kpidSolid, IDS_PROP_SOLID, 0x0200020D },
+ { kpidCommented, IDS_PROP_C0MMENTED, 0x0200020E },
+ { kpidEncrypted, IDS_PROP_ENCRYPTED, 0x0200020F },
+ { kpidSplitBefore, IDS_PROP_SPLIT_BEFORE, 0x02000210 },
+ { kpidSplitAfter, IDS_PROP_SPLIT_AFTER, 0x02000211 },
+ { kpidDictionarySize, IDS_PROP_DICTIONARY_SIZE, 0x02000212 },
+ { kpidCRC, IDS_PROP_CRC, 0x02000213 },
+ { kpidType, IDS_PROP_FILE_TYPE, 0x02000214},
+ { kpidIsAnti, IDS_PROP_ANTI, 0x02000215 },
+ { kpidMethod, IDS_PROP_METHOD, 0x02000216 },
+ { kpidHostOS, IDS_PROP_HOST_OS, 0x02000217 },
+ { kpidFileSystem, IDS_PROP_FILE_SYSTEM, 0x02000218},
+ { kpidUser, IDS_PROP_USER, 0x02000219},
+ { kpidGroup, IDS_PROP_GROUP, 0x0200021A},
+ { kpidBlock, IDS_PROP_BLOCK, 0x0200021B },
+ { kpidComment, IDS_PROP_COMMENT, 0x0200021C },
+ { kpidPosition, IDS_PROP_POSITION, 0x0200021D },
+ { kpidPrefix, IDS_PROP_PREFIX, 0x0200021E },
+ { kpidNumSubDirs, IDS_PROP_FOLDERS, 0x0200021F },
+ { kpidNumSubFiles, IDS_PROP_FILES, 0x02000220 },
+ { kpidUnpackVer, IDS_PROP_VERSION, 0x02000221},
+ { kpidVolume, IDS_PROP_VOLUME, 0x02000222},
+ { kpidIsVolume, IDS_PROP_IS_VOLUME, 0x02000223},
+ { kpidOffset, IDS_PROP_OFFSET, 0x02000224},
+ { kpidLinks, IDS_PROP_LINKS, 0x02000225},
+ { kpidNumBlocks, IDS_PROP_NUM_BLOCKS, 0x02000226},
+ { kpidNumVolumes, IDS_PROP_NUM_VOLUMES, 0x02000227},
+
+ { kpidBit64, IDS_PROP_BIT64, 0x02000229},
+ { kpidBigEndian, IDS_PROP_BIG_ENDIAN, 0x0200022A},
+ { kpidCpu, IDS_PROP_CPU, 0x0200022B},
+ { kpidPhySize, IDS_PROP_PHY_SIZE, 0x0200022C},
+ { kpidHeadersSize, IDS_PROP_HEADERS_SIZE, 0x0200022D},
+ { kpidChecksum, IDS_PROP_CHECKSUM, 0x0200022E},
+ { kpidCharacts, IDS_PROP_CHARACTS, 0x0200022F},
+ { kpidVa, IDS_PROP_VA, 0x02000230},
+ { kpidId, IDS_PROP_ID, 0x02000231 },
+ { kpidShortName, IDS_PROP_SHORT_NAME, 0x02000232 },
+ { kpidCreatorApp, IDS_PROP_CREATOR_APP, 0x02000233 },
+ { kpidSectorSize, IDS_PROP_SECTOR_SIZE, 0x02000234 },
+ { kpidPosixAttrib, IDS_PROP_POSIX_ATTRIB, 0x02000235 },
+ { kpidLink, IDS_PROP_LINK, 0x02000236 },
+ { kpidError, IDS_PROP_ERROR, 0x02000605 },
+
+ { kpidTotalSize, IDS_PROP_TOTAL_SIZE, 0x03031100 },
+ { kpidFreeSpace, IDS_PROP_FREE_SPACE, 0x03031101 },
+ { kpidClusterSize, IDS_PROP_CLUSTER_SIZE, 0x03031102},
+ { kpidVolumeName, IDS_PROP_VOLUME_NAME, 0x03031103 },
+
+ { kpidLocalName, IDS_PROP_LOCAL_NAME, 0x03031200 },
+ { kpidProvider, IDS_PROP_PROVIDER, 0x03031201 }
+};
+
+int FindProperty(PROPID propID)
+{
+ for (int i = 0; i < sizeof(kPropertyIDNamePairs) / sizeof(kPropertyIDNamePairs[0]); i++)
+ if (kPropertyIDNamePairs[i].PropID == propID)
+ return i;
+ return -1;
+}
+
+UString GetNameOfProperty(PROPID propID, const wchar_t *name)
+{
+ int index = FindProperty(propID);
+ if (index < 0)
+ {
+ if (name)
+ return name;
+ wchar_t s[16];
+ ConvertUInt32ToString(propID, s);
+ return s;
+ }
+ const CPropertyIDNamePair &pair = kPropertyIDNamePairs[index];
+ return LangString(pair.ResourceID, pair.LangID);
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PropertyName.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PropertyName.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PropertyName.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PropertyName.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,10 @@
+// PropertyName.h
+
+#ifndef __PROPERTYNAME_H
+#define __PROPERTYNAME_H
+
+#include "Common/MyString.h"
+
+UString GetNameOfProperty(PROPID propID, const wchar_t *name);
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PropertyNameRes.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PropertyNameRes.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PropertyNameRes.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/PropertyNameRes.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,53 @@
+#define IDS_PROP_PATH 3
+#define IDS_PROP_NAME 4
+#define IDS_PROP_EXTENSION 5
+#define IDS_PROP_IS_FOLDER 6
+#define IDS_PROP_SIZE 7
+#define IDS_PROP_PACKED_SIZE 8
+#define IDS_PROP_ATTRIBUTES 9
+#define IDS_PROP_CTIME 10
+#define IDS_PROP_ATIME 11
+#define IDS_PROP_MTIME 12
+#define IDS_PROP_SOLID 13
+#define IDS_PROP_C0MMENTED 14
+#define IDS_PROP_ENCRYPTED 15
+#define IDS_PROP_DICTIONARY_SIZE 16
+#define IDS_PROP_SPLIT_BEFORE 17
+#define IDS_PROP_SPLIT_AFTER 18
+#define IDS_PROP_CRC 19
+#define IDS_PROP_FILE_TYPE 20
+#define IDS_PROP_ANTI 21
+#define IDS_PROP_METHOD 22
+#define IDS_PROP_HOST_OS 23
+#define IDS_PROP_FILE_SYSTEM 24
+#define IDS_PROP_USER 25
+#define IDS_PROP_GROUP 26
+#define IDS_PROP_BLOCK 27
+#define IDS_PROP_COMMENT 28
+#define IDS_PROP_POSITION 29
+#define IDS_PROP_PREFIX 30
+#define IDS_PROP_FOLDERS 31
+#define IDS_PROP_FILES 32
+#define IDS_PROP_VERSION 33
+#define IDS_PROP_VOLUME 34
+#define IDS_PROP_IS_VOLUME 35
+#define IDS_PROP_OFFSET 36
+#define IDS_PROP_LINKS 37
+#define IDS_PROP_NUM_BLOCKS 38
+#define IDS_PROP_NUM_VOLUMES 39
+
+#define IDS_PROP_BIT64 41
+#define IDS_PROP_BIG_ENDIAN 42
+#define IDS_PROP_CPU 43
+#define IDS_PROP_PHY_SIZE 44
+#define IDS_PROP_HEADERS_SIZE 45
+#define IDS_PROP_CHECKSUM 46
+#define IDS_PROP_CHARACTS 47
+#define IDS_PROP_VA 48
+#define IDS_PROP_ID 49
+#define IDS_PROP_SHORT_NAME 50
+#define IDS_PROP_CREATOR_APP 51
+#define IDS_PROP_SECTOR_SIZE 52
+#define IDS_PROP_POSIX_ATTRIB 53
+#define IDS_PROP_LINK 54
+#define IDS_PROP_ERROR 55
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/RegistryAssociations.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/RegistryAssociations.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/RegistryAssociations.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/RegistryAssociations.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,312 @@
+// RegistryAssociations.cpp
+
+#include "StdAfx.h"
+
+#include "RegistryAssociations.h"
+
+#include "Common/IntToString.h"
+#include "Common/StringConvert.h"
+#include "Common/StringToInt.h"
+
+#include "Windows/Registry.h"
+#include "Windows/Synchronization.h"
+
+#include "StringUtils.h"
+
+using namespace NWindows;
+using namespace NRegistry;
+
+namespace NRegistryAssociations {
+
+static NSynchronization::CCriticalSection g_CriticalSection;
+
+#define REG_PATH_FM TEXT("Software") TEXT(STRING_PATH_SEPARATOR) TEXT("7-Zip") TEXT(STRING_PATH_SEPARATOR) TEXT("FM")
+
+/*
+
+static const TCHAR *kCUKeyPath = REG_PATH_FM;
+static const WCHAR *kExtPlugins = L"Plugins";
+static const TCHAR *kExtEnabled = TEXT("Enabled");
+
+#define kAssociations TEXT("Associations")
+#define kAssociationsPath REG_PATH_FM TEXT(STRING_PATH_SEPARATOR) kAssociations
+
+bool ReadInternalAssociation(const wchar_t *ext, CExtInfo &extInfo)
+{
+ NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
+ CKey key;
+ if (key.Open(HKEY_CURRENT_USER,
+ CSysString(kAssociationsPath TEXT(STRING_PATH_SEPARATOR)) +
+ GetSystemString(ext), KEY_READ) != ERROR_SUCCESS)
+ return false;
+ UString pluginsString;
+ key.QueryValue(kExtPlugins, pluginsString);
+ SplitString(pluginsString, extInfo.Plugins);
+ return true;
+}
+
+void ReadInternalAssociations(CObjectVector<CExtInfo> &items)
+{
+ items.Clear();
+ NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
+ CKey associationsKey;
+ if (associationsKey.Open(HKEY_CURRENT_USER, kAssociationsPath, KEY_READ) != ERROR_SUCCESS)
+ return;
+ CSysStringVector extNames;
+ associationsKey.EnumKeys(extNames);
+ for(int i = 0; i < extNames.Size(); i++)
+ {
+ const CSysString extName = extNames[i];
+ CExtInfo extInfo;
+ // extInfo.Enabled = false;
+ extInfo.Ext = GetUnicodeString(extName);
+ CKey key;
+ if (key.Open(associationsKey, extName, KEY_READ) != ERROR_SUCCESS)
+ return;
+ UString pluginsString;
+ key.QueryValue(kExtPlugins, pluginsString);
+ SplitString(pluginsString, extInfo.Plugins);
+ // if (key.QueryValue(kExtEnabled, extInfo.Enabled) != ERROR_SUCCESS)
+ // extInfo.Enabled = false;
+ items.Add(extInfo);
+ }
+}
+
+void WriteInternalAssociations(const CObjectVector<CExtInfo> &items)
+{
+ NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
+ CKey mainKey;
+ mainKey.Create(HKEY_CURRENT_USER, kCUKeyPath);
+ mainKey.RecurseDeleteKey(kAssociations);
+ CKey associationsKey;
+ associationsKey.Create(mainKey, kAssociations);
+ for(int i = 0; i < items.Size(); i++)
+ {
+ const CExtInfo &extInfo = items[i];
+ CKey key;
+ key.Create(associationsKey, GetSystemString(extInfo.Ext));
+ key.SetValue(kExtPlugins, JoinStrings(extInfo.Plugins));
+ // key.SetValue(kExtEnabled, extInfo.Enabled);
+ }
+}
+*/
+
+///////////////////////////////////
+// External
+
+static const TCHAR *kShellNewKeyName = TEXT("ShellNew");
+static const TCHAR *kShellNewDataValueName = TEXT("Data");
+
+static const TCHAR *kDefaultIconKeyName = TEXT("DefaultIcon");
+static const TCHAR *kShellKeyName = TEXT("shell");
+static const TCHAR *kOpenKeyName = TEXT("open");
+static const TCHAR *kCommandKeyName = TEXT("command");
+static const TCHAR *k7zipPrefix = TEXT("7-Zip.");
+
+static CSysString GetExtensionKeyName(const CSysString &extension)
+{
+ return CSysString(TEXT(".")) + extension;
+}
+
+static CSysString GetExtProgramKeyName(const CSysString &extension)
+{
+ return CSysString(k7zipPrefix) + extension;
+}
+
+static bool CheckShellExtensionInfo2(const CSysString &extension,
+ CSysString programKeyName, UString &iconPath, int &iconIndex)
+{
+ iconIndex = -1;
+ iconPath.Empty();
+ NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
+ CKey extKey;
+ if (extKey.Open(HKEY_CLASSES_ROOT, GetExtensionKeyName(extension), KEY_READ) != ERROR_SUCCESS)
+ return false;
+ if (extKey.QueryValue(NULL, programKeyName) != ERROR_SUCCESS)
+ return false;
+ UString s = GetUnicodeString(k7zipPrefix);
+ if (s.CompareNoCase(GetUnicodeString(programKeyName.Left(s.Length()))) != 0)
+ return false;
+ CKey iconKey;
+ if (extKey.Open(HKEY_CLASSES_ROOT, programKeyName + CSysString(TEXT(CHAR_PATH_SEPARATOR)) + kDefaultIconKeyName, KEY_READ) != ERROR_SUCCESS)
+ return false;
+ UString value;
+ if (extKey.QueryValue(NULL, value) == ERROR_SUCCESS)
+ {
+ int pos = value.ReverseFind(L',');
+ iconPath = value;
+ if (pos >= 0)
+ {
+ const wchar_t *end;
+ UInt64 index = ConvertStringToUInt64((const wchar_t *)value + pos + 1, &end);
+ if (*end == 0)
+ {
+ iconIndex = (int)index;
+ iconPath = value.Left(pos);
+ }
+ }
+ }
+ return true;
+}
+
+bool CheckShellExtensionInfo(const CSysString &extension, UString &iconPath, int &iconIndex)
+{
+ NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
+ CSysString programKeyName;
+ if (!CheckShellExtensionInfo2(extension, programKeyName, iconPath, iconIndex))
+ return false;
+ CKey extProgKey;
+ return (extProgKey.Open(HKEY_CLASSES_ROOT, programKeyName, KEY_READ) == ERROR_SUCCESS);
+}
+
+static void DeleteShellExtensionKey(const CSysString &extension)
+{
+ NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
+ CKey rootKey;
+ rootKey.Attach(HKEY_CLASSES_ROOT);
+ rootKey.RecurseDeleteKey(GetExtensionKeyName(extension));
+ rootKey.Detach();
+}
+
+static void DeleteShellExtensionProgramKey(const CSysString &extension)
+{
+ NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
+ CKey rootKey;
+ rootKey.Attach(HKEY_CLASSES_ROOT);
+ rootKey.RecurseDeleteKey(GetExtProgramKeyName(extension));
+ rootKey.Detach();
+}
+
+void DeleteShellExtensionInfo(const CSysString &extension)
+{
+ CSysString programKeyName;
+ UString iconPath;
+ int iconIndex;
+ if (CheckShellExtensionInfo2(extension, programKeyName, iconPath, iconIndex))
+ DeleteShellExtensionKey(extension);
+ DeleteShellExtensionProgramKey(extension);
+}
+
+void AddShellExtensionInfo(const CSysString &extension,
+ const UString &programTitle,
+ const UString &programOpenCommand,
+ const UString &iconPath, int iconIndex,
+ const void *shellNewData, int shellNewDataSize)
+{
+ DeleteShellExtensionKey(extension);
+ DeleteShellExtensionProgramKey(extension);
+ NSynchronization::CCriticalSectionLock lock(g_CriticalSection);
+ CSysString programKeyName;
+ {
+ CSysString ext = extension;
+ if (iconIndex < 0)
+ ext = TEXT("*");
+ programKeyName = GetExtProgramKeyName(ext);
+ }
+ {
+ CKey extKey;
+ extKey.Create(HKEY_CLASSES_ROOT, GetExtensionKeyName(extension));
+ extKey.SetValue(NULL, programKeyName);
+ if (shellNewData != NULL)
+ {
+ CKey shellNewKey;
+ shellNewKey.Create(extKey, kShellNewKeyName);
+ shellNewKey.SetValue(kShellNewDataValueName, shellNewData, shellNewDataSize);
+ }
+ }
+ CKey programKey;
+ programKey.Create(HKEY_CLASSES_ROOT, programKeyName);
+ programKey.SetValue(NULL, programTitle);
+ {
+ CKey iconKey;
+ iconKey.Create(programKey, kDefaultIconKeyName);
+ UString iconPathFull = iconPath;
+ if (iconIndex < 0)
+ iconIndex = 0;
+ // if (iconIndex >= 0)
+ {
+ iconPathFull += L",";
+ wchar_t s[16];
+ ConvertUInt32ToString(iconIndex, s);
+ iconPathFull += s;
+ }
+ iconKey.SetValue(NULL, iconPathFull);
+ }
+
+ CKey shellKey;
+ shellKey.Create(programKey, kShellKeyName);
+ shellKey.SetValue(NULL, TEXT(""));
+
+ CKey openKey;
+ openKey.Create(shellKey, kOpenKeyName);
+ openKey.SetValue(NULL, TEXT(""));
+
+ CKey commandKey;
+ commandKey.Create(openKey, kCommandKeyName);
+
+ commandKey.SetValue(NULL, programOpenCommand);
+}
+
+///////////////////////////
+// ContextMenu
+/*
+
+static const TCHAR *kContextMenuKeyName = TEXT("\\shellex\\ContextMenuHandlers\\7-Zip");
+static const TCHAR *kContextMenuHandlerCLASSIDValue =
+ TEXT("{23170F69-40C1-278A-1000-000100020000}");
+static const TCHAR *kRootKeyNameForFile = TEXT("*");
+static const TCHAR *kRootKeyNameForFolder = TEXT("Folder");
+
+static CSysString GetFullContextMenuKeyName(const CSysString &aKeyName)
+ { return (aKeyName + kContextMenuKeyName); }
+
+static bool CheckContextMenuHandlerCommon(const CSysString &aKeyName)
+{
+ NSynchronization::CCriticalSectionLock lock(&g_CriticalSection, true);
+ CKey aKey;
+ if (aKey.Open(HKEY_CLASSES_ROOT, GetFullContextMenuKeyName(aKeyName), KEY_READ)
+ != ERROR_SUCCESS)
+ return false;
+ CSysString aValue;
+ if (aKey.QueryValue(NULL, aValue) != ERROR_SUCCESS)
+ return false;
+ return (aValue.CompareNoCase(kContextMenuHandlerCLASSIDValue) == 0);
+}
+
+bool CheckContextMenuHandler()
+{
+ return CheckContextMenuHandlerCommon(kRootKeyNameForFile) &&
+ CheckContextMenuHandlerCommon(kRootKeyNameForFolder);
+}
+
+static void DeleteContextMenuHandlerCommon(const CSysString &aKeyName)
+{
+ CKey rootKey;
+ rootKey.Attach(HKEY_CLASSES_ROOT);
+ rootKey.RecurseDeleteKey(GetFullContextMenuKeyName(aKeyName));
+ rootKey.Detach();
+}
+
+void DeleteContextMenuHandler()
+{
+ DeleteContextMenuHandlerCommon(kRootKeyNameForFile);
+ DeleteContextMenuHandlerCommon(kRootKeyNameForFolder);
+}
+
+static void AddContextMenuHandlerCommon(const CSysString &aKeyName)
+{
+ DeleteContextMenuHandlerCommon(aKeyName);
+ NSynchronization::CCriticalSectionLock lock(&g_CriticalSection, true);
+ CKey aKey;
+ aKey.Create(HKEY_CLASSES_ROOT, GetFullContextMenuKeyName(aKeyName));
+ aKey.SetValue(NULL, kContextMenuHandlerCLASSIDValue);
+}
+
+void AddContextMenuHandler()
+{
+ AddContextMenuHandlerCommon(kRootKeyNameForFile);
+ AddContextMenuHandlerCommon(kRootKeyNameForFolder);
+}
+*/
+
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/RegistryAssociations.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/RegistryAssociations.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/RegistryAssociations.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/RegistryAssociations.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,46 @@
+// RegistryAssociations.h
+
+#ifndef __REGISTRYASSOCIATIONS_H
+#define __REGISTRYASSOCIATIONS_H
+
+#include "Common/MyString.h"
+
+namespace NRegistryAssociations {
+
+ /*
+ struct CExtInfo
+ {
+ UString Ext;
+ UStringVector Plugins;
+ // bool Enabled;
+ };
+ bool ReadInternalAssociation(const wchar_t *ext, CExtInfo &extInfo);
+ void ReadInternalAssociations(CObjectVector<CExtInfo> &items);
+ void WriteInternalAssociations(const CObjectVector<CExtInfo> &items);
+ */
+
+ bool CheckShellExtensionInfo(const CSysString &extension, UString &iconPath, int &iconIndex);
+
+ // void ReadCompressionInfo(NZipSettings::NCompression::CInfo &anInfo,
+ void DeleteShellExtensionInfo(const CSysString &extension);
+
+ void AddShellExtensionInfo(const CSysString &extension,
+ const UString &programTitle,
+ const UString &programOpenCommand,
+ const UString &iconPath, int iconIndex,
+ const void *shellNewData, int shellNewDataSize);
+
+
+ ///////////////////////////
+ // ContextMenu
+ /*
+ bool CheckContextMenuHandler();
+ void AddContextMenuHandler();
+ void DeleteContextMenuHandler();
+ */
+
+}
+
+// bool GetProgramDirPrefix(CSysString &aFolder);
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/RegistryPlugins.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/RegistryPlugins.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/RegistryPlugins.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/RegistryPlugins.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,32 @@
+// RegistryPlugins.h
+
+#ifndef __REGISTRYPLUGINS_H
+#define __REGISTRYPLUGINS_H
+
+#include "Common/MyString.h"
+
+enum EPluginType
+{
+ kPluginTypeFF = 0
+};
+
+struct CPluginInfo
+{
+ UString FilePath;
+ EPluginType Type;
+ UString Name;
+ CLSID ClassID;
+ CLSID OptionsClassID;
+ bool ClassIDDefined;
+ bool OptionsClassIDDefined;
+
+ // CSysString Extension;
+ // CSysString AddExtension;
+ // bool UpdateEnabled;
+ // bool KeepName;
+};
+
+void ReadPluginInfoList(CObjectVector<CPluginInfo> &plugins);
+void ReadFileFolderPluginInfoList(CObjectVector<CPluginInfo> &plugins);
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/RegistryUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/RegistryUtils.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/RegistryUtils.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/RegistryUtils.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,160 @@
+// RegistryUtils.cpp
+
+#include "StdAfx.h"
+
+#include "Common/IntToString.h"
+
+#include "Windows/Registry.h"
+
+#include "RegistryUtils.h"
+
+using namespace NWindows;
+using namespace NRegistry;
+
+#define REG_PATH_7Z TEXT("Software") TEXT(STRING_PATH_SEPARATOR) TEXT("7-Zip")
+
+static const TCHAR *kCUBasePath = REG_PATH_7Z;
+static const TCHAR *kCU_FMPath = REG_PATH_7Z TEXT(STRING_PATH_SEPARATOR) TEXT("FM");
+// static const TCHAR *kLM_Path = REG_PATH_7Z TEXT(STRING_PATH_SEPARATOR) TEXT("FM");
+
+static const WCHAR *kLangValueName = L"Lang";
+static const WCHAR *kEditor = L"Editor";
+static const WCHAR *kDiff = L"Diff";
+static const TCHAR *kShowDots = TEXT("ShowDots");
+static const TCHAR *kShowRealFileIcons = TEXT("ShowRealFileIcons");
+static const TCHAR *kShowSystemMenu = TEXT("ShowSystemMenu");
+
+static const TCHAR *kFullRow = TEXT("FullRow");
+static const TCHAR *kShowGrid = TEXT("ShowGrid");
+static const TCHAR *kAlternativeSelection = TEXT("AlternativeSelection");
+// static const TCHAR *kLockMemoryAdd = TEXT("LockMemoryAdd");
+static const TCHAR *kLargePagesEnable = TEXT("LargePages");
+static const TCHAR *kSingleClick = TEXT("SingleClick");
+// static const TCHAR *kUnderline = TEXT("Underline");
+
+static const TCHAR *kFlatViewName = TEXT("FlatViewArc");
+
+static void SaveCuString(LPCTSTR keyPath, LPCWSTR valuePath, LPCWSTR value)
+{
+ CKey key;
+ key.Create(HKEY_CURRENT_USER, keyPath);
+ key.SetValue(valuePath, value);
+}
+
+static void ReadCuString(LPCTSTR keyPath, LPCWSTR valuePath, UString &res)
+{
+ res.Empty();
+ CKey key;
+ if (key.Open(HKEY_CURRENT_USER, keyPath, KEY_READ) == ERROR_SUCCESS)
+ key.QueryValue(valuePath, res);
+}
+
+void SaveRegLang(const UString &path) { SaveCuString(kCUBasePath, kLangValueName, path); }
+void ReadRegLang(UString &path) { ReadCuString(kCUBasePath, kLangValueName, path); }
+
+void SaveRegEditor(const UString &path) { SaveCuString(kCU_FMPath, kEditor, path); }
+void ReadRegEditor(UString &path) { ReadCuString(kCU_FMPath, kEditor, path); }
+
+void SaveRegDiff(const UString &path) { SaveCuString(kCU_FMPath, kDiff, path); }
+void ReadRegDiff(UString &path) { ReadCuString(kCU_FMPath, kDiff, path); }
+
+static void Save7ZipOption(const TCHAR *value, bool enabled)
+{
+ CKey key;
+ key.Create(HKEY_CURRENT_USER, kCUBasePath);
+ key.SetValue(value, enabled);
+}
+
+static void SaveOption(const TCHAR *value, bool enabled)
+{
+ CKey key;
+ key.Create(HKEY_CURRENT_USER, kCU_FMPath);
+ key.SetValue(value, enabled);
+}
+
+static bool Read7ZipOption(const TCHAR *value, bool defaultValue)
+{
+ CKey key;
+ if (key.Open(HKEY_CURRENT_USER, kCUBasePath, KEY_READ) == ERROR_SUCCESS)
+ {
+ bool enabled;
+ if (key.QueryValue(value, enabled) == ERROR_SUCCESS)
+ return enabled;
+ }
+ return defaultValue;
+}
+
+static bool ReadOption(const TCHAR *value, bool defaultValue)
+{
+ CKey key;
+ if (key.Open(HKEY_CURRENT_USER, kCU_FMPath, KEY_READ) == ERROR_SUCCESS)
+ {
+ bool enabled;
+ if (key.QueryValue(value, enabled) == ERROR_SUCCESS)
+ return enabled;
+ }
+ return defaultValue;
+}
+
+/*
+static void SaveLmOption(const TCHAR *value, bool enabled)
+{
+ CKey key;
+ key.Create(HKEY_LOCAL_MACHINE, kLM_Path);
+ key.SetValue(value, enabled);
+}
+
+static bool ReadLmOption(const TCHAR *value, bool defaultValue)
+{
+ CKey key;
+ if (key.Open(HKEY_LOCAL_MACHINE, kLM_Path, KEY_READ) == ERROR_SUCCESS)
+ {
+ bool enabled;
+ if (key.QueryValue(value, enabled) == ERROR_SUCCESS)
+ return enabled;
+ }
+ return defaultValue;
+}
+*/
+
+void SaveShowDots(bool showDots) { SaveOption(kShowDots, showDots); }
+bool ReadShowDots() { return ReadOption(kShowDots, false); }
+
+void SaveShowRealFileIcons(bool show) { SaveOption(kShowRealFileIcons, show); }
+bool ReadShowRealFileIcons() { return ReadOption(kShowRealFileIcons, false); }
+
+void SaveShowSystemMenu(bool show) { SaveOption(kShowSystemMenu, show); }
+bool ReadShowSystemMenu(){ return ReadOption(kShowSystemMenu, false); }
+
+void SaveFullRow(bool enable) { SaveOption(kFullRow, enable); }
+bool ReadFullRow() { return ReadOption(kFullRow, false); }
+
+void SaveShowGrid(bool enable) { SaveOption(kShowGrid, enable); }
+bool ReadShowGrid(){ return ReadOption(kShowGrid, false); }
+
+void SaveAlternativeSelection(bool enable) { SaveOption(kAlternativeSelection, enable); }
+bool ReadAlternativeSelection(){ return ReadOption(kAlternativeSelection, false); }
+
+void SaveSingleClick(bool enable) { SaveOption(kSingleClick, enable); }
+bool ReadSingleClick(){ return ReadOption(kSingleClick, false); }
+
+/*
+void SaveUnderline(bool enable) { SaveOption(kUnderline, enable); }
+bool ReadUnderline(){ return ReadOption(kUnderline, false); }
+*/
+
+// void SaveLockMemoryAdd(bool enable) { SaveLmOption(kLockMemoryAdd, enable); }
+// bool ReadLockMemoryAdd() { return ReadLmOption(kLockMemoryAdd, true); }
+
+void SaveLockMemoryEnable(bool enable) { Save7ZipOption(kLargePagesEnable, enable); }
+bool ReadLockMemoryEnable() { return Read7ZipOption(kLargePagesEnable, false); }
+
+static CSysString GetFlatViewName(UInt32 panelIndex)
+{
+ TCHAR panelString[16];
+ ConvertUInt32ToString(panelIndex, panelString);
+ return (CSysString)kFlatViewName + panelString;
+}
+
+void SaveFlatView(UInt32 panelIndex, bool enable) { SaveOption(GetFlatViewName(panelIndex), enable); }
+bool ReadFlatView(UInt32 panelIndex) { return ReadOption(GetFlatViewName(panelIndex), false); }
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/RegistryUtils.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/RegistryUtils.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/RegistryUtils.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/RegistryUtils.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,53 @@
+// RegistryUtils.h
+
+#ifndef __REGISTRY_UTILS_H
+#define __REGISTRY_UTILS_H
+
+#include "Common/MyString.h"
+#include "Common/Types.h"
+
+void SaveRegLang(const UString &path);
+void ReadRegLang(UString &path);
+
+void SaveRegEditor(const UString &path);
+void ReadRegEditor(UString &path);
+
+void SaveRegDiff(const UString &path);
+void ReadRegDiff(UString &path);
+
+void SaveShowDots(bool showDots);
+bool ReadShowDots();
+
+void SaveShowRealFileIcons(bool show);
+bool ReadShowRealFileIcons();
+
+void SaveShowSystemMenu(bool showSystemMenu);
+bool ReadShowSystemMenu();
+
+void SaveFullRow(bool enable);
+bool ReadFullRow();
+
+void SaveShowGrid(bool enable);
+bool ReadShowGrid();
+
+void SaveAlternativeSelection(bool enable);
+bool ReadAlternativeSelection();
+
+// void SaveLockMemoryAdd(bool enable);
+// bool ReadLockMemoryAdd();
+
+bool ReadLockMemoryEnable();
+void SaveLockMemoryEnable(bool enable);
+
+void SaveSingleClick(bool enable);
+bool ReadSingleClick();
+
+/*
+void SaveUnderline(bool enable);
+bool ReadUnderline();
+*/
+
+void SaveFlatView(UInt32 panelIndex, bool enable);
+bool ReadFlatView(UInt32 panelIndex);
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/RootFolder.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/RootFolder.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/RootFolder.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/RootFolder.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,278 @@
+// RootFolder.cpp
+
+#include "StdAfx.h"
+
+#include "resource.h"
+
+#include "RootFolder.h"
+
+#include "Common/StringConvert.h"
+#include "../../PropID.h"
+#include "Windows/Defs.h"
+#include "Windows/PropVariant.h"
+
+#ifdef _WIN32
+#include "FSDrives.h"
+#include "PhysDriveFolder.h"
+#include "NetFolder.h"
+#endif
+#include "SysIconUtils.h"
+#include "LangUtils.h"
+
+using namespace NWindows;
+
+
+static const STATPROPSTG kProperties[] =
+{
+ { NULL, kpidName, VT_BSTR}
+};
+
+// static const wchar_t *kMyComputerTitle = L"Computer";
+// static const wchar_t *kMyNetworkTitle = L"Network";
+
+#ifdef _WIN32
+UString RootFolder_GetName_Computer(int &iconIndex)
+{
+ iconIndex = GetIconIndexForCSIDL(CSIDL_DRIVES);
+ return LangString(IDS_COMPUTER, 0x03020300);
+}
+
+UString RootFolder_GetName_Network(int &iconIndex)
+{
+ iconIndex = GetIconIndexForCSIDL(CSIDL_NETWORK);
+ return LangString(IDS_NETWORK, 0x03020301);
+}
+
+UString RootFolder_GetName_Documents(int &iconIndex)
+{
+ iconIndex = GetIconIndexForCSIDL(CSIDL_PERSONAL);
+ return LangString(IDS_DOCUMENTS, 0x03020302); ;
+}
+
+const int ROOT_INDEX_COMPUTER = 0;
+const int ROOT_INDEX_DOCUMENTS = 1;
+const int ROOT_INDEX_NETWORK = 2;
+
+void CRootFolder::Init()
+{
+ _names[ROOT_INDEX_COMPUTER] = RootFolder_GetName_Computer(_iconIndices[ROOT_INDEX_COMPUTER]);
+ _names[ROOT_INDEX_DOCUMENTS] = RootFolder_GetName_Documents(_iconIndices[ROOT_INDEX_DOCUMENTS]);
+ _names[ROOT_INDEX_NETWORK] = RootFolder_GetName_Network(_iconIndices[ROOT_INDEX_NETWORK]);
+}
+#else
+void CRootFolder::Init()
+{
+}
+#endif
+
+STDMETHODIMP CRootFolder::LoadItems()
+{
+ Init();
+ return S_OK;
+}
+
+STDMETHODIMP CRootFolder::GetNumberOfItems(UInt32 *numItems)
+{
+#ifdef _WIN32
+ *numItems = kNumRootFolderItems;
+#else
+ *numItems = 1; // only "/" !
+#endif
+ return S_OK;
+}
+
+STDMETHODIMP CRootFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT *value)
+{
+ NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidIsDir: prop = true; break;
+#ifdef _WIN32
+ case kpidName: prop = _names[itemIndex]; break;
+#else
+ case kpidName: prop = L"/"; break;
+#endif
+ }
+ prop.Detach(value);
+ return S_OK;
+}
+
+#ifdef _WIN32
+UString GetMyDocsPath()
+{
+ UString us;
+ WCHAR s[MAX_PATH + 1];
+ if (SHGetSpecialFolderPathW(0, s, CSIDL_PERSONAL, FALSE))
+ us = s;
+ #ifndef _UNICODE
+ else
+ {
+ CHAR s2[MAX_PATH + 1];
+ if (SHGetSpecialFolderPathA(0, s2, CSIDL_PERSONAL, FALSE))
+ us = GetUnicodeString(s2);
+ }
+ #endif
+ if (us.Length() > 0 && us[us.Length() - 1] != L'\\')
+ us += L'\\';
+ return us;
+}
+#endif
+
+STDMETHODIMP CRootFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder)
+{
+#ifdef _WIN32
+ if (index == ROOT_INDEX_COMPUTER)
+ {
+ CFSDrives *fsDrivesSpec = new CFSDrives;
+ CMyComPtr<IFolderFolder> subFolder = fsDrivesSpec;
+ fsDrivesSpec->Init();
+ *resultFolder = subFolder.Detach();
+ }
+ else if (index == ROOT_INDEX_NETWORK)
+ {
+ CNetFolder *netFolderSpec = new CNetFolder;
+ CMyComPtr<IFolderFolder> subFolder = netFolderSpec;
+ netFolderSpec->Init(0, 0, _names[ROOT_INDEX_NETWORK] + L'\\');
+ *resultFolder = subFolder.Detach();
+ }
+ else if (index == ROOT_INDEX_DOCUMENTS)
+ {
+ UString s = GetMyDocsPath();
+ if (!s.IsEmpty())
+ {
+ NFsFolder::CFSFolder *fsFolderSpec = new NFsFolder::CFSFolder;
+ CMyComPtr<IFolderFolder> subFolder = fsFolderSpec;
+ RINOK(fsFolderSpec->Init(s, NULL));
+ *resultFolder = subFolder.Detach();
+ }
+ }
+ else
+ return E_INVALIDARG;
+ return S_OK;
+#else
+ return E_INVALIDARG;
+#endif
+}
+
+static bool AreEqualNames(const UString &name1, const UString &name2)
+{
+ return (name1 == name2 || name1 == (name2 + UString(WCHAR_PATH_SEPARATOR)));
+}
+
+STDMETHODIMP CRootFolder::BindToFolder(const wchar_t *name, IFolderFolder **resultFolder)
+{
+ *resultFolder = 0;
+ UString name2 = name;
+ name2.Trim();
+ if (name2.IsEmpty())
+ {
+ CRootFolder *rootFolderSpec = new CRootFolder;
+ CMyComPtr<IFolderFolder> rootFolder = rootFolderSpec;
+ rootFolderSpec->Init();
+ *resultFolder = rootFolder.Detach();
+ return S_OK;
+ }
+#ifdef _WIN32
+ for (int i = 0; i < kNumRootFolderItems; i++)
+ if (AreEqualNames(name2, _names[i]))
+ return BindToFolder((UInt32)i, resultFolder);
+ if (AreEqualNames(name2, L"My Documents") ||
+ AreEqualNames(name2, L"Documents"))
+ return BindToFolder((UInt32)ROOT_INDEX_DOCUMENTS, resultFolder);
+ if (AreEqualNames(name2, L"My Computer") ||
+ AreEqualNames(name2, L"Computer"))
+ return BindToFolder((UInt32)ROOT_INDEX_COMPUTER, resultFolder);
+#endif
+ if (name2 == UString(WCHAR_PATH_SEPARATOR))
+ {
+ CMyComPtr<IFolderFolder> subFolder = this;
+ *resultFolder = subFolder.Detach();
+ return S_OK;
+ }
+
+ if (name2.Length () < 2)
+ return E_INVALIDARG;
+
+ CMyComPtr<IFolderFolder> subFolder;
+
+#ifdef _WIN32
+ if (name2.Left(4) == L"\\\\.\\")
+ {
+ CPhysDriveFolder *folderSpec = new CPhysDriveFolder;
+ subFolder = folderSpec;
+ RINOK(folderSpec->Init(name2.Mid(4, 2)));
+ }
+ else
+#endif
+ {
+ if (name2[name2.Length () - 1] != WCHAR_PATH_SEPARATOR)
+ name2 += WCHAR_PATH_SEPARATOR;
+ NFsFolder::CFSFolder *fsFolderSpec = new NFsFolder::CFSFolder;
+ subFolder = fsFolderSpec;
+ if (fsFolderSpec->Init(name2, 0) != S_OK)
+ {
+#ifdef _WIN32
+ if (name2[0] == WCHAR_PATH_SEPARATOR)
+ {
+ CNetFolder *netFolderSpec = new CNetFolder;
+ subFolder = netFolderSpec;
+ netFolderSpec->Init(name2);
+ }
+ else
+#endif
+ return E_INVALIDARG;
+ }
+ }
+ *resultFolder = subFolder.Detach();
+ return S_OK;
+}
+
+STDMETHODIMP CRootFolder::BindToParentFolder(IFolderFolder **resultFolder)
+{
+ *resultFolder = 0;
+ return S_OK;
+}
+
+STDMETHODIMP CRootFolder::GetNumberOfProperties(UInt32 *numProperties)
+{
+ *numProperties = sizeof(kProperties) / sizeof(kProperties[0]);
+ return S_OK;
+}
+
+STDMETHODIMP CRootFolder::GetPropertyInfo(UInt32 index,
+ BSTR *name, PROPID *propID, VARTYPE *varType)
+{
+ if (index >= sizeof(kProperties) / sizeof(kProperties[0]))
+ return E_INVALIDARG;
+ const STATPROPSTG &prop = kProperties[index];
+ *propID = prop.propid;
+ *varType = prop.vt;
+ *name = 0;
+ return S_OK;
+}
+
+STDMETHODIMP CRootFolder::GetFolderProperty(PROPID propID, PROPVARIANT *value)
+{
+ NWindows::NCOM::CPropVariant prop;
+ switch(propID)
+ {
+ case kpidType: prop = L"RootFolder"; break;
+ case kpidPath: prop = L""; break;
+ }
+ prop.Detach(value);
+ return S_OK;
+}
+
+STDMETHODIMP CRootFolder::GetSystemIconIndex(UInt32 index, INT32 *iconIndex)
+{
+#ifdef _WIN32
+ *iconIndex = _iconIndices[index];
+#else
+ *iconIndex = -1; // FIXME - folder icon ?
+#endif
+ return S_OK;
+}
+
+
+
+
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/RootFolder.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/RootFolder.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/RootFolder.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/RootFolder.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,38 @@
+// RootFolder.h
+
+#ifndef __ROOTFOLDER_H
+#define __ROOTFOLDER_H
+
+#include "Common/MyString.h"
+
+#include "Windows/PropVariant.h"
+
+#include "FSFolder.h"
+
+#ifdef _WIN32
+const int kNumRootFolderItems = 3;
+#endif
+
+class CRootFolder:
+ public IFolderFolder,
+ public IFolderGetSystemIconIndex,
+ public CMyUnknownImp
+{
+public:
+ MY_UNKNOWN_IMP1(
+ IFolderGetSystemIconIndex
+ )
+
+ INTERFACE_FolderFolder(;)
+
+ STDMETHOD(GetSystemIconIndex)(UInt32 index, INT32 *iconIndex);
+
+ void Init();
+private:
+#ifdef _WIN32
+ UString _names[kNumRootFolderItems];
+ int _iconIndices[kNumRootFolderItems];
+#endif
+};
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/SplitDialog.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/SplitDialog.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/SplitDialog.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/SplitDialog.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,118 @@
+// SplitDialog.cpp
+
+#include "StdAfx.h"
+
+#include "Windows/FileName.h"
+
+#ifdef LANG
+#include "LangUtils.h"
+#endif
+
+#include "BrowseDialog.h"
+#include "CopyDialogRes.h"
+#include "SplitDialog.h"
+#include "SplitUtils.h"
+#include "resourceGui.h"
+
+using namespace NWindows;
+
+#ifdef LANG
+static CIDLangPair kIDLangPairs[] =
+{
+ { IDC_STATIC_SPLIT_PATH, 0x03020501 },
+ { IDC_STATIC_SPLIT_VOLUME, 0x02000D40 },
+};
+#endif
+
+
+bool CSplitDialog::OnInit()
+{
+ #ifdef LANG
+ LangSetWindowText(HWND(*this), 0x03020500);
+ LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
+ #endif
+ _pathCombo.Attach(GetItem(IDC_COMBO_SPLIT_PATH));
+ _volumeCombo.Attach(GetItem(IDC_COMBO_SPLIT_VOLUME));
+
+ if (!FilePath.IsEmpty())
+ {
+ UString title;
+ GetText(title);
+ title += L' ';
+ title += FilePath;
+ SetText(title);
+ }
+ _pathCombo.SetText(Path);
+ AddVolumeItems(_volumeCombo);
+ _volumeCombo.SetCurSel(0);
+ NormalizeSize();
+ return CModalDialog::OnInit();
+}
+
+#ifdef _WIN32
+bool CSplitDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize)
+{
+ int mx, my;
+ GetMargins(8, mx, my);
+ int bx1, bx2, by;
+ GetItemSizes(IDCANCEL, bx1, by);
+ GetItemSizes(IDOK, bx2, by);
+ int yPos = ySize - my - by;
+ int xPos = xSize - mx - bx1;
+
+ InvalidateRect(NULL);
+
+ {
+ RECT rect;
+ GetClientRectOfItem(IDC_BUTTON_SPLIT_PATH, rect);
+ int bx = rect.right - rect.left;
+ MoveItem(IDC_BUTTON_SPLIT_PATH, xSize - mx - bx, rect.top, bx, rect.bottom - rect.top);
+ ChangeSubWindowSizeX(_pathCombo, xSize - mx - mx - bx - mx);
+ }
+
+ MoveItem(IDCANCEL, xPos, yPos, bx1, by);
+ MoveItem(IDOK, xPos - mx - bx2, yPos, bx2, by);
+
+ return false;
+}
+#endif
+
+bool CSplitDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
+{
+ switch(buttonID)
+ {
+ case IDC_BUTTON_SPLIT_PATH:
+ OnButtonSetPath();
+ return true;
+ }
+ return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
+}
+
+void CSplitDialog::OnButtonSetPath()
+{
+ UString currentPath;
+ _pathCombo.GetText(currentPath);
+ // UString title = L"Specify a location for output folder";
+ UString title = LangStringSpec(IDS_SET_FOLDER, 0x03020209);
+
+ UString resultPath;
+ if (!MyBrowseForFolder(HWND(*this), title, currentPath, resultPath))
+ return;
+ NFile::NName::NormalizeDirPathPrefix(resultPath);
+ _pathCombo.SetCurSel(-1);
+ _pathCombo.SetText(resultPath);
+}
+
+void CSplitDialog::OnOK()
+{
+ _pathCombo.GetText(Path);
+ UString volumeString;
+ _volumeCombo.GetText(volumeString);
+ volumeString.Trim();
+ if (!ParseVolumeSizes(volumeString, VolumeSizes) || VolumeSizes.Size() == 0)
+ {
+ ::MessageBoxW(*this, LangString(IDS_INCORRECT_VOLUME_SIZE, 0x02000D41), L"7-Zip", 0);
+ return;
+ }
+ CModalDialog::OnOK();
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/SplitDialog.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/SplitDialog.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/SplitDialog.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/SplitDialog.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,28 @@
+// SplitDialog.h
+
+#ifndef __SPLIT_DIALOG_H
+#define __SPLIT_DIALOG_H
+
+#include "Windows/Control/Dialog.h"
+#include "Windows/Control/ComboBox.h"
+
+#include "SplitDialogRes.h"
+
+class CSplitDialog: public NWindows::NControl::CModalDialog
+{
+ NWindows::NControl::CComboBox _pathCombo;
+ NWindows::NControl::CComboBox _volumeCombo;
+ virtual void OnOK();
+ virtual bool OnInit();
+ // FIXME virtual bool OnSize(WPARAM wParam, int xSize, int ySize);
+ virtual bool OnButtonClicked(int buttonID, HWND buttonHWND);
+ void OnButtonSetPath();
+public:
+ UString FilePath;
+ UString Path;
+ CRecordVector<UInt64> VolumeSizes;
+ INT_PTR Create(HWND parentWindow = 0)
+ { return CModalDialog::Create(IDD_DIALOG_SPLIT, parentWindow); }
+};
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/SplitDialogRes.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/SplitDialogRes.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/SplitDialogRes.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/SplitDialogRes.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,7 @@
+#define IDD_DIALOG_SPLIT 504
+#define IDC_STATIC_SPLIT_PATH 1000
+#define IDC_COMBO_SPLIT_PATH 1001
+#define IDC_BUTTON_SPLIT_PATH 1002
+#define IDC_STATIC_SPLIT_VOLUME 1010
+#define IDC_COMBO_SPLIT_VOLUME 1011
+
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/SplitDialog_rc.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/SplitDialog_rc.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/SplitDialog_rc.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/SplitDialog_rc.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,81 @@
+// PasswordDialog.cpp
+
+#include "StdAfx.h"
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+// for all others, include the necessary headers (this file is usually all you
+// need because it includes almost all "standard" wxWidgets headers)
+#ifndef WX_PRECOMP
+ #include "wx/wx.h"
+#endif
+
+#undef _WIN32
+
+#include "Windows/Control/DialogImpl.h"
+
+#include "SplitDialogRes.h"
+
+class CSplitDialogImpl : public NWindows::NControl::CModalDialogImpl
+{
+ public:
+ CSplitDialogImpl(NWindows::NControl::CModalDialog *dialog,wxWindow * parent,int id) : CModalDialogImpl(dialog, parent, id, wxT("Split File"))
+ {
+
+ wxArrayString pathArray;
+
+ wxBoxSizer* topsizer = new wxBoxSizer(wxVERTICAL);
+
+
+ topsizer->Add(new wxStaticText(this, IDC_STATIC_SPLIT_PATH, _T("&Split to:")) , 0 ,wxALL | wxALIGN_LEFT, 5 );
+
+
+ {
+ wxBoxSizer *pathSizer = new wxBoxSizer(wxHORIZONTAL);
+
+ wxComboBox *combo = new wxComboBox(this, IDC_COMBO_SPLIT_PATH, wxEmptyString, wxDefaultPosition, wxSize(600,-1), pathArray, wxCB_DROPDOWN|wxCB_SORT);
+ wxButton *button = new wxButton(this, IDC_BUTTON_SPLIT_PATH, wxT("..."), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
+ pathSizer->Add(combo, 1, wxLEFT|wxRIGHT|wxEXPAND, 5);
+ pathSizer->Add(button, 0, wxLEFT|wxRIGHT|wxEXPAND, 5);
+
+ topsizer->Add(pathSizer, 0 ,wxALL | wxALIGN_LEFT, 5 );
+ }
+
+ topsizer->Add(new wxStaticText(this, IDC_STATIC_SPLIT_VOLUME, _T("Split to &volumes, bytes:")) , 0 ,wxALL | wxALIGN_LEFT, 5 );
+
+ wxComboBox *combo = new wxComboBox(this, IDC_COMBO_SPLIT_VOLUME, wxEmptyString, wxDefaultPosition, wxSize(600,-1), pathArray, wxCB_DROPDOWN|wxCB_SORT);
+
+ topsizer->Add(combo, 0 ,wxALL | wxALIGN_LEFT, 5 );
+
+
+ topsizer->Add(CreateButtonSizer(wxOK|wxCANCEL), 0, wxALL|wxEXPAND, 5);
+
+ this->OnInit();
+
+ SetSizer(topsizer); // use the sizer for layout
+ topsizer->SetSizeHints(this); // set size hints to honour minimum size
+ }
+private:
+ // Any class wishing to process wxWindows events must use this macro
+ DECLARE_EVENT_TABLE()
+};
+
+static CStringTable g_stringTable[] =
+{
+ { 0 , 0 }
+};
+
+
+REGISTER_DIALOG(IDD_DIALOG_SPLIT,CSplitDialog,g_stringTable)
+
+BEGIN_EVENT_TABLE(CSplitDialogImpl, wxDialog)
+ EVT_BUTTON(wxID_ANY, CModalDialogImpl::OnAnyButton)
+ EVT_CHECKBOX(wxID_ANY, CModalDialogImpl::OnAnyButton)
+ EVT_MENU(WORKER_EVENT, CModalDialogImpl::OnWorkerEvent)
+END_EVENT_TABLE()
+
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/SplitUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/SplitUtils.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/SplitUtils.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/SplitUtils.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,86 @@
+// SplitUtils.cpp
+
+#include "StdAfx.h"
+
+#include "Common/StringToInt.h"
+
+#include "SplitUtils.h"
+#include "StringUtils.h"
+
+bool ParseVolumeSizes(const UString &s, CRecordVector<UInt64> &values)
+{
+ values.Clear();
+ UStringVector destStrings;
+ SplitString(s, destStrings);
+ bool prevIsNumber = false;
+ for (int i = 0; i < destStrings.Size(); i++)
+ {
+ UString subString = destStrings[i];
+ subString.MakeUpper();
+ if (subString.IsEmpty())
+ return false;
+ if (subString == L"-")
+ return true;
+ if (prevIsNumber)
+ {
+ wchar_t c = subString[0];
+ UInt64 &value = values.Back();
+ prevIsNumber = false;
+ switch(c)
+ {
+ case L'B':
+ continue;
+ case L'K':
+ value <<= 10;
+ continue;
+ case L'M':
+ value <<= 20;
+ continue;
+ case L'G':
+ value <<= 30;
+ continue;
+ }
+ }
+ const wchar_t *start = subString;
+ const wchar_t *end;
+ UInt64 value = ConvertStringToUInt64(start, &end);
+ if (start == end)
+ return false;
+ if (value == 0)
+ return false;
+ values.Add(value);
+ prevIsNumber = true;
+ UString rem = subString.Mid((int)(end - start));
+ if (!rem.IsEmpty())
+ destStrings.Insert(i + 1, rem);
+ }
+ return true;
+}
+
+void AddVolumeItems(NWindows::NControl::CComboBox &volumeCombo)
+{
+ volumeCombo.AddString(TEXT("10M"));
+ volumeCombo.AddString(TEXT("650M - CD"));
+ volumeCombo.AddString(TEXT("700M - CD"));
+ volumeCombo.AddString(TEXT("4480M - DVD"));
+ volumeCombo.AddString(TEXT("1457664 - 3.5\" floppy"));
+}
+
+UInt64 GetNumberOfVolumes(UInt64 size, CRecordVector<UInt64> &volSizes)
+{
+ if (size == 0 || volSizes.Size() == 0)
+ return 1;
+ UInt64 numVolumes = 0;
+ for (int i = 0; i < volSizes.Size(); i++)
+ {
+ UInt64 volSize = volSizes[i];
+ numVolumes++;
+ if (volSize >= size)
+ return numVolumes;
+ size -= volSize;
+ }
+ UInt64 volSize = volSizes.Back();
+ if (volSize == 0)
+ return (UInt64)(Int64)-1;
+ return numVolumes + (size - 1) / volSize + 1;
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/SplitUtils.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/SplitUtils.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/SplitUtils.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/SplitUtils.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,15 @@
+// SplitUtils.h
+
+#ifndef __SPLITUTILS_H
+#define __SPLITUTILS_H
+
+#include "Common/MyString.h"
+#include "Common/Types.h"
+#include "Windows/Control/ComboBox.h"
+
+bool ParseVolumeSizes(const UString &s, CRecordVector<UInt64> &values);
+void AddVolumeItems(NWindows::NControl::CComboBox &volumeCombo);
+
+UInt64 GetNumberOfVolumes(UInt64 size, CRecordVector<UInt64> &volSizes);
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/StringUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/StringUtils.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/StringUtils.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/StringUtils.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,68 @@
+// StringUtils.cpp
+
+#include "StdAfx.h"
+
+#include "StringUtils.h"
+
+void SplitStringToTwoStrings(const UString &src, UString &dest1, UString &dest2)
+{
+ dest1.Empty();
+ dest2.Empty();
+ bool quoteMode = false;
+ int i;
+ for (i = 0; i < src.Length(); i++)
+ {
+ wchar_t c = src[i];
+ if (c == L'\"')
+ quoteMode = !quoteMode;
+ else if (c == L' ' && !quoteMode)
+ {
+ if (!quoteMode)
+ {
+ i++;
+ break;
+ }
+ }
+ else
+ dest1 += c;
+ }
+ dest2 = src.Mid(i);
+}
+
+void SplitString(const UString &srcString, UStringVector &destStrings)
+{
+ destStrings.Clear();
+ UString string;
+ int len = srcString.Length();
+ if (len == 0)
+ return;
+ for (int i = 0; i < len; i++)
+ {
+ wchar_t c = srcString[i];
+ if (c == L' ')
+ {
+ if (!string.IsEmpty())
+ {
+ destStrings.Add(string);
+ string.Empty();
+ }
+ }
+ else
+ string += c;
+ }
+ if (!string.IsEmpty())
+ destStrings.Add(string);
+}
+
+UString JoinStrings(const UStringVector &srcStrings)
+{
+ UString destString;
+ for (int i = 0; i < srcStrings.Size(); i++)
+ {
+ if (i != 0)
+ destString += L' ';
+ destString += srcStrings[i];
+ }
+ return destString;
+}
+
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/StringUtils.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/StringUtils.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/StringUtils.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/StringUtils.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,13 @@
+// StringUtils.h
+
+#ifndef __STRINGUTILS_H
+#define __STRINGUTILS_H
+
+#include "Common/MyString.h"
+
+void SplitStringToTwoStrings(const UString &src, UString &dest1, UString &dest2);
+
+void SplitString(const UString &srcString, UStringVector &destStrings);
+UString JoinStrings(const UStringVector &srcStrings);
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/SysIconUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/SysIconUtils.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/SysIconUtils.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/SysIconUtils.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,173 @@
+// SysIconUtils.cpp
+
+#include "StdAfx.h"
+
+#ifndef _UNICODE
+#include "Common/StringConvert.h"
+#endif
+
+#include "SysIconUtils.h"
+
+#ifndef _UNICODE
+extern bool g_IsNT;
+#endif
+
+#ifdef _WIN32
+
+int GetIconIndexForCSIDL(int csidl)
+{
+ LPITEMIDLIST pidl = 0;
+ SHGetSpecialFolderLocation(NULL, csidl, &pidl);
+ if (pidl)
+ {
+ SHFILEINFO shellInfo;
+ SHGetFileInfo(LPCTSTR(pidl), FILE_ATTRIBUTE_NORMAL,
+ &shellInfo, sizeof(shellInfo),
+ SHGFI_PIDL | SHGFI_SYSICONINDEX);
+ IMalloc *pMalloc;
+ SHGetMalloc(&pMalloc);
+ if(pMalloc)
+ {
+ pMalloc->Free(pidl);
+ pMalloc->Release();
+ }
+ return shellInfo.iIcon;
+ }
+ return 0;
+}
+
+DWORD_PTR GetRealIconIndex(LPCTSTR path, DWORD attrib, int &iconIndex)
+{
+ SHFILEINFO shellInfo;
+ DWORD_PTR res = ::SHGetFileInfo(path, FILE_ATTRIBUTE_NORMAL | attrib, &shellInfo,
+ sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX);
+ iconIndex = shellInfo.iIcon;
+ return res;
+}
+
+
+#ifndef _UNICODE
+typedef int (WINAPI * SHGetFileInfoWP)(LPCWSTR pszPath, DWORD attrib, SHFILEINFOW *psfi, UINT cbFileInfo, UINT uFlags);
+
+struct CSHGetFileInfoInit
+{
+ SHGetFileInfoWP shGetFileInfoW;
+ CSHGetFileInfoInit()
+ {
+ shGetFileInfoW = (SHGetFileInfoWP)
+ ::GetProcAddress(::GetModuleHandleW(L"shell32.dll"), "SHGetFileInfoW");
+ }
+} g_SHGetFileInfoInit;
+#endif
+
+static DWORD_PTR MySHGetFileInfoW(LPCWSTR pszPath, DWORD attrib, SHFILEINFOW *psfi, UINT cbFileInfo, UINT uFlags)
+{
+ #ifdef _UNICODE
+ return SHGetFileInfo(
+ #else
+ if (g_SHGetFileInfoInit.shGetFileInfoW == 0)
+ return 0;
+ return g_SHGetFileInfoInit.shGetFileInfoW(
+ #endif
+ pszPath, attrib, psfi, cbFileInfo, uFlags);
+}
+
+#ifndef _UNICODE
+// static inline UINT GetCurrentCodePage() { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; }
+DWORD_PTR GetRealIconIndex(LPCWSTR path, DWORD attrib, int &iconIndex)
+{
+ if(g_IsNT)
+ {
+ SHFILEINFOW shellInfo;
+ DWORD_PTR res = ::MySHGetFileInfoW(path, FILE_ATTRIBUTE_NORMAL | attrib, &shellInfo,
+ sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX);
+ iconIndex = shellInfo.iIcon;
+ return res;
+ }
+ else
+ return GetRealIconIndex(UnicodeStringToMultiByte(path), attrib, iconIndex);
+}
+#endif
+
+DWORD_PTR GetRealIconIndex(const UString &fileName, DWORD attrib,
+ int &iconIndex, UString &typeName)
+{
+ #ifndef _UNICODE
+ if(!g_IsNT)
+ {
+ SHFILEINFO shellInfo;
+ shellInfo.szTypeName[0] = 0;
+ DWORD_PTR res = ::SHGetFileInfoA(GetSystemString(fileName), FILE_ATTRIBUTE_NORMAL | attrib, &shellInfo,
+ sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX | SHGFI_TYPENAME);
+ typeName = GetUnicodeString(shellInfo.szTypeName);
+ iconIndex = shellInfo.iIcon;
+ return res;
+ }
+ else
+ #endif
+ {
+ SHFILEINFOW shellInfo;
+ shellInfo.szTypeName[0] = 0;
+ DWORD_PTR res = ::MySHGetFileInfoW(fileName, FILE_ATTRIBUTE_NORMAL | attrib, &shellInfo,
+ sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX | SHGFI_TYPENAME);
+ typeName = shellInfo.szTypeName;
+ iconIndex = shellInfo.iIcon;
+ return res;
+ }
+}
+
+int CExtToIconMap::GetIconIndex(DWORD attrib, const UString &fileName, UString &typeName)
+{
+ int dotPos = fileName.ReverseFind(L'.');
+ if ((attrib & FILE_ATTRIBUTE_DIRECTORY) != 0 || dotPos < 0)
+ {
+ CAttribIconPair pair;
+ pair.Attrib = attrib;
+ int index = _attribMap.FindInSorted(pair);
+ if (index >= 0)
+ {
+ typeName = _attribMap[index].TypeName;
+ return _attribMap[index].IconIndex;
+ }
+ GetRealIconIndex(
+ #ifdef UNDER_CE
+ L"\\"
+ #endif
+ L"__File__"
+ , attrib, pair.IconIndex, pair.TypeName);
+ _attribMap.AddToSorted(pair);
+ typeName = pair.TypeName;
+ return pair.IconIndex;
+ }
+
+ CExtIconPair pair;
+ pair.Ext = fileName.Mid(dotPos + 1);
+ int index = _extMap.FindInSorted(pair);
+ if (index >= 0)
+ {
+ typeName = _extMap[index].TypeName;
+ return _extMap[index].IconIndex;
+ }
+ GetRealIconIndex(fileName.Mid(dotPos), attrib, pair.IconIndex, pair.TypeName);
+ _extMap.AddToSorted(pair);
+ typeName = pair.TypeName;
+ return pair.IconIndex;
+}
+
+int CExtToIconMap::GetIconIndex(DWORD attrib, const UString &fileName)
+{
+ UString typeName;
+ return GetIconIndex(attrib, fileName, typeName);
+}
+#else
+DWORD_PTR GetRealIconIndex(LPCTSTR path, DWORD attrib, int &iconIndex)
+{
+ iconIndex = -1;
+ return -1;
+}
+int CExtToIconMap::GetIconIndex(DWORD attrib, const UString &fileName)
+{
+ return -1;
+}
+#endif
+
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/SysIconUtils.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/SysIconUtils.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/SysIconUtils.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/SysIconUtils.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,59 @@
+// SysIconUtils.h
+
+#ifndef __SYS_ICON_UTILS_H
+#define __SYS_ICON_UTILS_H
+
+#include "Common/MyString.h"
+
+struct CExtIconPair
+{
+ UString Ext;
+ int IconIndex;
+ UString TypeName;
+};
+
+struct CAttribIconPair
+{
+ DWORD Attrib;
+ int IconIndex;
+ UString TypeName;
+};
+
+inline bool operator==(const CExtIconPair &a1, const CExtIconPair &a2) { return a1.Ext == a2.Ext; }
+inline bool operator< (const CExtIconPair &a1, const CExtIconPair &a2) { return a1.Ext < a2.Ext; }
+
+inline bool operator==(const CAttribIconPair &a1, const CAttribIconPair &a2) { return a1.Attrib == a2.Attrib; }
+inline bool operator< (const CAttribIconPair &a1, const CAttribIconPair &a2) { return a1.Attrib < a2.Attrib; }
+
+class CExtToIconMap
+{
+ CObjectVector<CExtIconPair> _extMap;
+ CObjectVector<CAttribIconPair> _attribMap;
+public:
+ void Clear()
+ {
+ _extMap.Clear();
+ _attribMap.Clear();
+ }
+ int GetIconIndex(DWORD attrib, const UString &fileName, UString &typeName);
+ int GetIconIndex(DWORD attrib, const UString &fileName);
+};
+
+DWORD_PTR GetRealIconIndex(LPCTSTR path, DWORD attrib, int &iconIndex);
+#ifndef _UNICODE
+DWORD_PTR GetRealIconIndex(LPCWSTR path, DWORD attrib, int &iconIndex);
+#endif
+int GetIconIndexForCSIDL(int csidl);
+
+#ifdef WIN32
+inline HIMAGELIST GetSysImageList(bool smallIcons)
+{
+ SHFILEINFO shellInfo;
+ return (HIMAGELIST)SHGetFileInfo(TEXT(""),
+ FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_DIRECTORY,
+ &shellInfo, sizeof(shellInfo),
+ SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX | (smallIcons ? SHGFI_SMALLICON : SHGFI_ICON));
+}
+#endif
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/TextPairs.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/TextPairs.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/TextPairs.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/TextPairs.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,189 @@
+// TextPairs.cpp
+
+#include "StdAfx.h"
+
+#include "TextPairs.h"
+
+static const wchar_t kNewLineChar = '\n';
+static const wchar_t kQuoteChar = '\"';
+
+static const wchar_t kBOM = (wchar_t)0xFEFF;
+
+static bool IsSeparatorChar(wchar_t c)
+{
+ return (c == ' ' || c == '\t');
+}
+
+static void RemoveCr(UString &s)
+{
+ s.Replace(L"\x0D", L"");
+}
+
+static UString GetIDString(const wchar_t *srcString, int &finishPos)
+{
+ UString result;
+ bool quotes = false;
+ for (finishPos = 0;;)
+ {
+ wchar_t c = srcString[finishPos];
+ if (c == 0)
+ break;
+ finishPos++;
+ bool isSeparatorChar = IsSeparatorChar(c);
+ if (c == kNewLineChar || (isSeparatorChar && !quotes)
+ || (c == kQuoteChar && quotes))
+ break;
+ else if (c == kQuoteChar)
+ quotes = true;
+ else
+ result += c;
+ }
+ result.Trim();
+ RemoveCr(result);
+ return result;
+}
+
+static UString GetValueString(const wchar_t *srcString, int &finishPos)
+{
+ UString result;
+ for (finishPos = 0;;)
+ {
+ wchar_t c = srcString[finishPos];
+ if (c == 0)
+ break;
+ finishPos++;
+ if (c == kNewLineChar)
+ break;
+ result += c;
+ }
+ result.Trim();
+ RemoveCr(result);
+ return result;
+}
+
+static bool GetTextPairs(const UString &srcString, CObjectVector<CTextPair> &pairs)
+{
+ pairs.Clear();
+ int pos = 0;
+
+ if (srcString.Length() > 0)
+ {
+ if (srcString[0] == kBOM)
+ pos++;
+ }
+ while (pos < srcString.Length())
+ {
+ int finishPos;
+ UString id = GetIDString((const wchar_t *)srcString + pos, finishPos);
+ pos += finishPos;
+ if (id.IsEmpty())
+ continue;
+ UString value = GetValueString((const wchar_t *)srcString + pos, finishPos);
+ pos += finishPos;
+ if (!id.IsEmpty())
+ {
+ CTextPair pair;
+ pair.ID = id;
+ pair.Value = value;
+ pairs.Add(pair);
+ }
+ }
+ return true;
+}
+
+static int ComparePairIDs(const UString &s1, const UString &s2)
+ { return s1.CompareNoCase(s2); }
+static int ComparePairItems(const CTextPair &p1, const CTextPair &p2)
+ { return ComparePairIDs(p1.ID, p2.ID); }
+
+static int ComparePairItems(void *const *a1, void *const *a2, void * /* param */)
+ { return ComparePairItems(**(const CTextPair **)a1, **(const CTextPair **)a2); }
+
+void CPairsStorage::Sort() { Pairs.Sort(ComparePairItems, 0); }
+
+int CPairsStorage::FindID(const UString &id, int &insertPos)
+{
+ int left = 0, right = Pairs.Size();
+ while (left != right)
+ {
+ int mid = (left + right) / 2;
+ int compResult = ComparePairIDs(id, Pairs[mid].ID);
+ if (compResult == 0)
+ return mid;
+ if (compResult < 0)
+ right = mid;
+ else
+ left = mid + 1;
+ }
+ insertPos = left;
+ return -1;
+}
+
+int CPairsStorage::FindID(const UString &id)
+{
+ int pos;
+ return FindID(id, pos);
+}
+
+void CPairsStorage::AddPair(const CTextPair &pair)
+{
+ int insertPos;
+ int pos = FindID(pair.ID, insertPos);
+ if (pos >= 0)
+ Pairs[pos] = pair;
+ else
+ Pairs.Insert(insertPos, pair);
+}
+
+void CPairsStorage::DeletePair(const UString &id)
+{
+ int pos = FindID(id);
+ if (pos >= 0)
+ Pairs.Delete(pos);
+}
+
+bool CPairsStorage::GetValue(const UString &id, UString &value)
+{
+ value.Empty();
+ int pos = FindID(id);
+ if (pos < 0)
+ return false;
+ value = Pairs[pos].Value;
+ return true;
+}
+
+UString CPairsStorage::GetValue(const UString &id)
+{
+ int pos = FindID(id);
+ if (pos < 0)
+ return UString();
+ return Pairs[pos].Value;
+}
+
+bool CPairsStorage::ReadFromString(const UString &text)
+{
+ bool result = ::GetTextPairs(text, Pairs);
+ if (result)
+ Sort();
+ else
+ Pairs.Clear();
+ return result;
+}
+
+void CPairsStorage::SaveToString(UString &text)
+{
+ for (int i = 0; i < Pairs.Size(); i++)
+ {
+ const CTextPair &pair = Pairs[i];
+ bool multiWord = (pair.ID.Find(L' ') >= 0);
+ if (multiWord)
+ text += L'\"';
+ text += pair.ID;
+ if (multiWord)
+ text += L'\"';
+ text += L' ';
+ text += pair.Value;
+ text += L'\x0D';
+ text += L'\n';
+ }
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/TextPairs.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/TextPairs.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/TextPairs.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/TextPairs.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,31 @@
+// TextPairs.h
+
+#ifndef __FM_TEXT_PAIRS_H
+#define __FM_TEXT_PAIRS_H
+
+#include "Common/MyString.h"
+
+struct CTextPair
+{
+ UString ID;
+ UString Value;
+};
+
+class CPairsStorage
+{
+ CObjectVector<CTextPair> Pairs;
+ int FindID(const UString &id, int &insertPos);
+ int FindID(const UString &id);
+ void Sort();
+public:
+ void Clear() { Pairs.Clear(); };
+ bool ReadFromString(const UString &text);
+ void SaveToString(UString &text);
+
+ bool GetValue(const UString &id, UString &value);
+ UString GetValue(const UString &id);
+ void AddPair(const CTextPair &pair);
+ void DeletePair(const UString &id);
+};
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/UpdateCallback100.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/UpdateCallback100.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/UpdateCallback100.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/UpdateCallback100.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,90 @@
+// UpdateCallback100.cpp
+
+#include "StdAfx.h"
+
+#include "PasswordDialog.h"
+#include "UpdateCallback100.h"
+
+STDMETHODIMP CUpdateCallback100Imp::SetNumFiles(UInt64 numFiles)
+{
+ ProgressDialog->Sync.SetNumFilesTotal(numFiles);
+ return S_OK;
+}
+
+STDMETHODIMP CUpdateCallback100Imp::SetTotal(UInt64 size)
+{
+ ProgressDialog->Sync.SetProgress(size, 0);
+ return S_OK;
+}
+
+STDMETHODIMP CUpdateCallback100Imp::SetCompleted(const UInt64 *completeValue)
+{
+ RINOK(ProgressDialog->Sync.ProcessStopAndPause());
+ if (completeValue != NULL)
+ ProgressDialog->Sync.SetPos(*completeValue);
+ return S_OK;
+}
+
+STDMETHODIMP CUpdateCallback100Imp::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize)
+{
+ ProgressDialog->Sync.SetRatioInfo(inSize, outSize);
+ return S_OK;
+}
+
+STDMETHODIMP CUpdateCallback100Imp::CompressOperation(const wchar_t *name)
+{
+ ProgressDialog->Sync.SetCurrentFileName(name);
+ return S_OK;
+}
+
+STDMETHODIMP CUpdateCallback100Imp::DeleteOperation(const wchar_t *name)
+{
+ ProgressDialog->Sync.SetCurrentFileName(name);
+ return S_OK;
+}
+
+STDMETHODIMP CUpdateCallback100Imp::OperationResult(Int32 /* operationResult */)
+{
+ ProgressDialog->Sync.SetNumFilesCur(++_numFiles);
+ return S_OK;
+}
+
+STDMETHODIMP CUpdateCallback100Imp::UpdateErrorMessage(const wchar_t *message)
+{
+ ProgressDialog->Sync.AddErrorMessage(message);
+ return S_OK;
+}
+
+STDMETHODIMP CUpdateCallback100Imp::CryptoGetTextPassword2(Int32 *passwordIsDefined, BSTR *password)
+{
+ *password = NULL;
+ *passwordIsDefined = BoolToInt(_passwordIsDefined);
+ if (!_passwordIsDefined)
+ return S_OK;
+ return StringToBstr(_password, password);
+}
+
+STDMETHODIMP CUpdateCallback100Imp::SetTotal(const UInt64 * /* files */, const UInt64 * /* bytes */)
+{
+ return S_OK;
+}
+
+STDMETHODIMP CUpdateCallback100Imp::SetCompleted(const UInt64 * /* files */, const UInt64 * /* bytes */)
+{
+ return ProgressDialog->Sync.ProcessStopAndPause();
+}
+
+STDMETHODIMP CUpdateCallback100Imp::CryptoGetTextPassword(BSTR *password)
+{
+ *password = NULL;
+ if (!_passwordIsDefined)
+ {
+ CPasswordDialog dialog;
+ ProgressDialog->WaitCreating();
+ if (dialog.Create(*ProgressDialog) == IDCANCEL)
+ return E_ABORT;
+ _password = dialog.Password;
+ _passwordIsDefined = true;
+ }
+ return StringToBstr(_password, password);
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/UpdateCallback100.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/UpdateCallback100.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/UpdateCallback100.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/UpdateCallback100.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,54 @@
+// UpdateCallback100.h
+
+#ifndef __UPDATE_CALLBACK100_H
+#define __UPDATE_CALLBACK100_H
+
+#include "Common/MyCom.h"
+
+#include "../../IPassword.h"
+
+#include "../Agent/IFolderArchive.h"
+
+#include "ProgressDialog2.h"
+
+class CUpdateCallback100Imp:
+ public IFolderArchiveUpdateCallback,
+ public ICryptoGetTextPassword2,
+ public ICryptoGetTextPassword,
+ public IArchiveOpenCallback,
+ public ICompressProgressInfo,
+ public CMyUnknownImp
+{
+ bool _passwordIsDefined;
+ UString _password;
+ UInt64 _numFiles;
+public:
+ CProgressDialog *ProgressDialog;
+
+ CUpdateCallback100Imp(): ProgressDialog(0) {}
+
+ MY_UNKNOWN_IMP5(
+ IFolderArchiveUpdateCallback,
+ ICryptoGetTextPassword2,
+ ICryptoGetTextPassword,
+ IArchiveOpenCallback,
+ ICompressProgressInfo)
+
+ INTERFACE_IProgress(;)
+ INTERFACE_IArchiveOpenCallback(;)
+ INTERFACE_IFolderArchiveUpdateCallback(;)
+
+ STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
+
+ STDMETHOD(CryptoGetTextPassword)(BSTR *password);
+ STDMETHOD(CryptoGetTextPassword2)(Int32 *passwordIsDefined, BSTR *password);
+
+ void Init(bool passwordIsDefined, const UString &password)
+ {
+ _passwordIsDefined = passwordIsDefined;
+ _password = password;
+ _numFiles = 0;
+ }
+};
+
+#endif
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ViewSettings.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ViewSettings.cpp?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ViewSettings.cpp (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ViewSettings.cpp Sun Dec 16 23:23:25 2012
@@ -0,0 +1,395 @@
+// ViewSettings.h
+
+#include "StdAfx.h"
+
+#include "Common/IntToString.h"
+#include "Common/StringConvert.h"
+
+#include "ViewSettings.h"
+#include "Windows/Registry.h"
+#include "Windows/Synchronization.h"
+
+using namespace NWindows;
+using namespace NRegistry;
+
+#define REG_PATH_FM TEXT("Software") TEXT(STRING_PATH_SEPARATOR) TEXT("7-Zip") TEXT(STRING_PATH_SEPARATOR) TEXT("FM")
+
+static const TCHAR *kCUBasePath = REG_PATH_FM;
+static const TCHAR *kCulumnsKeyName = REG_PATH_FM TEXT(STRING_PATH_SEPARATOR) TEXT("Columns");
+
+static const TCHAR *kPositionValueName = TEXT("Position");
+static const TCHAR *kPanelsInfoValueName = TEXT("Panels");
+static const TCHAR *kToolbars = TEXT("Toolbars");
+
+static const WCHAR *kPanelPathValueName = L"PanelPath";
+static const TCHAR *kListMode = TEXT("ListMode");
+static const TCHAR *kFolderHistoryValueName = TEXT("FolderHistory");
+static const TCHAR *kFastFoldersValueName = TEXT("FolderShortcuts");
+static const TCHAR *kCopyHistoryValueName = TEXT("CopyHistory");
+
+/*
+class CColumnInfoSpec
+{
+ UInt32 PropID;
+ Byte IsVisible;
+ UInt32 Width;
+};
+
+struct CColumnHeader
+{
+ UInt32 Version;
+ UInt32 SortID;
+ Byte Ascending;
+};
+*/
+
+static const UInt32 kColumnInfoSpecHeader = 12;
+static const UInt32 kColumnHeaderSize = 12;
+
+static const UInt32 kColumnInfoVersion = 1;
+
+static NSynchronization::CCriticalSection g_CS;
+
+class CTempOutBufferSpec
+{
+ CByteBuffer Buffer;
+ UInt32 Size;
+ UInt32 Pos;
+public:
+ operator const Byte *() const { return (const Byte *)Buffer; }
+ void Init(UInt32 dataSize)
+ {
+ Buffer.SetCapacity(dataSize);
+ Size = dataSize;
+ Pos = 0;
+ }
+ void WriteByte(Byte value)
+ {
+ if (Pos >= Size)
+ throw "overflow";
+ ((Byte *)Buffer)[Pos++] = value;
+ }
+ void WriteUInt32(UInt32 value)
+ {
+ for (int i = 0; i < 4; i++)
+ {
+ WriteByte((Byte)value);
+ value >>= 8;
+ }
+ }
+ void WriteBool(bool value)
+ {
+ WriteUInt32(value ? 1 : 0);
+ }
+};
+
+class CTempInBufferSpec
+{
+public:
+ Byte *Buffer;
+ UInt32 Size;
+ UInt32 Pos;
+ Byte ReadByte()
+ {
+ if (Pos >= Size)
+ throw "overflow";
+ return Buffer[Pos++];
+ }
+ UInt32 ReadUInt32()
+ {
+ UInt32 value = 0;
+ for (int i = 0; i < 4; i++)
+ value |= (((UInt32)ReadByte()) << (8 * i));
+ return value;
+ }
+ bool ReadBool()
+ {
+ return (ReadUInt32() != 0);
+ }
+};
+
+void SaveListViewInfo(const UString &id, const CListViewInfo &viewInfo)
+{
+ const CObjectVector<CColumnInfo> &columns = viewInfo.Columns;
+ CTempOutBufferSpec buffer;
+ UInt32 dataSize = kColumnHeaderSize + kColumnInfoSpecHeader * columns.Size();
+ buffer.Init(dataSize);
+
+
+
+ buffer.WriteUInt32(kColumnInfoVersion);
+ buffer.WriteUInt32(viewInfo.SortID);
+ buffer.WriteBool(viewInfo.Ascending);
+
+ for(int i = 0; i < columns.Size(); i++)
+ {
+ const CColumnInfo &column = columns[i];
+ buffer.WriteUInt32(column.PropID);
+ buffer.WriteBool(column.IsVisible);
+ buffer.WriteUInt32(column.Width);
+ }
+ {
+ NSynchronization::CCriticalSectionLock lock(g_CS);
+ CKey key;
+ key.Create(HKEY_CURRENT_USER, kCulumnsKeyName);
+ key.SetValue(GetSystemString(id), (const Byte *)buffer, dataSize);
+ }
+}
+
+void ReadListViewInfo(const UString &id, CListViewInfo &viewInfo)
+{
+ viewInfo.Clear();
+ CObjectVector<CColumnInfo> &columns = viewInfo.Columns;
+ CByteBuffer buffer;
+ UInt32 size;
+ {
+ NSynchronization::CCriticalSectionLock lock(g_CS);
+ CKey key;
+ if (key.Open(HKEY_CURRENT_USER, kCulumnsKeyName, KEY_READ) != ERROR_SUCCESS)
+ return;
+ if (key.QueryValue(GetSystemString(id), buffer, size) != ERROR_SUCCESS)
+ return;
+ }
+ if (size < kColumnHeaderSize)
+ return;
+ CTempInBufferSpec inBuffer;
+ inBuffer.Size = size;
+ inBuffer.Buffer = (Byte *)buffer;
+ inBuffer.Pos = 0;
+
+
+ UInt32 version = inBuffer.ReadUInt32();
+ if (version != kColumnInfoVersion)
+ return;
+ viewInfo.SortID = inBuffer.ReadUInt32();
+ viewInfo.Ascending = inBuffer.ReadBool();
+
+ size -= kColumnHeaderSize;
+ if (size % kColumnInfoSpecHeader != 0)
+ return;
+ int numItems = size / kColumnInfoSpecHeader;
+ columns.Reserve(numItems);
+ for(int i = 0; i < numItems; i++)
+ {
+ CColumnInfo columnInfo;
+ columnInfo.PropID = inBuffer.ReadUInt32();
+ columnInfo.IsVisible = inBuffer.ReadBool();
+ columnInfo.Width = inBuffer.ReadUInt32();
+ columns.Add(columnInfo);
+ }
+}
+
+static const UInt32 kWindowPositionHeaderSize = 5 * 4;
+static const UInt32 kPanelsInfoHeaderSize = 3 * 4;
+
+/*
+struct CWindowPosition
+{
+ RECT Rect;
+ UInt32 Maximized;
+};
+
+struct CPanelsInfo
+{
+ UInt32 NumPanels;
+ UInt32 CurrentPanel;
+ UInt32 SplitterPos;
+};
+*/
+
+#ifdef _WIN32
+void SaveWindowSize(const RECT &rect, bool maximized)
+{
+ CSysString keyName = kCUBasePath;
+ NSynchronization::CCriticalSectionLock lock(g_CS);
+ CKey key;
+ key.Create(HKEY_CURRENT_USER, keyName);
+ // CWindowPosition position;
+ CTempOutBufferSpec buffer;
+ buffer.Init(kWindowPositionHeaderSize);
+ buffer.WriteUInt32(rect.left);
+ buffer.WriteUInt32(rect.top);
+ buffer.WriteUInt32(rect.right);
+ buffer.WriteUInt32(rect.bottom);
+ buffer.WriteBool(maximized);
+ key.SetValue(kPositionValueName, (const Byte *)buffer, kWindowPositionHeaderSize);
+}
+
+bool ReadWindowSize(RECT &rect, bool &maximized)
+{
+ CSysString keyName = kCUBasePath;
+ NSynchronization::CCriticalSectionLock lock(g_CS);
+ CKey key;
+ if (key.Open(HKEY_CURRENT_USER, keyName, KEY_READ) != ERROR_SUCCESS)
+ return false;
+ CByteBuffer buffer;
+ UInt32 size;
+ if (key.QueryValue(kPositionValueName, buffer, size) != ERROR_SUCCESS)
+ return false;
+ if (size != kWindowPositionHeaderSize)
+ return false;
+ CTempInBufferSpec inBuffer;
+ inBuffer.Size = size;
+ inBuffer.Buffer = (Byte *)buffer;
+ inBuffer.Pos = 0;
+ rect.left = inBuffer.ReadUInt32();
+ rect.top = inBuffer.ReadUInt32();
+ rect.right = inBuffer.ReadUInt32();
+ rect.bottom = inBuffer.ReadUInt32();
+ maximized = inBuffer.ReadBool();
+ return true;
+}
+#endif
+
+void SavePanelsInfo(UInt32 numPanels, UInt32 currentPanel, UInt32 splitterPos)
+{
+ CSysString keyName = kCUBasePath;
+ NSynchronization::CCriticalSectionLock lock(g_CS);
+ CKey key;
+ key.Create(HKEY_CURRENT_USER, keyName);
+
+ CTempOutBufferSpec buffer;
+ buffer.Init(kPanelsInfoHeaderSize);
+ buffer.WriteUInt32(numPanels);
+ buffer.WriteUInt32(currentPanel);
+ buffer.WriteUInt32(splitterPos);
+ key.SetValue(kPanelsInfoValueName, (const Byte *)buffer, kPanelsInfoHeaderSize);
+}
+
+bool ReadPanelsInfo(UInt32 &numPanels, UInt32 ¤tPanel, UInt32 &splitterPos)
+{
+ CSysString keyName = kCUBasePath;
+ NSynchronization::CCriticalSectionLock lock(g_CS);
+ CKey key;
+ if (key.Open(HKEY_CURRENT_USER, keyName, KEY_READ) != ERROR_SUCCESS)
+ return false;
+ CByteBuffer buffer;
+ UInt32 size;
+ if (key.QueryValue(kPanelsInfoValueName, buffer, size) != ERROR_SUCCESS)
+ return false;
+ if (size != kPanelsInfoHeaderSize)
+ return false;
+ CTempInBufferSpec inBuffer;
+ inBuffer.Size = size;
+ inBuffer.Buffer = (Byte *)buffer;
+ inBuffer.Pos = 0;
+ numPanels = inBuffer.ReadUInt32();
+ currentPanel = inBuffer.ReadUInt32();
+ splitterPos = inBuffer.ReadUInt32();
+ return true;
+}
+
+void SaveToolbarsMask(UInt32 toolbarMask)
+{
+ CKey key;
+ key.Create(HKEY_CURRENT_USER, kCUBasePath);
+ key.SetValue(kToolbars, toolbarMask);
+}
+
+static const UInt32 kDefaultToolbarMask = ((UInt32)1 << 31) | 8 | 4 | 1;
+
+UInt32 ReadToolbarsMask()
+{
+ CKey key;
+ if (key.Open(HKEY_CURRENT_USER, kCUBasePath, KEY_READ) != ERROR_SUCCESS)
+ return kDefaultToolbarMask;
+ UInt32 mask;
+ if (key.QueryValue(kToolbars, mask) != ERROR_SUCCESS)
+ return kDefaultToolbarMask;
+ return mask;
+}
+
+
+static UString GetPanelPathName(UInt32 panelIndex)
+{
+ WCHAR panelString[16];
+ ConvertUInt32ToString(panelIndex, panelString);
+ return UString(kPanelPathValueName) + panelString;
+}
+
+
+void SavePanelPath(UInt32 panel, const UString &path)
+{
+ NSynchronization::CCriticalSectionLock lock(g_CS);
+ CKey key;
+ key.Create(HKEY_CURRENT_USER, kCUBasePath);
+ key.SetValue(GetPanelPathName(panel), path);
+}
+
+bool ReadPanelPath(UInt32 panel, UString &path)
+{
+ NSynchronization::CCriticalSectionLock lock(g_CS);
+ CKey key;
+ if (key.Open(HKEY_CURRENT_USER, kCUBasePath, KEY_READ) != ERROR_SUCCESS)
+ return false;
+ return (key.QueryValue(GetPanelPathName(panel), path) == ERROR_SUCCESS);
+}
+
+void SaveListMode(const CListMode &listMode)
+{
+ CKey key;
+ key.Create(HKEY_CURRENT_USER, kCUBasePath);
+ UInt32 t = 0;
+ for (int i = 0; i < 2; i++)
+ t |= ((listMode.Panels[i]) & 0xFF) << (i * 8);
+ key.SetValue(kListMode, t);
+}
+
+void ReadListMode(CListMode &listMode)
+{
+ CKey key;
+ listMode.Init();
+ if (key.Open(HKEY_CURRENT_USER, kCUBasePath, KEY_READ) != ERROR_SUCCESS)
+ return;
+ UInt32 t;
+ if (key.QueryValue(kListMode, t) != ERROR_SUCCESS)
+ return;
+ for (int i = 0; i < 2; i++)
+ {
+ listMode.Panels[i] = (t & 0xFF);
+ t >>= 8;
+ }
+}
+
+
+static void SaveStringList(LPCTSTR valueName, const UStringVector &folders)
+{
+ NSynchronization::CCriticalSectionLock lock(g_CS);
+ CKey key;
+ key.Create(HKEY_CURRENT_USER, kCUBasePath);
+ key.SetValue_Strings(valueName, folders);
+}
+
+static void ReadStringList(LPCTSTR valueName, UStringVector &folders)
+{
+ folders.Clear();
+ NSynchronization::CCriticalSectionLock lock(g_CS);
+ CKey key;
+ if (key.Open(HKEY_CURRENT_USER, kCUBasePath, KEY_READ) == ERROR_SUCCESS)
+ key.GetValue_Strings(valueName, folders);
+}
+
+void SaveFolderHistory(const UStringVector &folders)
+ { SaveStringList(kFolderHistoryValueName, folders); }
+void ReadFolderHistory(UStringVector &folders)
+ { ReadStringList(kFolderHistoryValueName, folders); }
+
+void SaveFastFolders(const UStringVector &folders)
+ { SaveStringList(kFastFoldersValueName, folders); }
+void ReadFastFolders(UStringVector &folders)
+ { ReadStringList(kFastFoldersValueName, folders); }
+
+void SaveCopyHistory(const UStringVector &folders)
+ { SaveStringList(kCopyHistoryValueName, folders); }
+void ReadCopyHistory(UStringVector &folders)
+ { ReadStringList(kCopyHistoryValueName, folders); }
+
+void AddUniqueStringToHeadOfList(UStringVector &list, const UString &s)
+{
+ for (int i = 0; i < list.Size();)
+ if (s.CompareNoCase(list[i]) == 0)
+ list.Delete(i);
+ else
+ i++;
+ list.Insert(0, s);
+}
Added: test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ViewSettings.h
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ViewSettings.h?rev=170306&view=auto
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ViewSettings.h (added)
+++ test-suite/trunk/MultiSource/Benchmarks/7zip/CPP/7zip/UI/FileManager/ViewSettings.h Sun Dec 16 23:23:25 2012
@@ -0,0 +1,100 @@
+// ViewSettings.h
+
+#ifndef __VIEW_SETTINGS_H
+#define __VIEW_SETTINGS_H
+
+#include "Common/MyString.h"
+#include "Common/Types.h"
+
+struct CColumnInfo
+{
+ PROPID PropID;
+ bool IsVisible;
+ UInt32 Width;
+};
+
+inline bool operator==(const CColumnInfo &a1, const CColumnInfo &a2)
+{
+ return (a1.PropID == a2.PropID) &&
+ (a1.IsVisible == a2.IsVisible) && (a1.Width == a2.Width);
+}
+
+inline bool operator!=(const CColumnInfo &a1, const CColumnInfo &a2)
+{
+ return !(a1 == a2);
+}
+
+struct CListViewInfo
+{
+ CObjectVector<CColumnInfo> Columns;
+ PROPID SortID;
+ bool Ascending;
+
+ void Clear()
+ {
+ SortID = 0;
+ Ascending = true;
+ Columns.Clear();
+ }
+
+ int FindColumnWithID(PROPID propID) const
+ {
+ for (int i = 0; i < Columns.Size(); i++)
+ if (Columns[i].PropID == propID)
+ return i;
+ return -1;
+ }
+
+ bool IsEqual(const CListViewInfo &info) const
+ {
+ if (Columns.Size() != info.Columns.Size() ||
+ // SortIndex != info.SortIndex ||
+ SortID != info.SortID ||
+ Ascending != info.Ascending)
+ return false;
+ for (int i = 0; i < Columns.Size(); i++)
+ if (Columns[i] != info.Columns[i])
+ return false;
+ return true;
+ }
+};
+
+void SaveListViewInfo(const UString &id, const CListViewInfo &viewInfo);
+void ReadListViewInfo(const UString &id, CListViewInfo &viewInfo);
+
+#ifdef _WIN32
+void SaveWindowSize(const RECT &rect, bool maximized);
+bool ReadWindowSize(RECT &rect, bool &maximized);
+#endif
+
+void SavePanelsInfo(UInt32 numPanels, UInt32 currentPanel, UInt32 splitterPos);
+bool ReadPanelsInfo(UInt32 &numPanels, UInt32 ¤tPanel, UInt32 &splitterPos);
+
+void SaveToolbarsMask(UInt32 toolbarMask);
+UInt32 ReadToolbarsMask();
+
+void SavePanelPath(UInt32 panel, const UString &path);
+bool ReadPanelPath(UInt32 panel, UString &path);
+
+struct CListMode
+{
+ UInt32 Panels[2];
+ void Init() { Panels[0] = Panels[1] = 3; }
+ CListMode() { Init(); }
+};
+
+void SaveListMode(const CListMode &listMode);
+void ReadListMode(CListMode &listMode);
+
+void SaveFolderHistory(const UStringVector &folders);
+void ReadFolderHistory(UStringVector &folders);
+
+void SaveFastFolders(const UStringVector &folders);
+void ReadFastFolders(UStringVector &folders);
+
+void SaveCopyHistory(const UStringVector &folders);
+void ReadCopyHistory(UStringVector &folders);
+
+void AddUniqueStringToHeadOfList(UStringVector &list, const UString &s);
+
+#endif
More information about the llvm-commits
mailing list