Пример #1
0
bool isAnimationFile(const char filename []) {
    String filenameString(filename);

#if defined(ESP32)
    // ESP32 filename includes the full path, so need to remove the path before looking at the filename
    int pathindex = filenameString.lastIndexOf("/");
    if(pathindex >= 0)
        filenameString.remove(0, pathindex + 1);
#endif

    Serial.print(filenameString);

    if ((filenameString[0] == '_') || (filenameString[0] == '~') || (filenameString[0] == '.')) {
        Serial.println(" ignoring: leading _/~/. character");
        return false;
    }

    filenameString.toUpperCase();
    if (filenameString.endsWith(".GIF") != 1) {
        Serial.println(" ignoring: doesn't end of .GIF");
        return false;
    }

    Serial.println();

    return true;
}
Пример #2
0
std::unordered_map<ResourceID, unz64_file_pos> CZipLoader::listFiles(const std::string & mountPoint, const boost::filesystem::path & archive)
{
	std::unordered_map<ResourceID, unz64_file_pos> ret;

	unzFile file = unzOpen2_64(archive.c_str(), &zlibApi);

	if(file == nullptr)
		logGlobal->errorStream() << archive << " failed to open";

	if (unzGoToFirstFile(file) == UNZ_OK)
	{
		do
		{
			unz_file_info64 info;
			std::vector<char> filename;
			// Fill unz_file_info structure with current file info
			unzGetCurrentFileInfo64 (file, &info, nullptr, 0, nullptr, 0, nullptr, 0);

			filename.resize(info.size_filename);
			// Get name of current file. Contrary to docs "info" parameter can't be null
			unzGetCurrentFileInfo64 (file, &info, filename.data(), filename.size(), nullptr, 0, nullptr, 0);

			std::string filenameString(filename.data(), filename.size());
			unzGetFilePos64(file, &ret[ResourceID(mountPoint + filenameString)]);
		}
		while (unzGoToNextFile(file) == UNZ_OK);
	}
	unzClose(file);

	return ret;
}
Пример #3
0
std::unordered_map<ResourceID, unz_file_pos> CZipLoader::listFiles(const std::string & mountPoint, const std::string & archive)
{
	std::unordered_map<ResourceID, unz_file_pos> ret;

	unzFile file = unzOpen(archive.c_str());

	if (unzGoToFirstFile(file) == UNZ_OK)
	{
		do
		{
			unz_file_info info;
			std::vector<char> filename;
			// Fill unz_file_info structure with current file info
			unzGetCurrentFileInfo (file, &info, nullptr, 0, nullptr, 0, nullptr, 0);

			filename.resize(info.size_filename);
			// Get name of current file. Contrary to docs "info" parameter can't be null
			unzGetCurrentFileInfo (file, &info, filename.data(), filename.size(), nullptr, 0, nullptr, 0);

			std::string filenameString(filename.data(), filename.size());
			unzGetFilePos(file, &ret[ResourceID(mountPoint + filenameString)]);
		}
		while (unzGoToNextFile(file) == UNZ_OK);
	}
	unzClose(file);

	return ret;
}
Пример #4
0
int stripTrees(char* filename = "all.root") {
  
  char outfilename[100];
  std::string filenameString(filename);
  std::cout << filenameString.size() << std::endl; 
  std::string filenameStripped = filenameString.substr(filenameString.size()-5, filenameString.size());
  //  filenameStripped.erase(filenameStripped
  sprintf(outfilename, "%s_histograms.root", filenameString.c_str());

  std::vector<TTree*> trees;
  std::vector<TH1F*> th1fs;
  std::vector<TH2F*> th2fs;
  std::vector<TProfile*> tprofiles;

  TFile* f = new TFile(filename);

  // Create an iterator on the list of keys
  TIter nextTopLevelKey = NULL;
  nextTopLevelKey=(f->GetListOfKeys());
  
  TKey *keyTopLevel;
  while (keyTopLevel = (TKey*)nextTopLevelKey()) {
    
    TString name(keyTopLevel->GetName());
    TString className(keyTopLevel->GetClassName());
    
    if ((className.CompareTo("TTree") != 0) || 
	((name.CompareTo("plotvariables") == 0) || (name.CompareTo("inputfiles") == 0))) {
      std::cout << "Adding " << keyTopLevel->GetName() << std::endl;
      
      if (className.CompareTo("TTree") == 0)
	trees.push_back((TTree*) f->Get(name));
      else if (className.CompareTo("TH1F") == 0)
	th1fs.push_back((TH1F*) f->Get(name));
      else if (className.CompareTo("TH2F") == 0)
	th2fs.push_back((TH2F*) f->Get(name));
      else if (className.CompareTo("TProfile") == 0)
	tprofiles.push_back((TProfile*) f->Get(name));
    }
  }

  TFile* out = new TFile(outfilename, "recreate");
  out->cd();
  for (unsigned int i=0; i<trees.size(); i++) 
    trees[i]->Write();

  for (unsigned int i=0; i<th1fs.size(); i++) 
    th1fs[i]->Write();

  for (unsigned int i=0; i<th2fs.size(); i++) 
    th2fs[i]->Write();

  for (unsigned int i=0; i<tprofiles.size(); i++) 
    tprofiles[i]->Write();

  out->Close();
  
  return 0;
}