示例#1
0
bool FileSystem::take(FileNode* node) {
  pthread_mutex_lock(&fmap_mux);
    int ret = file_map.erase(node->pathname);
  pthread_mutex_unlock(&fmap_mux);

  if (ret == 0) return false;

  FileList* files = &(node->parent->children);
  FileList::iterator it = ::find(files->begin(), files->end(), node);

  if (it != files->end()) {
    files->erase(it);
    return true;
  }
  return false;
}
示例#2
0
int archivefs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
                      off_t offset, struct fuse_file_info *info) {
  (void)offset;
  (void)path;

  FusePrivate* fuse_data = PRIVATE_DATA;
  FileHandle* fh = NULL;
  int ret;

  /* Stejná logika jako u archivefs_read.
   */
  if (fuse_data->mode == FusePrivate::ARCHIVE_MOUNTED) {
    fh = reinterpret_cast<FileHandle*>(info->fh);
  } else {
    char fpath[PATH_MAX];
    fullpath(fpath, path);
    struct stat dir_info;
    if (stat(fpath, &dir_info) == 0 && S_ISDIR(dir_info.st_mode)) {
      DIR* dir = reinterpret_cast<DIR*>(info->fh);
      struct dirent* file;

      // Every directory contains at least two entries: . and ..  If my
      // first call to the system readdir() returns NULL I've got an
      // error; near as I can tell, that's the only condition under
      // which I can get an error from readdir()
      file = readdir(dir);
      if (file == NULL) {
        ret = errno;
        print_err("READDIR", path, ret);
        return -ret;
      } else {
        do {
          if (filler(buf, file->d_name, NULL, 0) != 0) {
            return -ENOMEM;
          }

        } while ((file = readdir(dir)) != NULL);

        return 0;
      }
    } else {
      fh = reinterpret_cast<FileHandle*>(info->fh);
    }
  }

  filler(buf, ".", NULL, 0);
  filler(buf, "..", NULL, 0);

  FileList* files = fh->first->readDir(fh->second);
  for (FileList::const_iterator it = files->begin();
       it != files->end(); ++it) {
    if (filler(buf, (*it)->name_ptr, NULL, 0) != 0) {
      print_err("READDIR", path, ENOMEM);
      return -ENOMEM;
    }
  }

  return 0;
}
void MaterialScriptChecker::run()
{
	string currentPath = FileSystem::getCurrentPath();
	FileList fileList;
	FileSystem::getAllFileInPath(fileList, currentPath, "material", FILE_ATTRIBUTE_ARCHIVE);
	for (FileIterator i = fileList.begin(); i != fileList.end(); i++)
	{
		checkFile(i->fileName);
	}
}
 void DirectoryScanner::scan(db::Watchfolder folder,std::string indir/*, std::string outdir, db::Preset preset, FileFilter & filter*/) {
   LOGDEBUG("Scanning Directory:" << indir);
   MyFileFilter filter=MyFileFilter(folder.extensionfilter);
   FileList list = File(indir).listFiles(filter);
   FileList::iterator it = list.begin();
   for (; it != list.end(); it++) {
     if ((*it)->isDirectory())
       scan(folder,(*it)->getPath());
     else
       computeFile(folder,*it->get());
   }
 }
示例#5
0
文件: main.cpp 项目: wenxq/cpp
void output(const FileList& flist)
{
	for (BOOST_AUTO(iter, flist.begin()); iter != flist.end(); ++iter)
	{
		BOOST_AUTO(&fmeta, iter->second);
		std::vector<char> buffer;
		std::cout << "name  : "  << GetFileName(fmeta.mName, buffer) << "\n, "
					<< "meta  : {" << fmeta.mMeta     << "}, \n"
					<< "offset: "  << fmeta.mOffset   << ", \n"
					<< "fsize : "  << fmeta.mFileSize << ", \n"
					<< "wbsize: "  << fmeta.mWriteBSize << "\n"
					<< std::endl;
	}
}
      PresetList::PresetList() : Wt::Ext::TableView() {
        File presetdir(org::esb::config::Config::get("preset.path"));
        if (presetdir.exists()) {
          FileList files = presetdir.listFiles();
          std::list<std::list<std::string> > data;
          FileList::iterator file_it = files.begin();
          for (; file_it != files.end(); file_it++) {
            org::esb::hive::PresetReader reader((*file_it)->getPath());
            LOGDEBUG((*file_it)->getPath());
            std::list<std::string> line;
            line.push_back((*file_it)->getFileName());
            line.push_back(reader.getPreset()["name"]);
            //line.push_back(reader.getPreset()["id"]);
            data.push_back(line);
          }
          setModel(new PresetListTableModel(data));
          setAlternatingRowColors(true);
          resizeColumnsToContents(true);
          setColumnHidden(0, true);
          setHighlightMouseOver(true);
          setSelectionBehavior(Wt::SelectRows);
          setSelectionMode(Wt::SingleSelection);
          setColumnWidth(0, 50);
          setAutoExpandColumn(1);

          itemSelectionChanged().connect(SLOT(this, PresetList::selectionChanged));


          setTopToolBar(new Wt::Ext::ToolBar());
          create_button = topToolBar()->addButton("Create a new Preset");
          create_button->setIcon("icons/add-icon.png");
          topToolBar()->addSeparator();
          edit_button = topToolBar()->addButton("Edit selected Preset");
          edit_button->setIcon("icons/edit-icon.png");
          //topToolBar()->addSeparator();
          //delete_button = topToolBar()->addButton("Delete selected Preset");
          //delete_button->setIcon("icons/encoding-project-remove-icon.png");

          create_button->setEnabled(true);
          edit_button->setEnabled(false);
          //delete_button->setEnabled(false);

          create_button->clicked().connect(SLOT(this, PresetList::createPreset));
          edit_button->clicked().connect(SLOT(this, PresetList::editPreset));
          //delete_button->clicked().connect(SLOT(this, PresetList::deletePreset));

        } else {
          LOGERROR("Preset Directory does not exist! " << presetdir.getPath());
        }
      }
 void PresetList::refresh() {
   File presetdir(org::esb::config::Config::get("preset.path"));
   if (presetdir.exists()) {
     FileList files = presetdir.listFiles();
     std::list<std::list<std::string> > data;
     FileList::iterator file_it = files.begin();
     for (; file_it != files.end(); file_it++) {
       org::esb::hive::PresetReader reader((*file_it)->getPath());
       LOGDEBUG((*file_it)->getPath());
       std::list<std::string> line;
       line.push_back((*file_it)->getFileName());
       line.push_back(reader.getPreset()["name"]);
       data.push_back(line);
     }
    static_cast<PresetListTableModel*>(model())->setModelData(data);
   }
 }
示例#8
0
bool FileSystem::remove_recursive(const String &filename)
{
	assert(!filename.empty());

	if (filename.empty())
		return false;
	if (is_file(filename))
		return file_remove(filename);
	if (is_directory(filename))
	{
		FileList files;
		directory_scan(filename, files);
		bool success = true;
		for(FileList::const_iterator i = files.begin(); i != files.end(); ++i)
			if (!remove_recursive(filename + ETL_DIRECTORY_SEPARATOR + *i))
				success = false;
		return success;
	}
	return true;
}
示例#9
0
void GenCheckCodes( const string& path )
{
	string cur_file;
	string res_path = path.substr(0, path.find("sound"));

	FileList::iterator it	= g_file_list.begin();
	FileList::iterator eit	= g_file_list.end();
	for ( ; it != eit; ++it )
	{	
		cur_file = res_path + *it;
		uint32 file_id = FileName2Id((*it).c_str());
		uint32 crc = 0;
		CCrc32::GetInst()->InitCrc32(crc);

		FILE* fp = 0;
		if ( fopen_s(&fp, cur_file.c_str(), "rb") != 0 )
		{
			cerr << "open " << cur_file << "failed." << endl;
			return;
		}

		fseek(fp, 0, SEEK_END);
		size_t size = ftell(fp);
		fseek(fp, 0, SEEK_SET);
		char* date_buf = new char[size];
		if ( !date_buf )
		{
			cerr << "alloc data buf failed." << endl;
			return;
		}
		fread_s(date_buf, size, size, 1, fp);
		
		CCrc32::GetInst()->MakeCrc32Sub(crc, (uint8*)date_buf, (uint32)size);
		CCrc32::GetInst()->MakeCrc32End(crc);
		g_check_map.insert(make_pair(file_id, crc));

		delete[] date_buf;
		fclose(fp);
	}
}
示例#10
0
void scanDirectory(const char* path, const char* ext, FileList& list)
{
	fileListClear(list);
	
#ifdef WIN32
	_finddata_t dir;
	char pathWithExt[260];
	intptr_t fh;
	strcpy(pathWithExt, path);
	strcat(pathWithExt, "/*");
	strcat(pathWithExt, ext);
	fh = _findfirst(pathWithExt, &dir);
	if (fh == -1L)
		return;
	do
	{
		fileListAdd(list, std::string(dir.name));
	}
	while (_findnext(fh, &dir) == 0);
	_findclose(fh);
#else
	dirent* current = 0;
	DIR* dp = opendir(path);
	if (!dp)
		return;
	
	while ((current = readdir(dp)) != 0)
	{
		int len = strlen(current->d_name);
		if (len > 4 && strncmp(current->d_name+len-4, ext, 4) == 0)
		{
			fileListAdd(list, current->d_name);
		}
	}
	closedir(dp);
#endif

	if (!list.empty())
		std::sort(list.begin(), list.end());
}
void QuickOpenFunctionDialog::fillItemList() {
    m_items.clear();
    m_functionDefList.clear();
    FileList fileList = m_part->codeModel()->fileList();

    // for each one file, get all functions
    FileDom fileDom;
    for( FileList::Iterator it = fileList.begin() ; it!=fileList.end() ; ++it ){
            fileDom = *it;
            FunctionDefinitionList defs = CodeModelUtils::allFunctionDefinitionsDetailed( fileDom ).functionList;
            if( defs.isEmpty() ) {
              m_functionDefList += CodeModelUtils::allFunctionsDetailed( fileDom ).functionList;
            } else {
              for( FunctionDefinitionList::iterator it = defs.begin(); it != defs.end(); ++it )
                (m_functionDefList).append( (*it).data() );
            }
    }

    for( FunctionList::const_iterator it = m_functionDefList.begin(); it != m_functionDefList.end(); ++it )
      m_items << (*it)->name();
    QStringList_unique( m_items );
}
示例#12
0
bool FileSystem::copy_recursive(Handle from_file_system, const String &from_filename, Handle to_file_system, const String &to_filename)
{
	if (!from_file_system || !to_file_system) return false;
	if (from_file_system->is_file(from_filename))
		return copy(from_file_system, from_filename, to_file_system, to_filename);
	if (from_file_system->is_directory(from_filename))
	{
		if (!to_file_system->directory_create(to_filename))
			return false;
		FileList files;
		bool success = from_file_system->directory_scan(from_filename, files);
		for(FileList::const_iterator i = files.begin(); i != files.end(); ++i)
			if (!copy_recursive(
					from_file_system,
					from_filename + ETL_DIRECTORY_SEPARATOR + *i,
					to_file_system,
					to_filename + ETL_DIRECTORY_SEPARATOR + *i ))
				success = false;
		return success;
	}
	return false;
}
示例#13
0
/// Create list of all files in provided folder ending with same postfix
static FileList CreateFileList(std::string folder , std::string postfix)
{
  itk::Directory::Pointer dir = itk::Directory::New();
  FileList fileList;

  if( dir->Load(folder.c_str() ) )
  {
    int n = dir->GetNumberOfFiles();
    for(int r=0;r<n;r++)
    {
      std::string filename = dir->GetFile( r );
      if (filename == "." || filename == "..")
        continue;
      filename = folder + filename;
      if (!itksys::SystemTools::FileExists( filename.c_str()))
        continue;

      if (postfix.compare(filename.substr(filename.length() -postfix.length() )) == 0)
        fileList.push_back(filename);
    }
  }
  std::sort (fileList.begin(), fileList.end());
  return fileList;
}
示例#14
0
文件: mergehdf.cpp 项目: jpcoles/ZM
int main( int argc, char *argv[] ) {
    bool bHelp = false;
    bool bError = false;
    bool bDouble = false;
    std::string RefName, OutName;
    File *RefFile = 0;
    FileList files;
    uint64_t n;
    //double dValue;

    //! Parse command line arguments (flags).
    for (;;) {
	int c, option_index=0;

	static struct option long_options[] = {
		{ "help",        0, 0, OPT_HELP	},
		{ "reference",   1, 0, OPT_REFERENCE },
		{ "output",      1, 0, OPT_OUTPUT },
		{ "double",      0, 0, OPT_DOUBLE },
		{ 0,             0, 0, 0 }
	    };
	c = getopt_long( argc, argv, "hr:o:d",
			 long_options, &option_index );
	if ( c == -1 ) break;

	switch (c) {
	case OPT_HELP:
	    bHelp = true;
	    break;
	case OPT_REFERENCE:
	    assert(optarg !=NULL);
	    RefName = optarg;
	    break;
	case OPT_OUTPUT:
	    assert(optarg !=NULL);
	    OutName = optarg;
	    break;
	case OPT_DOUBLE:
	    bDouble = true;
	    break;
	default:
	    bError = true;
	    }
	}

    if ( bError ) return 1;

    if ( !RefName.empty() ) {
	std::cout << "Opening " << RefName << std::endl;
	RefFile = new File( RefName, H5F_ACC_RDONLY );
	RefFile->readClasses();
	}

    // Open all MDL I/O files
    files.reserve( argc-optind );
    while ( optind < argc ) {
	std::cout << "Opening " << argv[optind] << std::endl;
	files.push_back(
	    new File(argv[optind++],
		     RefName.empty() ? H5F_ACC_RDONLY : H5F_ACC_RDWR));
	}

    // Put the files in iOrder order.
    std::for_each(files.begin(), files.end(), File::doReadClasses());
    std::sort(files.begin(),files.end(), File::compStart());

    // Check that there are no gaps and determine the totals
    std::for_each(files.begin(), files.end(), File::doAddStart(n));
    std::cout << "We have a total of " << n << " dark particles" << std::endl;

    // Now fix the tables if we have a reference file
    if ( RefFile ) {
	std::for_each(files.begin(), files.end(), File::doFixClasses(RefFile));
	std::for_each(files.begin(), files.end(), File::doWriteClasses());
	}

    if ( !OutName.empty() ) {
	std::cout << "Creating " << OutName << std::endl;
	File OutFile( OutName, H5F_ACC_TRUNC );
	OutFile.create(n,false);
	OutFile.copyAttributes(files.front());
	std::for_each(files.begin(), files.end(), File::doMergeClasses(OutFile));
	OutFile.writeClasses();
	std::for_each(files.begin(), files.end(), File::doCopyData(OutFile));
	}
    }
示例#15
0
 gcc_pure
 const_iterator end() const {
   return files.end();
 }
示例#16
0
static void typeNameList( QStringList& path, QStringList & lst, const CodeModel * model )
{
	const FileList fileList = model->fileList();
	for( FileList::ConstIterator it=fileList.begin(); it!=fileList.end(); ++it )
		typeNameList( path, lst, model_cast<NamespaceDom>(*it) );
}
示例#17
0
static void typedefMap( QMap<QString, QString> & map, const CodeModel * model )
{
	const FileList fileList = model->fileList();
	for( FileList::ConstIterator it=fileList.begin(); it!=fileList.end(); ++it )
		typedefMap( map, model_cast<NamespaceDom>(*it) );
}
示例#18
0
unsigned char * zmodifyer::get( UString & file_name, size_t & size, wchar_t const * password /* = 0 */ )
{
	if( file_name.Length() == 0 )
		return 0;

	// 커맨드 스트링
	UStringVector commandStrings;

	commandStrings.Add( L"G" );

	UString pw( L"-P" );

	commandStrings.Add( (pw + ( password ? password : L"") ) );
	
	// multi thread
	commandStrings.Add( L"-MMT=+" );

	commandStrings.Add( L"-BD" );

	commandStrings.Add( file_name_ );

	commandStrings.Add( file_name );

	// 파싱된 커맨드라인 정보로 options 셋팅 ------------
	CArchiveCommandLineOptions options;
	
	//options.HelpMode = true;
	
	// 없는 파일이면 작업 중지
	if( !zdb_->db_.IsEmpty() )
	{
		typedef std::list< std::wstring > FileList;
		FileList files;

		std::wstring tmp = file_name;

		boost::split( files, tmp, boost::is_any_of(L":") );

		for( FileList::iterator iter = files.begin(); iter != files.end(); ++iter )
		{
			if( !zdb_->folder_.find( *iter ) )
				return 0;
		}
	}

	OptionSetting( commandStrings, options );
	options.OverwriteMode = NExtract::NOverwriteMode::kWithoutPrompt; // 덮어쓰기 할때 묻지마라.
	options.YesToAll = true;
	//------------

	// 압축파일 형식 인덱스 추출.
	CIntVector formatIndices;
	if (!codecs_->FindFormatForArchiveType(options.ArcType, formatIndices))
	{
		throw kUnsupportedArcTypeMessage;
	}

	bool isExtractGroupCommand = options.Command.IsFromExtractGroup();

	if (codecs_->Formats.Size() == 0 &&
		(isExtractGroupCommand ||
		options.Command.CommandType == NCommandType::kList ||
		options.Command.IsFromUpdateGroup()))
		throw kNoFormats;

	// 압축 해제
	if (isExtractGroupCommand)
	{
		CExtractCallbackConsole *ecs = new CExtractCallbackConsole;
		CMyComPtr<IFolderArchiveExtractCallback> extractCallback = ecs;

		ecs->OutStream = &outStream_;

#ifndef _NO_CRYPTO
		ecs->PasswordIsDefined = options.PasswordEnabled;
		ecs->Password = options.Password;
#endif

		ecs->Init();

		COpenCallbackConsole openCallback;
		openCallback.OutStream = &outStream_;

#ifndef _NO_CRYPTO
		openCallback.PasswordIsDefined = options.PasswordEnabled;
		openCallback.Password = options.Password;
#endif

		CExtractOptions eo;
		eo.StdInMode = options.StdInMode;
		eo.StdOutMode = options.StdOutMode;
		eo.PathMode = options.Command.GetPathMode();
		//eo.TestMode = options.Command.IsTestMode();
		eo.TestMode = true; // 테스트 모드로 압축해제(파일 저장 안함)
		eo.OverwriteMode = options.OverwriteMode;
		eo.OutputDir = options.OutputDir;
		eo.YesToAll = options.YesToAll;
		eo.CalcCrc = options.CalcCrc;

#if !defined(_7ZIP_ST) && !defined(_SFX)
		eo.Properties = options.ExtractProperties;
#endif

		//ZDBS::_currentArchive = file_name_;

		UString errorMessage;
		CDecompressStat stat;
		HRESULT result = DecompressArchives(
			codecs_,
			formatIndices,
			options.ArchivePathsSorted,
			options.ArchivePathsFullSorted,
			options.WildcardCensor.Pairs.Front().Head,
			eo, &openCallback, ecs, errorMessage, stat, zdb_);
	}

	return CIOStream::Read( size );
}
示例#19
0
void CalibrationScanAnalysis::analyze() {

#ifdef DEBUG_ON
  TFile* debugFile = new TFile("debug.root","RECREATE");
#endif
  
  // load data from files
  std::cout << "Loading data from files..." << std::endl;
  for(FileList::const_iterator it=files_.begin();it!=files_.end();++it) {
    getSummaries(it);
  }
  std::cout << endl;
  sortByGeometry();
  loadPresentValues();

  // sanity check
  if(!checkInput()) return;

  // check if both ISHA and VFS have to be tuned
  std::cout << "Preparing analysis..." << std::endl;
  int minISHA = 1000;
  int maxISHA = 0;
  int minVFS  = 1000;
  int maxVFS  = 0;
  for(FileList::const_iterator file=files_.begin();file!=files_.end();++file){
    int isha = file->first.first;
    int vfs  = file->first.second;
    minISHA = minISHA<isha ? minISHA : isha;
    maxISHA = maxISHA>isha ? maxISHA : isha;
    minVFS  = minVFS <vfs  ? minVFS  : vfs ;
    maxVFS  = maxVFS >vfs  ? maxVFS  : vfs ;
  }
  tuneISHA_ &= (minISHA!=maxISHA);
  tuneVFS_  &= (minVFS !=maxVFS );
  if(!tuneISHA_) std::cout << "ISHA tune disabled" << std::endl;
  if(!tuneVFS_ ) std::cout << "VFS  tune disabled" << std::endl;
  // two cases are possible:
  // ISHA tune: look at the rise time
  // VFS  tune: look at the tail

  // number of APVs
  unsigned int nAPVs = (*(summaries_.begin()->second.begin()))->GetNbinsX();

  // loop over the inputs to find individual values of ISHA ans VFS
  std::list<unsigned int> ishaValues;
  std::list<unsigned int> vfsValues;
  for(SummaryV::const_iterator summary = summaries_.begin(); summary!=summaries_.end(); ++summary) {
     ishaValues.push_back(summary->first.first);
     vfsValues.push_back(summary->first.second);
  }
  ishaValues.sort();
  vfsValues.sort();
  ishaValues.unique();
  vfsValues.unique();

  // loop over apvs (bins)
  std::cout << "Running analysis..." << std::endl;
  for(unsigned int apv=1;apv<=nAPVs;++apv) {
     TGraph* g1 = new TGraph();
     TGraph* g2 = new TGraph();
     int ii=0;
     cout << "\r" << setw(5) << setfill('0') << apv << flush; 

     // loop over the VFS values
     for(std::list<unsigned int>::const_iterator vfs = vfsValues.begin(); vfs!=vfsValues.end(); ++vfs,++ii) {
       float tail = 0.;
       unsigned int npts = 0;
       for(SummaryV::const_iterator summary = summaries_.begin(); summary!=summaries_.end(); ++summary){
         if((unsigned int)summary->first.second==(*vfs)) {
           // determine which histogram are the rise time and the tail
           const std::vector<TH1*>& observables = summary->second;
           int tail_index = 0;
           int rise_index = 0;
           for( std::vector<TH1*>::const_iterator histo = observables.begin();histo<observables.end();++histo) {
              std::string name = (*histo)->GetName();
              if(name.find("CalibrationTail")!=std::string::npos) tail_index = histo-observables.begin();
              if(name.find("CalibrationRiseTime")!=std::string::npos) rise_index = histo-observables.begin();
           }
	   //for vfs, we take the mean tail over the ISHA values at that point
	   tail += observables[tail_index]->GetBinContent(apv);
	   ++npts;
	 }
       }
       // fill the graph
       g2->SetPoint(ii,(*vfs), tail/npts);
     }
#ifdef DEBUG_ON
     std::string name2 = Form("graph%s%s",summaries_.begin()->second[0]->GetXaxis()->GetBinLabel(apv),"CalibrationTail");
     std::replace( name2.begin(), name2.end(), '.', '_' );
     g2->Write(name2.c_str());
#endif
     // analyse the graphs
     float best_vfs  = tuneVFS_  ? getX(g2,50) : 
                                   presentValues_[summaries_.begin()->second[0]->GetXaxis()->GetBinLabel(apv)].second;
     // now that VFS is optimized, take the ISHA values for the closest VFS point
     // for ISHA, we consider the rise time for VFS values close to the optimal

     // find the closest point in the VFS scan
     float dist = 1000.;
     std::list<unsigned int>::const_iterator vfsPoint = vfsValues.begin();
     for(std::list<unsigned int>::const_iterator vfs = vfsValues.begin(); vfs!=vfsValues.end(); ++vfs) {
       if(dist>fabs((*vfs)-best_vfs)) {
         dist = fabs((*vfs)-best_vfs);
	 vfsPoint = vfs;
       }
     }
     // loop over the ISHA values
     ii=0;
     for(std::list<unsigned int>::const_iterator isha = ishaValues.begin(); isha!=ishaValues.end(); ++isha,++ii) {
       for(SummaryV::const_iterator summary = summaries_.begin(); summary!=summaries_.end(); ++summary){
         if(((unsigned int)summary->first.second==(*vfsPoint))&&((unsigned int)summary->first.first==(*isha))) {
           // determine which histogram are the rise time and the tail
           const std::vector<TH1*>& observables = summary->second;
           int tail_index = 0;
           int rise_index = 0;
           for( std::vector<TH1*>::const_iterator histo = observables.begin();histo<observables.end();++histo) {
              std::string name = (*histo)->GetName();
              if(name.find("CalibrationTail")!=std::string::npos) tail_index = histo-observables.begin();
              if(name.find("CalibrationRiseTime")!=std::string::npos) rise_index = histo-observables.begin();
           }
	   // fill the graph
	   g1->SetPoint(ii,summary->first.first,observables[rise_index]->GetBinContent(apv));
#ifdef DEBUG_ON
           std::string name1 = Form("graph%s%s",summaries_.begin()->second[0]->GetXaxis()->GetBinLabel(apv),"CalibrationRiseTime");
           std::replace( name1.begin(), name1.end(), '.', '_' );
           g1->Write(name1.c_str());
#endif
	 }
       }
     }
     // analyse the graphs
     float best_isha = tuneISHA_ ? getX(g1,53.5 ) :
                                   presentValues_[summaries_.begin()->second[0]->GetXaxis()->GetBinLabel(apv)].first;

     // save the result
     result_[summaries_.begin()->second[0]->GetXaxis()->GetBinLabel(apv)] = std::make_pair((int)round(best_isha),(int)round(best_vfs));

     // cleaning
     delete g1;
     delete g2;
  }
  std::cout << std::endl;

#ifdef DEBUG_ON
  debugFile->Write();
  debugFile->Close();
  delete debugFile;
#endif

}
示例#20
0
/*++

Routine Name:

    CXPSProcessor::Start

Routine Description:

    This routine kicks off the processing of the XPS archive struture. The
    routine parses the Fixed Document Sequence mark-up to find the Fixed
    Document parts, then parses the Fixed Document mark-up to find the Fixed
    Page parts before passing these on to the Fixed Page processor. Additionally
    the routine handles indentifying, processing and sending resources and part
    relationships. Note: This limits the XPS document processing to only modifying
    the fixed page data; the client is not presented the opportunity to modify any
    other parts.

Arguments:

    None

Return Value:

    HRESULT
    S_OK - On success
    E_*  - On error

--*/
HRESULT
CXPSProcessor::Start(
    VOID
    )
{
    HRESULT hr = S_OK;

    try
    {
        //
        // Get the start part list and iterate over all parts
        //
        FileList fixedDocumentSequenceParts;
        if (SUCCEEDED(hr = GetFixedDocumentSequenceParts(&fixedDocumentSequenceParts)))
        {
            FileList::const_iterator iterFDS = fixedDocumentSequenceParts.begin();

            for (;
                 iterFDS != fixedDocumentSequenceParts.end() &&
                 SUCCEEDED(hr) &&
                 SUCCEEDED(hr = ProcessRelsParts(*iterFDS, ContentFixedDocumentSequence));
                 iterFDS++)
            {
                //
                // Parse the start part retrieving the FD list - iterate over all FDs
                //
                FileList fixedDocumentParts;
                if (SUCCEEDED(hr = GetFixedDocumentParts(*iterFDS, &fixedDocumentParts)))
                {
                    FileList::const_iterator iterFD = fixedDocumentParts.begin();

                    for (;
                         iterFD != fixedDocumentParts.end() &&
                         SUCCEEDED(hr) &&
                         SUCCEEDED(hr = ProcessRelsParts(*iterFD, ContentFixedDocument));
                         iterFD++)
                    {
                        //
                        // Parse the FD retrieving the FP list - iterate over all FPs
                        //
                        FileList fixedPageParts;
                        if (SUCCEEDED(hr = GetFixedPageParts(*iterFD, &fixedPageParts)))
                        {
                            FileList::const_iterator iterFP = fixedPageParts.begin();

                            for (;
                                 iterFP != fixedPageParts.end() &&
                                 SUCCEEDED(hr) &&
                                 SUCCEEDED(hr = ProcessRelsParts(*iterFP, ContentFixedPage));
                                 iterFP++)
                            {
                                //
                                // Process the fixed page - this calls on to the IFixedPageProcessor
                                // interface for the client to do the work
                                //
                                hr = ProcessFixedPage(*iterFP);
                            }
                        }
                    }
                }
            }
        }
    }
    catch (CXDException& e)
    {
        hr = e;
    }
    catch (exception& DBG_ONLY(e))
    {
        ERR(e.what());
        hr = E_FAIL;
    }

    ERR_ON_HR(hr);
    return hr;
}
示例#21
0
void QueueEditor::AlignAffectedGroups(DownloadQueue* pDownloadQueue, IDList* pIDList, bool bSmartOrder, int iOffset)
{
	// Build list of all groups; List contains first file of each group
	FileList cGroupList;
	BuildGroupList(pDownloadQueue, &cGroupList);

	// Find affected groups. It includes groups being moved and groups directly
	// above or under of these groups (those order is also changed)
	FileList cAffectedGroupList;
	cAffectedGroupList.clear();
	ItemList cItemList;
	PrepareList(pDownloadQueue, &cItemList, pIDList, bSmartOrder, eaFileMoveOffset, iOffset);
	for (ItemList::iterator it = cItemList.begin(); it != cItemList.end(); it++)
	{
		EditItem* pItem = *it;
		unsigned int iNum = 0;
		for (FileList::iterator it = cGroupList.begin(); it != cGroupList.end(); it++, iNum++)
		{
			FileInfo* pFileInfo = *it;
			if (pItem->m_pFileInfo->GetNZBInfo() == pFileInfo->GetNZBInfo())
			{
				if (!ItemExists(&cAffectedGroupList, pFileInfo))
				{
					cAffectedGroupList.push_back(pFileInfo);
				}
				if (iOffset < 0)
				{
					for (int i = iNum - 1; i >= -iOffset-1; i--)
					{
						if (!ItemExists(&cAffectedGroupList, cGroupList[i]))
						{
							cAffectedGroupList.push_back(cGroupList[i]);
						}
					}
				}
				if (iOffset > 0)
				{
					for (unsigned int i = iNum + 1; i <= cGroupList.size() - iOffset; i++)
					{
						if (!ItemExists(&cAffectedGroupList, cGroupList[i]))
						{
							cAffectedGroupList.push_back(cGroupList[i]);
						}
					}

					if (iNum + 1 < cGroupList.size())
					{
						cAffectedGroupList.push_back(cGroupList[iNum + 1]);
					}
				}
				break;
			}
		}
		delete pItem;
	}
	cGroupList.clear();

	// Aligning groups
	for (FileList::iterator it = cAffectedGroupList.begin(); it != cAffectedGroupList.end(); it++)
	{
		FileInfo* pFileInfo = *it;
		AlignGroup(pDownloadQueue, pFileInfo->GetNZBInfo());
	}
}
示例#22
0
int
main(int argc, char** argv)
{
	if (argc < 2) {
		fprintf(stderr, "usage: %s <hash-file> [<files> ...]\n"
			"\tWhen invoked without files, the hash-file is updated only.\n",
			kProgramName);
		return 1;
	}

	const char* hashFileName = argv[1];

	status_t status = gSHA.Init();
	if (status != B_OK) {
		fprintf(stderr, "%s: Could not initialize SHA processor: %s\n",
			kProgramName, strerror(status));
		return 1;
	}

	int fileCount = argc - 2;
	char** files = argv + 2;

	if (argc == 2) {
		// read files from hash file

		int file = open(hashFileName, O_RDONLY);
		if (file < 0) {
			fprintf(stderr, "%s: Could not open hash file \"%s\": %s\n",
				kProgramName, hashFileName, strerror(status));
			return 1;
		}

		char buffer[2048];
		read(file, buffer, 4);
		if (memcmp(buffer, "HASH", 4)) {
			fprintf(stderr, "%s: \"%s\" is not a hash file\n",
				kProgramName, hashFileName);
			close(file);
			return 1;
		}
		read(file, &fileCount, sizeof(int));
		TRACE("Found %d path(s):\n", fileCount);

		files = (char**)malloc(fileCount * sizeof(char*));
		if (files == NULL) {
			fprintf(stderr, "%s: Could not allocate %ld bytes\n",
				kProgramName, fileCount * sizeof(char*));
			close(file);
			return 1;
		}

		for (int i = 0; i < fileCount; i++) {
			int length;
			read(file, &length, sizeof(int));

			files[i] = (char*)malloc(length + 1);
			if (files[i] == NULL) {
				fprintf(stderr, "%s: Could not allocate %d bytes\n",
					kProgramName, length + 1);
				close(file);
				// TODO: we actually leak memory here, but it's not important in this context
				return 1;
			}
			read(file, files[i], length + 1);
			TRACE("\t%s\n", files[i]);
		}

		close(file);
	} else {
		// Normalize paths
		char** normalizedFiles = (char**)malloc(fileCount * sizeof(char*));
		if (normalizedFiles == NULL) {
			fprintf(stderr, "%s: Could not allocate %ld bytes\n",
				kProgramName, fileCount * sizeof(char*));
			return 1;
		}

		for (int i = 0; i < fileCount; i++) {
			BPath path(files[i], NULL, true);
			normalizedFiles[i] = strdup(path.Path());
			if (normalizedFiles[i] == NULL) {
				fprintf(stderr, "%s: Could not allocate %ld bytes\n",
					kProgramName, strlen(path.Path()) + 1);
				return 1;
			}
		}

		files = normalizedFiles;
	}

	bigtime_t start = system_time();

	for (int i = 0; i < fileCount; i++) {
		process_file(files[i]);
	}

	sort(gFiles.begin(), gFiles.end());

	bigtime_t runtime = system_time() - start;

	write_hash_file(hashFileName, fileCount, files);

	if (gFiles.size() > 0) {
		printf("Generated hashes for %ld files in %g seconds, %g msec per "
			"file.\n", gFiles.size(), runtime / 1000000.0,
			runtime / 1000.0 / gFiles.size());
	}

	for (int i = 0; i < fileCount; i++) {
		free(files[i]);
	}
	free(files);

	return 0;
}
示例#23
0
bool QueueEditor::EditGroup(DownloadQueue* pDownloadQueue, FileInfo* pFileInfo, EEditAction eAction, int iOffset, const char* szText)
{
	IDList cIDList;
	cIDList.clear();

	// collecting files belonging to group
	for (FileQueue::iterator it = pDownloadQueue->GetFileQueue()->begin(); it != pDownloadQueue->GetFileQueue()->end(); it++)
	{
		FileInfo* pFileInfo2 = *it;
		if (pFileInfo2->GetNZBInfo() == pFileInfo->GetNZBInfo())
		{
			cIDList.push_back(pFileInfo2->GetID());
		}
	}

	if (eAction == eaGroupMoveOffset)
	{
		// calculating offset in terms of files
		FileList cGroupList;
		BuildGroupList(pDownloadQueue, &cGroupList);
		unsigned int iNum = 0;
		for (FileList::iterator it = cGroupList.begin(); it != cGroupList.end(); it++, iNum++)
		{
			FileInfo* pGroupInfo = *it;
			if (pGroupInfo->GetNZBInfo() == pFileInfo->GetNZBInfo())
			{
				break;
			}
		}
		int iFileOffset = 0;
		if (iOffset > 0)
		{
			if (iNum + iOffset >= cGroupList.size() - 1)
			{
				eAction = eaGroupMoveBottom;
			}
			else
			{
				for (unsigned int i = iNum + 2; i < cGroupList.size() && iOffset > 0; i++, iOffset--)
				{
					iFileOffset += FindFileInfoEntry(pDownloadQueue, cGroupList[i]) - FindFileInfoEntry(pDownloadQueue, cGroupList[i-1]);
				}
			}
		}
		else
		{
			if (iNum + iOffset <= 0)
			{
				eAction = eaGroupMoveTop;
			}
			else
			{
				for (unsigned int i = iNum; i > 0 && iOffset < 0; i--, iOffset++)
				{
					iFileOffset -= FindFileInfoEntry(pDownloadQueue, cGroupList[i]) - FindFileInfoEntry(pDownloadQueue, cGroupList[i-1]);
				}
			}
		}
		iOffset = iFileOffset;
	}
	else if (eAction == eaGroupDelete)
	{
		pFileInfo->GetNZBInfo()->SetDeleted(true);
		pFileInfo->GetNZBInfo()->SetCleanupDisk(CanCleanupDisk(pDownloadQueue, pFileInfo->GetNZBInfo()));
	}

	EEditAction GroupToFileMap[] = { (EEditAction)0, eaFileMoveOffset, eaFileMoveTop, eaFileMoveBottom, 
		eaFilePause, eaFileResume, eaFileDelete, eaFilePauseAllPars, eaFilePauseExtraPars, eaFileSetPriority, eaFileReorder,
		eaFileMoveOffset, eaFileMoveTop, eaFileMoveBottom, eaFilePause, eaFileResume, eaFileDelete, 
		eaFilePauseAllPars, eaFilePauseExtraPars, eaFileSetPriority,
		(EEditAction)0, (EEditAction)0, (EEditAction)0 };

	return InternEditList(pDownloadQueue, &cIDList, true, GroupToFileMap[eAction], iOffset, szText);
}