本文整理汇总了C++中CDirectory::DirectoryScan方法的典型用法代码示例。如果您正苦于以下问题:C++ CDirectory::DirectoryScan方法的具体用法?C++ CDirectory::DirectoryScan怎么用?C++ CDirectory::DirectoryScan使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDirectory
的用法示例。
在下文中一共展示了CDirectory::DirectoryScan方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CDirectory
bool CDirectory::dir2fdd(char *sourceDirectory, char *fddImageName)
{
Debug::out(LOG_INFO, "CDirectory::dir2fdd() -- will try to create %s from %s", fddImageName, sourceDirectory);
CDirectory *pDir = new CDirectory();
pDir->DirectoryScan(sourceDirectory);
if(!pDir) {
Debug::out(LOG_ERROR, "CreateTreeFromDirectory failed...");
return false;
}
CFloppy floppy;
floppy.Create(NB_HEAD,NB_SECTOR_PER_TRACK,NB_CYLINDER);
bool bOk = floppy.Fill( pDir, (char *) "CONF_FDD" );
if (bOk) {
Debug::out(LOG_INFO, "CDirectory::dir2fdd() -- Writing file %s", fddImageName);
floppy.WriteImage(fddImageName);
}
delete pDir;
return bOk;
}
示例2: DirectoryScan
void CDirectory::DirectoryScan(const char *pDir)
{
char tmpName[_MAX_PATH];
strcpy(tmpName,pDir);
strcat(tmpName,"\\*.*");
DIR *dir = opendir((char *) pDir); // try to open the dir
if(dir == NULL) { // not found?
return;
}
while(1) { // while there are more files, store them
struct dirent *de = readdir(dir); // read the next directory entry
if(de == NULL) { // no more entries?
break;
}
if(de->d_type != DT_DIR && de->d_type != DT_REG) { // not a file, not a directory?
continue;
}
sprintf(tmpName,"%s/%s", pDir, de->d_name);
if(de->d_type == DT_DIR) { // for dir
if(de->d_name[0] == '.') { // skip . and ..
continue;
}
CDirectory *pNewDir = new CDirectory();
this->AddEntry(de, pNewDir, tmpName);
pNewDir->DirectoryScan(tmpName);
} else {
this->AddEntry(de, NULL, tmpName);
}
}
closedir(dir);
}