本文整理汇总了C++中UStringVector::FindInSorted方法的典型用法代码示例。如果您正苦于以下问题:C++ UStringVector::FindInSorted方法的具体用法?C++ UStringVector::FindInSorted怎么用?C++ UStringVector::FindInSorted使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UStringVector
的用法示例。
在下文中一共展示了UStringVector::FindInSorted方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DecompressArchives
HRESULT DecompressArchives(
UStringVector &archivePaths, UStringVector &archivePathsFull,
const NWildcard::CCensorNode &wildcardCensor,
const CExtractOptions &optionsSpec,
IOpenCallbackUI *openCallback,
IExtractCallbackUI *extractCallback)
{
CExtractOptions options = optionsSpec;
for (int i = 0; i < archivePaths.Size(); i++)
{
const UString &archivePath = archivePaths[i];
NFile::NFind::CFileInfoW archiveFileInfo;
if (!NFile::NFind::FindFile(archivePath, archiveFileInfo))
throw "there is no such archive";
if (archiveFileInfo.IsDirectory())
throw "there is no such archive";
options.ArchiveFileInfo = archiveFileInfo;
RINOK(extractCallback->BeforeOpen(archivePath));
CArchiveLink archiveLink;
HRESULT result = MyOpenArchive(archivePath, archiveLink, openCallback);
RINOK(extractCallback->OpenResult(archivePath, result));
if (result != S_OK)
continue;
for (int v = 0; v < archiveLink.VolumePaths.Size(); v++)
{
int index = archivePathsFull.FindInSorted(archiveLink.VolumePaths[v]);
if (index >= 0 && index > i)
{
archivePaths.Delete(index);
archivePathsFull.Delete(index);
}
}
#ifndef _NO_CRYPTO
UString password;
RINOK(openCallback->GetPasswordIfAny(password));
if (!password.IsEmpty())
{
RINOK(extractCallback->SetPassword(password));
}
#endif
options.DefaultItemName = archiveLink.GetDefaultItemName();
RINOK(DecompressArchive(
archiveLink.GetArchive(), archiveLink.GetDefaultItemName(),
wildcardCensor, options, extractCallback));
}
return S_OK;
}
示例2: RefreshListCtrl
//.........这里部分代码省略.........
nameLen = itemName.Len();
}
bool selected = false;
if (!focusedName.IsEmpty() || !selectedNames.IsEmpty())
{
relPath.Empty();
// relPath += GetItemPrefix(i);
// change it (_flatMode)
if (i != kParentIndex && _flatMode)
{
const wchar_t *prefix = NULL;
if (_folderGetItemName)
{
unsigned prefixLen = 0;
_folderGetItemName->GetItemPrefix(i, &prefix, &prefixLen);
if (prefix)
relPath += prefix;
}
if (!prefix)
{
NCOM::CPropVariant prop;
if (_folder->GetProperty(i, kpidPrefix, &prop) != S_OK)
throw 2723400;
if (prop.vt == VT_BSTR)
relPath += prop.bstrVal;
}
}
relPath += name;
if (relPath == focusedName)
cursorIndex = listViewItemCount;
if (selectedNames.FindInSorted(relPath) >= 0)
selected = true;
}
_selectedStatusVector.AddInReserved(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 = listViewItemCount;
item.iSubItem = subItem++;
item.lParam = i;
/*
int finish = nameLen - 4;
int j;
for (j = 0; j < finish; j++)
{
if (name[j ] == ' ' &&
name[j + 1] == ' ' &&
name[j + 2] == ' ' &&
name[j + 3] == ' ' &&
name[j + 4] == ' ')
break;
}
示例3: DecompressArchives
HRESULT DecompressArchives(
CCodecs *codecs, const CIntVector &formatIndices,
UStringVector &archivePaths, UStringVector &archivePathsFull,
const NWildcard::CCensorNode &wildcardCensor,
const CExtractOptions &optionsSpec,
IOpenCallbackUI *openCallback,
IExtractCallbackUI *extractCallback,
UString &errorMessage,
CDecompressStat &stat)
{
stat.Clear();
CExtractOptions options = optionsSpec;
int i;
UInt64 totalPackSize = 0;
CRecordVector<UInt64> archiveSizes;
for (i = 0; i < archivePaths.Size(); i++)
{
const UString &archivePath = archivePaths[i];
NFile::NFind::CFileInfoW fi;
if (!NFile::NFind::FindFile(archivePath, fi))
throw "there is no such archive";
if (fi.IsDir())
throw "can't decompress folder";
archiveSizes.Add(fi.Size);
totalPackSize += fi.Size;
}
CArchiveExtractCallback *extractCallbackSpec = new CArchiveExtractCallback;
CMyComPtr<IArchiveExtractCallback> ec(extractCallbackSpec);
bool multi = (archivePaths.Size() > 1);
extractCallbackSpec->InitForMulti(multi, options.PathMode, options.OverwriteMode);
if (multi)
{
RINOK(extractCallback->SetTotal(totalPackSize));
}
for (i = 0; i < archivePaths.Size(); i++)
{
const UString &archivePath = archivePaths[i];
NFile::NFind::CFileInfoW fi;
if (!NFile::NFind::FindFile(archivePath, fi))
throw "there is no such archive";
if (fi.IsDir())
throw "there is no such archive";
options.ArchiveFileInfo = fi;
#ifndef _NO_CRYPTO
openCallback->Open_ClearPasswordWasAskedFlag();
#endif
RINOK(extractCallback->BeforeOpen(archivePath));
CArchiveLink archiveLink;
CIntVector formatIndices2 = formatIndices;
#ifndef _SFX
if (formatIndices.IsEmpty())
{
int pos = archivePath.ReverseFind(L'.');
if (pos >= 0)
{
UString s = archivePath.Mid(pos + 1);
int index = codecs->FindFormatForExtension(s);
if (index >= 0 && s == L"001")
{
s = archivePath.Left(pos);
pos = s.ReverseFind(L'.');
if (pos >= 0)
{
int index2 = codecs->FindFormatForExtension(s.Mid(pos + 1));
if (index2 >= 0 && s.CompareNoCase(L"rar") != 0)
{
formatIndices2.Add(index2);
formatIndices2.Add(index);
}
}
}
}
}
#endif
HRESULT result = MyOpenArchive(codecs, formatIndices2, archivePath, archiveLink, openCallback);
if (result == E_ABORT)
return result;
bool crypted = false;
#ifndef _NO_CRYPTO
crypted = openCallback->Open_WasPasswordAsked();
#endif
RINOK(extractCallback->OpenResult(archivePath, result, crypted));
if (result != S_OK)
continue;
for (int v = 0; v < archiveLink.VolumePaths.Size(); v++)
{
int index = archivePathsFull.FindInSorted(archiveLink.VolumePaths[v]);
if (index >= 0 && index > i)
{
archivePaths.Delete(index);
archivePathsFull.Delete(index);
totalPackSize -= archiveSizes[index];
//.........这里部分代码省略.........
示例4: ListArchives
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++)
//.........这里部分代码省略.........
示例5: ListArchives
HRESULT ListArchives(
CCodecs *codecs,
UStringVector &archivePaths, UStringVector &archivePathsFull,
const NWildcard::CCensorNode &wildcardCensor,
bool enableHeaders, bool techMode, bool &passwordEnabled, UString &password, 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;
for (int i = 0; i < archivePaths.Size(); i++)
{
const UString &archiveName = archivePaths[i];
NFile::NFind::CFileInfoW archiveFileInfo;
if (!NFile::NFind::FindFile(archiveName, archiveFileInfo) || archiveFileInfo.IsDirectory())
{
g_StdOut << endl << "Error: " << archiveName << " is not archive" << endl;
numErrors++;
continue;
}
if (archiveFileInfo.IsDirectory())
{
g_StdOut << endl << "Error: " << archiveName << " is not file" << endl;
numErrors++;
continue;
}
CArchiveLink archiveLink;
COpenCallbackConsole openCallback;
openCallback.OutStream = &g_StdOut;
openCallback.PasswordIsDefined = passwordEnabled;
openCallback.Password = password;
HRESULT result = MyOpenArchive(codecs, archiveName, archiveLink, &openCallback);
if (result != S_OK)
{
g_StdOut << endl << "Error: " << archiveName << " is not supported archive" << endl;
numErrors++;
continue;
}
for (int v = 0; v < archiveLink.VolumePaths.Size(); v++)
{
int index = archivePathsFull.FindInSorted(archiveLink.VolumePaths[v]);
if (index >= 0 && index > i)
{
archivePaths.Delete(index);
archivePathsFull.Delete(index);
}
}
IInArchive *archive = archiveLink.GetArchive();
const UString defaultItemName = archiveLink.GetDefaultItemName();
if (enableHeaders)
{
g_StdOut << endl << kListing << archiveName << endl << endl;
UInt32 numProps;
if (archive->GetNumberOfArchiveProperties(&numProps) == S_OK)
{
for (UInt32 i = 0; i < numProps; i++)
{
CMyComBSTR name;
PROPID propID;
VARTYPE vt;
if (archive->GetArchivePropertyInfo(i, &name, &propID, &vt) != S_OK)
continue;
NCOM::CPropVariant prop;
if (archive->GetArchiveProperty(propID, &prop) != S_OK)
continue;
UString s = ConvertPropertyToString(prop, propID);
if (!s.IsEmpty())
g_StdOut << GetPropName(propID, name) << " = " << s << endl;
}
}
if (techMode)
g_StdOut << "----------\n";
if (numProps > 0)
g_StdOut << endl;
}
if (enableHeaders && !techMode)
{
fieldPrinter.PrintTitle();
g_StdOut << endl;
fieldPrinter.PrintTitleLines();
g_StdOut << endl;
}
if (techMode)
{
RINOK(fieldPrinter.Init(archive));
}
UInt64 numFiles = 0, numDirs = 0, totalPackSize = 0, totalUnPackSize = 0;
UInt64 *totalPackSizePointer = 0, *totalUnPackSizePointer = 0;
//.........这里部分代码省略.........
示例6: ExplodeArchives
// Create a new 7z archive for each folder contained in the archive to be
// exploded.
HRESULT ExplodeArchives(CCodecs *codecs, const CIntVector &formatIndices,
bool stdInMode,
UStringVector &arcPaths, UStringVector &arcPathsFull,
UString& outputPath, UInt64 maxDepth, UInt64 &numErrors)
{
int numArcs = arcPaths.Size();
for (int i = 0; i < numArcs; i++)
{
UString archivePath = arcPaths[i];
/*UString outputPath = arcPaths[i];
outputPath.Replace(L'\\', L'/'); // linux and windows consistent
const UString archiveName = StripFile(outputPath);
outputPath.Empty();*/
archivePath.Replace(L'\\', L'/'); // linux, windows and archive consistent
outputPath.Replace(L'\\', L'/');
FixPathFormat(outputPath);
const UString archiveName = GetFileFromPath(archivePath);
g_StdOut << "Outputting into : " << outputPath << endl;
UInt64 arcPackSize = 0;
if (!stdInMode)
{
NFile::NFind::CFileInfoW fi;
if (!fi.Find(archivePath) || fi.IsDir())
{
SHOW_ERROR("is not a file.");
continue;
}
arcPackSize = fi.Size;
}
g_StdOut << endl << "Exploding : " << archivePath << endl << endl;
CArchiveLink archiveLink;
COpenCallbackConsole openCallback;
openCallback.OutStream = &g_StdOut;
#ifndef _NO_CRYPTO
openCallback.PasswordIsDefined = false;
#endif
HRESULT result = archiveLink.Open2(codecs, formatIndices, stdInMode, NULL, archivePath, &openCallback);
if (result != S_OK)
{
if (result == E_ABORT)
return result;
g_StdOut << endl << "Error: " << archivePath << ": ";
if (result == S_FALSE)
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;
}
// remove other files names if multi-volume
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();
}
}
}
// don't support multi volume because i have to reopen the stream
if (archiveLink.VolumePaths.Size() != 1) {
SHOW_ERROR("Exploding multi-volume archives isn't supported.");
continue;
}
bool szArchive = true;
for (int x = 0; x < archiveLink.Arcs.Size(); x++)
{
const UString szName = L"7z";
const CArc &arc = archiveLink.Arcs[x];
if (codecs->Formats[arc.FormatIndex].Name != szName) {
szArchive = false;
break;
}
}
if (!szArchive) {
SHOW_ERROR("Only 7z archives can be exploded.");
continue;
}
//.........这里部分代码省略.........
示例7: RefreshListCtrl
HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool selectFocused,
const UStringVector &selectedNames)
{
_dontShowMode = false;
LoadFullPathAndShow();
// OutputDebugStringA("=======\n");
// OutputDebugStringA("s1 \n");
CDisableTimerProcessing timerProcessing(*this);
if (focusedPos < 0)
focusedPos = 0;
_listView.SetRedraw(false);
// m_RedrawEnabled = false;
LVITEMW item;
ZeroMemory(&item, sizeof(item));
_listView.DeleteAllItems();
_selectedStatusVector.Clear();
// _realIndices.Clear();
_startGroupSelect = 0;
_selectionIsDefined = false;
// m_Files.Clear();
// _folder.Release();
if (!_folder)
{
// throw 1;
SetToRootFolder();
}
_headerToolBar.EnableButton(kParentFolderID, !IsRootFolder());
CMyComPtr<IFolderSetFlatMode> folderSetFlatMode;
_folder.QueryInterface(IID_IFolderSetFlatMode, &folderSetFlatMode);
if (folderSetFlatMode)
folderSetFlatMode->SetFlatMode(BoolToInt(_flatMode));
RINOK(_folder->LoadItems());
RINOK(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 = const_cast<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 E_FAIL;
}
// 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;
}
//.........这里部分代码省略.........
示例8: DecompressArchives
//.........这里部分代码省略.........
int pos = arcPath.ReverseFind(L'.');
if (pos >= 0)
{
UString s = arcPath.Mid(pos + 1);
int index = codecs->FindFormatForExtension(s);
if (index >= 0 && s == L"001")
{
s = arcPath.Left(pos);
pos = s.ReverseFind(L'.');
if (pos >= 0)
{
int index2 = codecs->FindFormatForExtension(s.Mid(pos + 1));
if (index2 >= 0 && s.CompareNoCase(L"rar") != 0)
{
formatIndices2.Add(index2);
formatIndices2.Add(index);
}
}
}
}
}
#endif
HRESULT result = archiveLink.Open2(codecs, formatIndices2, options.StdInMode, NULL, arcPath, openCallback);
if (result == E_ABORT)
return result;
bool crypted = false;
#ifndef _NO_CRYPTO
crypted = openCallback->Open_WasPasswordAsked();
/* if(!crypted) {
fprintf(stderr, "%s is not encrypted!\n", "123");
exit(0);
} */
#endif
RINOK(extractCallback->OpenResult(arcPath, result, crypted));
if (result != S_OK)
continue;
if (!options.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);
totalPackSize -= archiveSizes[index];
archiveSizes.Delete(index);
numArcs = arcPaths.Size();
}
}
if (archiveLink.VolumePaths.Size() != 0)
{
totalPackSize += archiveLink.VolumesSize;
RINOK(extractCallback->SetTotal(totalPackSize));
}
#ifndef _NO_CRYPTO
UString password;
RINOK(openCallback->Open_GetPasswordIfAny(password));
if (!password.IsEmpty())
{
RINOK(extractCallback->SetPassword(password));
}
#endif
for (int v = 0; v < archiveLink.Arcs.Size(); v++)
{
const UString &s = archiveLink.Arcs[v].ErrorMessage;
if (!s.IsEmpty())
{
RINOK(extractCallback->MessageError(s));
}
}
CArc &arc = archiveLink.Arcs.Back();
arc.MTimeDefined = (!options.StdInMode && !fi.IsDevice);
arc.MTime = fi.MTime;
UInt64 packProcessed;
RINOK(DecompressArchive(arc,
fi.Size + archiveLink.VolumesSize,
wildcardCensor, options, extractCallback, extractCallbackSpec, errorMessage, packProcessed));
if (!options.StdInMode)
packProcessed = fi.Size + archiveLink.VolumesSize;
extractCallbackSpec->LocalProgressSpec->InSize += packProcessed;
extractCallbackSpec->LocalProgressSpec->OutSize = extractCallbackSpec->UnpackSize;
if (!errorMessage.IsEmpty())
return E_FAIL;
}
stat.NumFolders = extractCallbackSpec->NumFolders;
stat.NumFiles = extractCallbackSpec->NumFiles;
stat.UnpackSize = extractCallbackSpec->UnpackSize;
stat.CrcSum = extractCallbackSpec->CrcSum;
stat.NumArchives = arcPaths.Size();
stat.PackSize = extractCallbackSpec->LocalProgressSpec->InSize;
return S_OK;
}