本文整理汇总了C++中nfind::CFileInfo::IsDir方法的典型用法代码示例。如果您正苦于以下问题:C++ CFileInfo::IsDir方法的具体用法?C++ CFileInfo::IsDir怎么用?C++ CFileInfo::IsDir使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nfind::CFileInfo
的用法示例。
在下文中一共展示了CFileInfo::IsDir方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EnumerateDirectory
void CDirItems::EnumerateDirectory(int phyParent, int logParent, const FString &phyPrefix,
FStringVector &errorPaths, CRecordVector<DWORD> &errorCodes)
{
NFind::CEnumerator enumerator(phyPrefix + FCHAR_ANY_MASK);
for (;;)
{
NFind::CFileInfo 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 FString name2 = fi.Name + FCHAR_PATH_SEPARATOR;
int parent = AddPrefix(phyParent, logParent, fs2us(name2));
EnumerateDirectory(parent, parent, phyPrefix + name2, errorPaths, errorCodes);
}
}
}
示例2: EnumerateDir
void CDirItems::EnumerateDir(int phyParent, int logParent, const FString &phyPrefix)
{
NFind::CEnumerator enumerator(phyPrefix + FCHAR_ANY_MASK);
for (;;)
{
NFind::CFileInfo fi;
bool found;
if (!enumerator.Next(fi, found))
{
AddError(phyPrefix);
return;
}
if (!found)
break;
int secureIndex = -1;
#ifdef _USE_SECURITY_CODE
if (ReadSecure)
AddSecurityItem(phyPrefix + fi.Name, secureIndex);
#endif
AddDirFileInfo(phyParent, logParent, secureIndex, fi, Items);
if (fi.IsDir())
{
const FString name2 = fi.Name + FCHAR_PATH_SEPARATOR;
unsigned parent = AddPrefix(phyParent, logParent, fs2us(name2));
EnumerateDir(parent, parent, phyPrefix + name2);
}
}
}
示例3: AddPrefix
void CDirItems::EnumerateDirItems2(const FString &phyPrefix, const UString &logPrefix,
const FStringVector &filePaths, FStringVector &errorPaths, CRecordVector<DWORD> &errorCodes)
{
int phyParent = phyPrefix.IsEmpty() ? -1 : AddPrefix(-1, -1, fs2us(phyPrefix));
int logParent = logPrefix.IsEmpty() ? -1 : AddPrefix(-1, -1, logPrefix);
for (int i = 0; i < filePaths.Size(); i++)
{
const FString &filePath = filePaths[i];
NFind::CFileInfo fi;
const FString phyPath = phyPrefix + filePath;
if (!fi.Find(phyPath))
{
errorCodes.Add(::GetLastError());
errorPaths.Add(phyPath);
continue;
}
int delimiter = filePath.ReverseFind(FCHAR_PATH_SEPARATOR);
FString phyPrefixCur;
int phyParentCur = phyParent;
if (delimiter >= 0)
{
phyPrefixCur = filePath.Left(delimiter + 1);
phyParentCur = AddPrefix(phyParent, logParent, fs2us(phyPrefixCur));
}
AddDirFileInfo(phyParentCur, logParent, fi, Items);
if (fi.IsDir())
{
const FString name2 = fi.Name + FCHAR_PATH_SEPARATOR;
int parent = AddPrefix(phyParentCur, logParent, fs2us(name2));
EnumerateDirectory(parent, parent, phyPrefix + phyPrefixCur + name2, errorPaths, errorCodes);
}
}
ReserveDown();
}
示例4: AddDirFileInfo
void CDirItems::AddDirFileInfo(int phyParent, int logParent, int secureIndex,
const NFind::CFileInfo &fi)
{
CDirItem di;
di.Size = fi.Size;
di.CTime = fi.CTime;
di.ATime = fi.ATime;
di.MTime = fi.MTime;
di.Attrib = fi.Attrib;
di.IsAltStream = fi.IsAltStream;
di.PhyParent = phyParent;
di.LogParent = logParent;
di.SecureIndex = secureIndex;
di.Name = fs2us(fi.Name);
#if defined(_WIN32) && !defined(UNDER_CE)
// di.ShortName = fs2us(fi.ShortName);
#endif
Items.Add(di);
if (fi.IsDir())
Stat.NumDirs++;
else if (fi.IsAltStream)
{
Stat.NumAltStreams++;
Stat.AltStreamsSize += fi.Size;
}
else
{
Stat.NumFiles++;
Stat.FilesSize += fi.Size;
}
}
示例5: GetNextFile
HRESULT CDirEnumerator::GetNextFile(NFind::CFileInfo &fileInfo, bool &filled, FString &resPath)
{
filled = false;
for (;;)
{
if (Enumerators.IsEmpty())
{
if (Index >= FileNames.Size())
return S_OK;
const FString &path = FileNames[Index];
int pos = path.ReverseFind(FCHAR_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())
{
FString prefix = resPath + FCHAR_PATH_SEPARATOR;
Enumerators.Add(NFind::CEnumerator(BasePrefix + prefix + FCHAR_ANY_MASK));
Prefixes.Add(prefix);
}
filled = true;
return S_OK;
}
示例6: AddPrefix
HRESULT CDirItems::EnumerateItems2(
const FString &phyPrefix,
const UString &logPrefix,
const FStringVector &filePaths,
FStringVector *requestedPaths)
{
int phyParent = phyPrefix.IsEmpty() ? -1 : AddPrefix(-1, -1, fs2us(phyPrefix));
int logParent = logPrefix.IsEmpty() ? -1 : AddPrefix(-1, -1, logPrefix);
FOR_VECTOR (i, filePaths)
{
const FString &filePath = filePaths[i];
NFind::CFileInfo fi;
const FString phyPath = phyPrefix + filePath;
if (!fi.Find(phyPath))
{
RINOK(AddError(phyPath));
continue;
}
if (requestedPaths)
requestedPaths->Add(phyPath);
int delimiter = filePath.ReverseFind_PathSepar();
FString phyPrefixCur;
int phyParentCur = phyParent;
if (delimiter >= 0)
{
phyPrefixCur.SetFrom(filePath, delimiter + 1);
phyParentCur = AddPrefix(phyParent, logParent, fs2us(phyPrefixCur));
}
int secureIndex = -1;
#ifdef _USE_SECURITY_CODE
if (ReadSecure)
{
RINOK(AddSecurityItem(phyPath, secureIndex));
}
#endif
AddDirFileInfo(phyParentCur, logParent, secureIndex, fi);
if (fi.IsDir())
{
const FString name2 = fi.Name + FCHAR_PATH_SEPARATOR;
unsigned parent = AddPrefix(phyParentCur, logParent, fs2us(name2));
RINOK(EnumerateDir(parent, parent, phyPrefix + phyPrefixCur + name2));
}
}
ReserveDown();
return S_OK;
}
示例7: DeleteEmptyFolderAndEmptySubFolders
static bool DeleteEmptyFolderAndEmptySubFolders(const FString &path)
{
NFind::CFileInfo fileInfo;
FString pathPrefix = path + FCHAR_PATH_SEPARATOR;
{
NFind::CEnumerator enumerator(pathPrefix + FCHAR_ANY_MASK);
while (enumerator.Next(fileInfo))
{
if (fileInfo.IsDir())
if (!DeleteEmptyFolderAndEmptySubFolders(pathPrefix + fileInfo.Name))
return false;
}
}
/*
// we don't need clear read-only for folders
if (!MySetFileAttributes(path, 0))
return false;
*/
return RemoveDir(path);
}
示例8: EnumerateDir
HRESULT CDirItems::EnumerateDir(int phyParent, int logParent, const FString &phyPrefix)
{
RINOK(ScanProgress(phyPrefix));
NFind::CEnumerator enumerator;
enumerator.SetDirPrefix(phyPrefix);
for (unsigned ttt = 0; ; ttt++)
{
NFind::CFileInfo fi;
bool found;
if (!enumerator.Next(fi, found))
{
return AddError(phyPrefix);
}
if (!found)
return S_OK;
int secureIndex = -1;
#ifdef _USE_SECURITY_CODE
if (ReadSecure)
{
RINOK(AddSecurityItem(phyPrefix + fi.Name, secureIndex));
}
#endif
AddDirFileInfo(phyParent, logParent, secureIndex, fi);
if (Callback && (ttt & kScanProgressStepMask) == kScanProgressStepMask)
{
RINOK(ScanProgress(phyPrefix));
}
if (fi.IsDir())
{
const FString name2 = fi.Name + FCHAR_PATH_SEPARATOR;
unsigned parent = AddPrefix(phyParent, logParent, fs2us(name2));
RINOK(EnumerateDir(parent, parent, phyPrefix + name2));
}
}
}
示例9: DeleteEmptyFolderAndEmptySubFolders
static bool DeleteEmptyFolderAndEmptySubFolders(const FString &path)
{
NFind::CFileInfo fileInfo;
FString pathPrefix = path;
pathPrefix.Add_PathSepar();
{
NFind::CEnumerator enumerator;
enumerator.SetDirPrefix(pathPrefix);
while (enumerator.Next(fileInfo))
{
if (fileInfo.IsDir())
if (!DeleteEmptyFolderAndEmptySubFolders(pathPrefix + fileInfo.Name))
return false;
}
}
/*
// we don't need clear readonly for folders
if (!SetFileAttrib(path, 0))
return false;
*/
return RemoveDir(path);
}
示例10: ReadPluginInfoList
void ReadPluginInfoList(CObjectVector<CPluginInfo> &plugins)
{
plugins.Clear();
FString baseFolderPrefix = NDLL::GetModuleDirPrefix();
{
CPluginInfo pluginInfo;
pluginInfo.FilePath = baseFolderPrefix + FTEXT("7-zip.dll");
if (::ReadPluginInfo(pluginInfo, false))
plugins.Add(pluginInfo);
}
FString folderPath = baseFolderPrefix + FTEXT("Plugins") FSTRING_PATH_SEPARATOR;
NFind::CEnumerator enumerator(folderPath + FCHAR_ANY_MASK);
NFind::CFileInfo fileInfo;
while (enumerator.Next(fileInfo))
{
if (fileInfo.IsDir())
continue;
CPluginInfo pluginInfo;
pluginInfo.FilePath = folderPath + fileInfo.Name;
if (::ReadPluginInfo(pluginInfo, true))
plugins.Add(pluginInfo);
}
}
示例11: ProcessVirt
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::CFileInfo fileInfo;
bool filled;
FString resPath;
HRESULT errorCode = Enumerator.GetNextFile(fileInfo, filled, resPath);
if (errorCode != 0)
{
SetErrorPath1(resPath);
return errorCode;
}
if (!filled)
break;
if (!fileInfo.IsDir())
{
totalSize += fileInfo.Size;
NumFilesScan++;
}
sync.SetCurrentFileName(scanningStr + fs2us(resPath));
sync.SetProgress(totalSize, 0);
RINOK(sync.SetPosAndCheckPaused(0));
}
sync.SetNumFilesTotal(NumFilesScan);
sync.SetProgress(totalSize, 0);
Enumerator.Init();
for (;;)
{
NFind::CFileInfo fileInfo;
bool filled;
FString resPath;
HRESULT errorCode = Enumerator.GetNextFile(fileInfo, filled, resPath);
if (errorCode != 0)
{
SetErrorPath1(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();
SetErrorPath1(resPath);
return errorCode;
}
sync.SetCurrentFileName(fs2us(resPath));
sync.SetNumFilesCur(NumFiles);
NumFiles++;
for (;;)
{
UInt32 processedSize;
if (!inFile.Read(buffer, kBufSize, processedSize))
{
errorCode = GetNormalizedError();
SetErrorPath1(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);
//.........这里部分代码省略.........
示例12: OnInit
bool CLinkDialog::OnInit()
{
#ifdef LANG
LangSetWindowText(*this, IDD_LINK);
LangSetDlgItems(*this, kLangIDs, ARRAY_SIZE(kLangIDs));
#endif
_pathFromCombo.Attach(GetItem(IDC_LINK_PATH_FROM));
_pathToCombo.Attach(GetItem(IDC_LINK_PATH_TO));
if (!FilePath.IsEmpty())
{
NFind::CFileInfo fi;
int linkType = 0;
if (!fi.Find(us2fs(FilePath)))
linkType = IDR_LINK_TYPE_SYM_FILE;
else
{
if (fi.HasReparsePoint())
{
CReparseAttr attr;
bool res = GetSymLink(us2fs(FilePath), attr);
UString s = attr.PrintName;
if (!attr.IsOkNamePair())
{
s += L" : ";
s += attr.SubsName;
}
if (!res)
s = L"ERROR: " + s;
SetItemText(IDT_LINK_PATH_TO_CUR, s);
UString destPath = attr.GetPath();
_pathFromCombo.SetText(FilePath);
_pathToCombo.SetText(destPath);
if (res)
{
if (attr.IsMountPoint())
linkType = IDR_LINK_TYPE_JUNCTION;
if (attr.IsSymLink())
{
linkType =
fi.IsDir() ?
IDR_LINK_TYPE_SYM_DIR :
IDR_LINK_TYPE_SYM_FILE;
// if (attr.IsRelative()) linkType = IDR_LINK_TYPE_SYM_RELATIVE;
}
if (linkType != 0)
Set_LinkType_Radio(linkType);
}
}
else
{
_pathFromCombo.SetText(AnotherPath);
_pathToCombo.SetText(FilePath);
if (fi.IsDir())
linkType = g_SymLink_Supported ?
IDR_LINK_TYPE_SYM_DIR :
IDR_LINK_TYPE_JUNCTION;
else
linkType = IDR_LINK_TYPE_HARD;
}
}
if (linkType != 0)
Set_LinkType_Radio(linkType);
}
NormalizeSize();
return CModalDialog::OnInit();
}
示例13: CompressFiles
HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems)
{
if (pluginPanelItems.Size() == 0)
return E_FAIL;
UStringVector fileNames;
int i;
for (i = 0; i < pluginPanelItems.Size(); i++)
{
const PluginPanelItem &panelItem = pluginPanelItems[i];
if (strcmp(panelItem.FindData.cFileName, "..") == 0 &&
NFind::NAttributes::IsDir(panelItem.FindData.dwFileAttributes))
return E_FAIL;
if (strcmp(panelItem.FindData.cFileName, ".") == 0 &&
NFind::NAttributes::IsDir(panelItem.FindData.dwFileAttributes))
return E_FAIL;
FString fullPath;
FString fileNameUnicode = us2fs(MultiByteToUnicodeString(panelItem.FindData.cFileName, CP_OEMCP));
if (!MyGetFullPathName(fileNameUnicode, fullPath))
return E_FAIL;
fileNames.Add(fs2us(fullPath));
}
NCompression::CInfo compressionInfo;
compressionInfo.Load();
int archiverIndex = 0;
CCodecs *codecs = new CCodecs;
CMyComPtr<ICompressCodecsInfo> compressCodecsInfo = codecs;
if (codecs->Load() != S_OK)
throw "Can't load 7-Zip codecs";
{
for (int i = 0; i < codecs->Formats.Size(); i++)
{
const CArcInfoEx &arcInfo = codecs->Formats[i];
if (arcInfo.UpdateEnabled)
{
if (archiverIndex == -1)
archiverIndex = i;
if (arcInfo.Name.CompareNoCase(compressionInfo.ArcType) == 0)
archiverIndex = i;
}
}
}
UString resultPath;
{
CParsedPath parsedPath;
parsedPath.ParsePath(fileNames.Front());
if (parsedPath.PathParts.Size() == 0)
return E_FAIL;
if (fileNames.Size() == 1 || parsedPath.PathParts.Size() == 1)
{
// CSysString pureName, dot, extension;
resultPath = parsedPath.PathParts.Back();
}
else
{
parsedPath.PathParts.DeleteBack();
resultPath = parsedPath.PathParts.Back();
}
}
UString archiveNameSrc = resultPath;
UString archiveName = archiveNameSrc;
const CArcInfoEx &arcInfo = codecs->Formats[archiverIndex];
int prevFormat = archiverIndex;
if (!arcInfo.KeepName)
{
int dotPos = archiveName.ReverseFind('.');
int slashPos = MyMax(archiveName.ReverseFind('\\'), archiveName.ReverseFind('/'));
if (dotPos > slashPos)
archiveName = archiveName.Left(dotPos);
}
archiveName += L'.';
archiveName += arcInfo.GetMainExt();
const CActionSet *actionSet = &kAddActionSet;
for (;;)
{
AString archiveNameA = UnicodeStringToMultiByte(archiveName, CP_OEMCP);
const int kYSize = 16;
const int kXMid = 38;
const int kArchiveNameIndex = 2;
const int kMethodRadioIndex = kArchiveNameIndex + 2;
const int kModeRadioIndex = kMethodRadioIndex + 7;
const CArcInfoEx &arcInfo = codecs->Formats[archiverIndex];
char updateAddToArchiveString[512];
const AString s = UnicodeStringToMultiByte(arcInfo.Name, CP_OEMCP);
sprintf(updateAddToArchiveString,
g_StartupInfo.GetMsgString(NMessageID::kUpdateAddToArchive), (const char *)s);
//.........这里部分代码省略.........
示例14: CopyFolder
static HRESULT CopyFolder(
CCopyState &state,
const FString &srcPath, // without TAIL separator
const FString &destPath) // without TAIL separator
{
RINOK(state.CallProgress());
if (IsDestChild(srcPath, destPath))
{
RINOK(SendMessageError(state.Callback,
state.MoveMode ?
"can not copy folder onto itself" :
"can not move folder onto itself"
, destPath));
return E_ABORT;
}
if (state.MoveMode)
{
if (state.MoveFile_Sys(srcPath, destPath))
return S_OK;
// MSDN: MoveFile() fails for dirs on different volumes.
}
if (!CreateComplexDir(destPath))
{
RINOK(SendMessageError(state.Callback, "can not create folder", destPath));
return E_ABORT;
}
CEnumerator enumerator;
enumerator.SetDirPrefix(CombinePath(srcPath, FString()));
for (;;)
{
NFind::CFileInfo fi;
bool found;
if (!enumerator.Next(fi, found))
{
SendLastErrorMessage(state.Callback, srcPath);
return S_OK;
}
if (!found)
break;
const FString srcPath2 = CombinePath(srcPath, fi.Name);
const FString destPath2 = CombinePath(destPath, fi.Name);
if (fi.IsDir())
{
RINOK(CopyFolder(state, srcPath2, destPath2))
}
else
{
RINOK(CopyFile_Ask(state, srcPath2, fi, destPath2));
}
}
if (state.MoveMode)
{
if (!RemoveDir(srcPath))
{
RINOK(SendMessageError(state.Callback, "can not remove folder", srcPath));
return E_ABORT;
}
}
return S_OK;
}
示例15: RemoveDirectoryWithSubItems
static bool RemoveDirectorySubItems2(const FString pathPrefix, const NFind::CFileInfo &fileInfo)
{
if (fileInfo.IsDir())
return RemoveDirectoryWithSubItems(pathPrefix + fileInfo.Name);
return DeleteFileAlways(pathPrefix + fileInfo.Name);
}