当前位置: 首页>>代码示例>>C++>>正文


C++ FileList::add方法代码示例

本文整理汇总了C++中FileList::add方法的典型用法代码示例。如果您正苦于以下问题:C++ FileList::add方法的具体用法?C++ FileList::add怎么用?C++ FileList::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FileList的用法示例。


在下文中一共展示了FileList::add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: listFiles

int File::listFiles(FileList &fileList)
{
  fileList.clear();
  if (isDirectory() == false)
    return 0;

  string dir = getName();

#if defined(WIN32)
  string findDir = dir + "\\*.*";
  WIN32_FIND_DATA fd;
  HANDLE hFind;
  hFind = FindFirstFile(findDir.c_str(), &fd);
  if (hFind != INVALID_HANDLE_VALUE) {
    do{
      string findFilename = fd.cFileName;
      if (findFilename.compare(".") != 0 && findFilename.compare("..") != 0) {
        File *file = new File(dir.c_str(), findFilename.c_str());
        fileList.add(file);
      }
    } while(FindNextFile(hFind,&fd) != FALSE);
  }
  FindClose(hFind);
#elif defined(BTRON)
  int fd = open(dir.c_str(), O_RDONLY);
  if( fd == -1 )
    return fileList.size();
  char buf[1024] ;
  int cnt;
  while(0 < (cnt = u_getdents(fd, (dirent *)buf, sizeof(buf)))) {
    for(struct dirent *p = (struct dirent *)buf ; (char *)p < &buf[cnt]; p=(struct dirent *) ((int)p+(p->d_reclen)) ) {
        File *file = new File(dir.c_str(), p->d_name);
        fileList.add(file);
    }
    }
  close(fd);
#elif !defined(ITRON) && !defined(TENGINE)
  struct dirent **namelist;
  int n = scandir(dir.c_str(), &namelist, 0, alphasort);
  if (0 <= n) {
    while(n--) {
      string filename =  namelist[n]->d_name;
      if (filename.compare(".") != 0 && filename.compare("..") != 0) {
        // Thanks for Pekka Virtanen <[email protected]> and Bastiaan Van Eeckhoudt <[email protected]>
        File *file = new File(dir.c_str(), filename.c_str());
        fileList.add(file);
      }
      free(namelist[n]);
    }
    free(namelist);
  }
#endif

  return fileList.size();
}
开发者ID:swc4848a,项目名称:uHTTP4CC,代码行数:55,代码来源:File.cpp

示例2: loaddirectories

static ibool loaddirectories(const char *filename,FileList& fileList)
/****************************************************************************
*
* Function:		loaddirectories
* Parameters:   filename	- Name of directories to look for
*				fileList	- Place to store the filenames
* Returns:		True on success, false on memory error
*
* Description:	Loads a list of all the directories from the current
*				directory into the specified name list.
*
****************************************************************************/
{
	PM_findData	findData;
	void		*hfile;
	ibool		valid;

	valid = (hfile = PM_findFirstFile(filename,&findData)) != NULL;
	while (valid) {
		if ((findData.attrib & PM_FILE_DIRECTORY) && findData.name[0] != '.') {
			fileList.add(new TCDynStr(findData.name));
			if (MV_lowMemory())
				return false;
			}
		valid = PM_findNextFile(hfile,&findData);
		}
	if (hfile)
		PM_findClose(hfile);
	return true;
}
开发者ID:OS2World,项目名称:LIB-VIDEO-MGL,代码行数:30,代码来源:mfiledlg.cpp

示例3: glob

	int glob(const std::string& regex, FileList& result, bool recursive=true) {
		std::regex e(regex);
		if (dir && APR_SUCCESS == check_apr(apr_dir_open(&dir, dirname.c_str(), mPool))) {
			// iterate over directory:
			while (APR_SUCCESS == (apr_dir_read(&dirent, APR_FINFO_TYPE|APR_FINFO_NAME, dir))) {
				//printf("test %s %s\n", dirname.c_str(), dirent.name);
				if (dirent.filetype == APR_REG && dirent.name && std::regex_match(dirname+dirent.name,e) ) {
					FilePath res;
					res.file(dirent.name);
					res.path(dirname);
					result.add(res);
				} else if (recursive && dirent.filetype == APR_DIR && dirent.name && dirent.name[0] != '.') {
					Path path(dirname + dirent.name + AL_FILE_DELIMITER);
					path.glob(regex, result, true);
				}
			}
		} else {
			AL_WARN("couldn't open directory %s", dirname.c_str());
		}
		return result.count();
	}
开发者ID:AlloSphere-Research-Group,项目名称:AlloSystem,代码行数:21,代码来源:al_FileAPR.cpp


注:本文中的FileList::add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。