示例#1
0
void DirectoryFileSource::MountFiles(const PathStringArg& BasePath, const PathStringArg& DestinationPath){
  ConvertAndValidatePath(BasePath);

  string NormBasePath = BasePath.GetNormalizedPath();
   NormBasePath.push_back('/');

  PlatformPath CurrentPath = BasePath.CreatePath(RealPath);
  string CurrentDestPath = DestinationPath.GetNormalizedPath();

  if(!CurrentDestPath.empty() && CurrentDestPath.back() != '/'){
    CurrentDestPath.push_back('/');
  }

  std::wstring& CurrentPathS =  const_cast<std::wstring&>(CurrentPath.native());
  CurrentPathS.reserve(255);

  int pathOffset  = RealPath.native().size();

  std::function<void(const FileInfo&)> foreachFunc = [&](const FileInfo& file) mutable ->void {
    if(file.IsDirectory()){
      int namesize = CurrentPathS.size();
      
      string dirname = file.GetNormlizedNameWithSlash();

      NormBasePath.append(dirname);
      CurrentDestPath.append(dirname);

      CurrentPath /= file.cFileName;
      
      //lambda recursion fun times
      ForEachFile(CurrentPath.c_str()+pathOffset, foreachFunc);

      //shrink the path back down one directory
      CurrentPathS.resize(namesize);

      CurrentDestPath.resize(CurrentDestPath.size()-dirname.size());
      NormBasePath.resize(NormBasePath.size()-dirname.size());
    }else{
      //CurrentDestPath
      string FileName = file.GetNormlizedName();
      string MountedPath = CurrentDestPath+FileName;

      SourceManager::MountFile(MountedPath, MountedFile(this, CurrentPath/file.cFileName, false));

      MountedFiles.insert(std::make_pair(NormBasePath+FileName, std::move(MountedPath))); 
    }
  };

  ForEachFile(BasePath.ToString(),  foreachFunc);
}
	static bool GetDirSize(const char *szPath, uint32_t *pSize, uint32_t inMaxSize = ~0)
	{
		// Security
		if (!pSize) return false;
		// Fold it
		iSize = 0; iMaxSize = inMaxSize;
		ForEachFile(szPath, &Helper);
		// Return
		*pSize = iSize;
		return true;
	}
	static bool Helper(const char *szPath)
	{
		if (szPath[SLen(szPath)-1] == '.')
			return false;
		if (iSize > iMaxSize)
			return false;
		if (DirectoryExists(szPath))
			ForEachFile(szPath, &Helper);
		else if (FileExists(szPath))
			iSize += FileSize(szPath);
		return true;
	}
示例#4
0
int DirectoryFileSource::FindFiles(const PathStringArg& SearchPath, const PathStringArg& NamePatten, FileSearchResult& FoundFiles){
  int count = 0;

  ForEachFile(SearchPath.CreateSearchPath("", NamePatten), [=,&FoundFiles ,&count](const FileInfo& file)mutable ->void{
    if(!file.IsDirectory()){
      FoundFiles[UTF16ToUTF8STLString(file.cFileName)] = this;
      count++;
    }
  });

	return count;
}
示例#5
0
static char *
recursive_args(int argc, const char *argv[]) {
	if (argc == 0) {
		ForEachFile(str2Fname("."), register_file);
	}
	else {
		int i;

		for (i = 0; i < argc; i++) {
			const char *arg = argv[i];
			const Fchar *Farg = str2Fname(arg);
			if (is_new_old_separator(arg)) {
				add_string_to_args(Farg);
			} else {
				ForEachFile(Farg, register_file);
			}
		}
	}
	add_char_to_args('\0');

	return args;
}
示例#6
0
	void ImageBrowser::ScanDirectory(const std::string &directory)
	{
		hasContent = false;
		DestroyChildren();
		selectionImages.clear();

		Entity *bg = new Entity();
		bg->SetGraphic(new Sprite("", 128, 600));
		bg->color = Color::black;
		bg->color.a = 0.75f;
		Add(bg);

		grid = new Entity();
		Add(grid);

		ForEachFile(directory, "png", &ImageBrowser::FileCallback, (intptr_t)this);
	}
示例#7
0
static void
satisfy_lint(void *x) {
	ForEachFile(0, 0);
	ForEachLocalFile(0, 0);
	satisfy_lint(x);
}