本文整理汇总了C++中nfind::CFileInfoW::IsDir方法的典型用法代码示例。如果您正苦于以下问题:C++ CFileInfoW::IsDir方法的具体用法?C++ CFileInfoW::IsDir怎么用?C++ CFileInfoW::IsDir使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nfind::CFileInfoW
的用法示例。
在下文中一共展示了CFileInfoW::IsDir方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetBaseFolderPrefixFromRegistry
CSysString GetBaseFolderPrefixFromRegistry()
{
CSysString moduleFolderPrefix = GetLibraryFolderPrefix();
#ifdef _UNICODE
NFind::CFileInfoW fi;
#else
NFind::CFileInfo fi;
#endif
if (NFind::FindFile(moduleFolderPrefix + kMainDll, fi))
if (!fi.IsDir())
return moduleFolderPrefix;
if (NFind::FindFile(moduleFolderPrefix + kCodecsFolderName, fi))
if (fi.IsDir())
return moduleFolderPrefix;
if (NFind::FindFile(moduleFolderPrefix + kFormatsFolderName, fi))
if (fi.IsDir())
return moduleFolderPrefix;
#ifdef _WIN32
CSysString path;
if (ReadPathFromRegistry(HKEY_CURRENT_USER, path))
return path;
if (ReadPathFromRegistry(HKEY_LOCAL_MACHINE, path))
return path;
#endif
return moduleFolderPrefix;
}
示例2: ReadPluginInfoList
void ReadPluginInfoList(CObjectVector<CPluginInfo> &plugins)
{
plugins.Clear();
UString baseFolderPrefix;
GetProgramFolderPath(baseFolderPrefix);
{
CPluginInfo pluginInfo;
pluginInfo.FilePath = baseFolderPrefix + L"7-zip.dll";
if (::ReadPluginInfo(pluginInfo, false))
plugins.Add(pluginInfo);
}
UString folderPath = baseFolderPrefix + L"Plugins" WSTRING_PATH_SEPARATOR;
NFind::CEnumeratorW enumerator(folderPath + L"*");
NFind::CFileInfoW fileInfo;
while (enumerator.Next(fileInfo))
{
if (fileInfo.IsDir())
continue;
CPluginInfo pluginInfo;
pluginInfo.FilePath = folderPath + fileInfo.Name;
if (::ReadPluginInfo(pluginInfo, true))
plugins.Add(pluginInfo);
}
}
示例3: EnumerateDirectory
void CDirItems::EnumerateDirectory(int phyParent, int logParent, const UString &phyPrefix,
UStringVector &errorPaths, CRecordVector<DWORD> &errorCodes)
{
NFind::CEnumeratorW enumerator(phyPrefix + (wchar_t)kAnyStringWildcard);
for (;;)
{
NFind::CFileInfoW fi;
bool found;
if (!enumerator.Next(fi, found))
{
errorCodes.Add(::GetLastError());
errorPaths.Add(phyPrefix);
return;
}
if (!found)
break;
AddDirFileInfo(phyParent, logParent, fi, Items);
if (fi.IsDir())
{
const UString name2 = fi.Name + (wchar_t)kDirDelimiter;
int parent = AddPrefix(phyParent, logParent, name2);
EnumerateDirectory(parent, parent, phyPrefix + name2, errorPaths, errorCodes);
}
}
}
示例4: AddPrefix
void CDirItems::EnumerateDirItems2(const UString &phyPrefix, const UString &logPrefix,
const UStringVector &filePaths, UStringVector &errorPaths, CRecordVector<DWORD> &errorCodes)
{
int phyParent = phyPrefix.IsEmpty() ? -1 : AddPrefix(-1, -1, phyPrefix);
int logParent = logPrefix.IsEmpty() ? -1 : AddPrefix(-1, -1, logPrefix);
for (int i = 0; i < filePaths.Size(); i++)
{
const UString &filePath = filePaths[i];
NFind::CFileInfoW fi;
const UString phyPath = phyPrefix + filePath;
if (!fi.Find(phyPath))
{
errorCodes.Add(::GetLastError());
errorPaths.Add(phyPath);
continue;
}
int delimiter = filePath.ReverseFind((wchar_t)kDirDelimiter);
UString phyPrefixCur;
int phyParentCur = phyParent;
if (delimiter >= 0)
{
phyPrefixCur = filePath.Left(delimiter + 1);
phyParentCur = AddPrefix(phyParent, logParent, phyPrefixCur);
}
AddDirFileInfo(phyParentCur, logParent, fi, Items);
if (fi.IsDir())
{
const UString name2 = fi.Name + (wchar_t)kDirDelimiter;
int parent = AddPrefix(phyParentCur, logParent, name2);
EnumerateDirectory(parent, parent, phyPrefix + phyPrefixCur + name2, errorPaths, errorCodes);
}
}
ReserveDown();
}
示例5: GetNextFile
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(WCHAR_PATH_SEPARATOR);
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;
}
示例6: Main2
int Main2(
#ifndef _WIN32
int numArguments, const char *arguments[]
#endif
)
{
#ifdef _WIN32
SetFileApisToOEM();
#endif
g_StdOut << kCopyrightString;
UStringVector commandStrings;
#ifdef _WIN32
NCommandLineParser::SplitCommandLine(GetCommandLineW(), commandStrings);
#else
GetArguments(numArguments, arguments, commandStrings);
#endif
UString archiveName = commandStrings.Front();
commandStrings.Delete(0);
NCommandLineParser::CParser parser(kNumSwitches);
try
{
parser.ParseStrings(kSwitchForms, commandStrings);
}
catch(...)
{
PrintHelpAndExit();
}
if(parser[NKey::kHelp1].ThereIs || parser[NKey::kHelp2].ThereIs)
{
PrintHelp();
return 0;
}
const UStringVector &nonSwitchStrings = parser.NonSwitchStrings;
int numNonSwitchStrings = nonSwitchStrings.Size();
CArchiveCommand command;
if (numNonSwitchStrings == 0)
command.CommandType = NCommandType::kFullExtract;
else
{
if (numNonSwitchStrings > 1)
PrintHelpAndExit();
if (!ParseArchiveCommand(nonSwitchStrings[kCommandIndex], command))
PrintHelpAndExit();
}
NRecursedType::EEnum recursedType;
recursedType = command.DefaultRecursedType();
NWildcard::CCensor wildcardCensor;
bool thereAreSwitchIncludeWildCards;
thereAreSwitchIncludeWildCards = false;
AddToCensorFromNonSwitchesStrings(wildcardCensor, nonSwitchStrings, recursedType,
thereAreSwitchIncludeWildCards);
bool yesToAll = parser[NKey::kYes].ThereIs;
#ifdef _WIN32
if (archiveName.Right(kDefaultExtLength).CompareNoCase(kDefaultExt) != 0)
archiveName += kDefaultExt;
#endif
// NExtractMode::EEnum extractMode;
// bool isExtractGroupCommand = command.IsFromExtractGroup(extractMode);
bool passwordEnabled = parser[NKey::kPassword].ThereIs;
UString password;
if(passwordEnabled)
password = parser[NKey::kPassword].PostStrings[0];
NFind::CFileInfoW archiveFileInfo;
if (!NFind::FindFile(archiveName, archiveFileInfo))
throw kCantFindSFX;
if (archiveFileInfo.IsDir())
throw kCantFindSFX;
UString outputDir;
if(parser[NKey::kOutputDir].ThereIs)
{
outputDir = parser[NKey::kOutputDir].PostStrings[0];
NName::NormalizeDirPathPrefix(outputDir);
}
{
UStringVector v1, v2;
v1.Add(archiveName);
v2.Add(archiveName);
const NWildcard::CCensorNode &wildcardCensorHead =
wildcardCensor.Pairs.Front().Head;
//.........这里部分代码省略.........
示例7: EnumerateDirItems
static HRESULT EnumerateDirItems(const NWildcard::CCensorNode &curNode,
int phyParent, int logParent, const UString &phyPrefix,
const UStringVector &addArchivePrefix, // prefix from curNode
CDirItems &dirItems,
bool enterToSubFolders,
IEnumDirItemCallback *callback,
UStringVector &errorPaths,
CRecordVector<DWORD> &errorCodes)
{
if (!enterToSubFolders)
if (curNode.NeedCheckSubDirs())
enterToSubFolders = true;
if (callback)
RINOK(callback->ScanProgress(dirItems.GetNumFolders(), dirItems.Items.Size(), phyPrefix));
// try direct_names case at first
if (addArchivePrefix.IsEmpty() && !enterToSubFolders)
{
// check that all names are direct
int i;
for (i = 0; i < curNode.IncludeItems.Size(); i++)
{
const NWildcard::CItem &item = curNode.IncludeItems[i];
if (item.Recursive || item.PathParts.Size() != 1)
break;
const UString &name = item.PathParts.Front();
if (name.IsEmpty() || DoesNameContainWildCard(name))
break;
}
if (i == curNode.IncludeItems.Size())
{
// all names are direct (no wildcards)
// so we don't need file_system's dir enumerator
CRecordVector<bool> needEnterVector;
for (i = 0; i < curNode.IncludeItems.Size(); i++)
{
const NWildcard::CItem &item = curNode.IncludeItems[i];
const UString &name = item.PathParts.Front();
const UString fullPath = phyPrefix + name;
NFind::CFileInfoW fi;
if (!fi.Find(fullPath))
{
errorCodes.Add(::GetLastError());
errorPaths.Add(fullPath);
continue;
}
bool isDir = fi.IsDir();
if (isDir && !item.ForDir || !isDir && !item.ForFile)
{
errorCodes.Add((DWORD)E_FAIL);
errorPaths.Add(fullPath);
continue;
}
{
UStringVector pathParts;
pathParts.Add(fi.Name);
if (curNode.CheckPathToRoot(false, pathParts, !isDir))
continue;
}
AddDirFileInfo(phyParent, logParent, fi, dirItems.Items);
if (!isDir)
continue;
UStringVector addArchivePrefixNew;
const NWildcard::CCensorNode *nextNode = 0;
int index = curNode.FindSubNode(name);
if (index >= 0)
{
for (int t = needEnterVector.Size(); t <= index; t++)
needEnterVector.Add(true);
needEnterVector[index] = false;
nextNode = &curNode.SubNodes[index];
}
else
{
nextNode = &curNode;
addArchivePrefixNew.Add(name); // don't change it to fi.Name. It's for shortnames support
}
RINOK(EnumerateDirItems_Spec(*nextNode, phyParent, logParent, fi.Name, phyPrefix,
addArchivePrefixNew, dirItems, true, callback, errorPaths, errorCodes));
}
for (i = 0; i < curNode.SubNodes.Size(); i++)
{
if (i < needEnterVector.Size())
if (!needEnterVector[i])
continue;
const NWildcard::CCensorNode &nextNode = curNode.SubNodes[i];
const UString fullPath = phyPrefix + nextNode.Name;
NFind::CFileInfoW fi;
if (!fi.Find(fullPath))
{
if (!nextNode.AreThereIncludeItems())
continue;
errorCodes.Add(::GetLastError());
errorPaths.Add(fullPath);
continue;
}
if (!fi.IsDir())
{
//.........这里部分代码省略.........
示例8: ShowDialog
static HRESULT ShowDialog(
CCodecs *codecs,
const NWildcard::CCensor &censor,
CUpdateOptions &options, CUpdateCallbackGUI *callback, HWND hwndParent)
{
if (options.Commands.Size() != 1)
throw "It must be one command";
UString currentDirPrefix;
#ifndef UNDER_CE
{
if (!NDirectory::MyGetCurrentDirectory(currentDirPrefix))
return E_FAIL;
NName::NormalizeDirPathPrefix(currentDirPrefix);
}
#endif
bool oneFile = false;
NFind::CFileInfoW fileInfo;
UString name;
if (censor.Pairs.Size() > 0)
{
const NWildcard::CPair &pair = censor.Pairs[0];
if (pair.Head.IncludeItems.Size() > 0)
{
const NWildcard::CItem &item = pair.Head.IncludeItems[0];
if (item.ForFile)
{
name = pair.Prefix;
for (int i = 0; i < item.PathParts.Size(); i++)
{
if (i > 0)
name += WCHAR_PATH_SEPARATOR;
name += item.PathParts[i];
}
if (fileInfo.Find(name))
{
if (censor.Pairs.Size() == 1 && pair.Head.IncludeItems.Size() == 1)
oneFile = !fileInfo.IsDir();
}
}
}
}
CCompressDialog dialog;
NCompressDialog::CInfo &di = dialog.Info;
dialog.ArcFormats = &codecs->Formats;
for (int i = 0; i < codecs->Formats.Size(); i++)
{
const CArcInfoEx &ai = codecs->Formats[i];
if (ai.Name.CompareNoCase(L"swfc") == 0)
if (!oneFile || name.Right(4).CompareNoCase(L".swf") != 0)
continue;
if (ai.UpdateEnabled && (oneFile || !ai.KeepName))
dialog.ArcIndices.Add(i);
}
if (dialog.ArcIndices.Size() == 0)
{
ShowErrorMessage(L"No Update Engines");
return E_FAIL;
}
// di.ArchiveName = options.ArchivePath.GetFinalPath();
di.ArchiveName = options.ArchivePath.GetPathWithoutExt();
dialog.OriginalFileName = options.ArchivePath.Prefix + fileInfo.Name;
di.CurrentDirPrefix = currentDirPrefix;
di.SFXMode = options.SfxMode;
di.OpenShareForWrite = options.OpenShareForWrite;
if (callback->PasswordIsDefined)
di.Password = callback->Password;
di.KeepName = !oneFile;
if (dialog.Create(hwndParent) != IDOK)
return E_ABORT;
options.VolumesSizes = di.VolumeSizes;
/*
if (di.VolumeSizeIsDefined)
{
MyMessageBox(L"Splitting to volumes is not supported");
return E_FAIL;
}
*/
NUpdateArchive::CActionSet &actionSet = options.Commands.Front().ActionSet;
switch(di.UpdateMode)
{
case NCompressDialog::NUpdateMode::kAdd:
actionSet = NUpdateArchive::kAddActionSet;
break;
case NCompressDialog::NUpdateMode::kUpdate:
actionSet = NUpdateArchive::kUpdateActionSet;
break;
case NCompressDialog::NUpdateMode::kFresh:
actionSet = NUpdateArchive::kFreshActionSet;
break;
case NCompressDialog::NUpdateMode::kSynchronize:
//.........这里部分代码省略.........