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


C++ Files类代码示例

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


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

示例1: Files

Files *File::match(FileName *n)
{
#if POSIX
    return NULL;
#elif _WIN32
    HANDLE h;
    WIN32_FIND_DATAA fileinfo;
    Files *a;
    char *c;
    char *name;

    a = new Files();
    c = n->toChars();
    name = n->name();
    h = FindFirstFileA(c,&fileinfo);
    if (h != INVALID_HANDLE_VALUE)
    {
        do
        {
            // Glue path together with name
            char *fn;
            File *f;

            fn = (char *)mem.malloc(name - c + strlen(fileinfo.cFileName) + 1);
            memcpy(fn, c, name - c);
            strcpy(fn + (name - c), fileinfo.cFileName);
            f = new File(fn);
            f->touchtime = mem.malloc(sizeof(WIN32_FIND_DATAA));
            memcpy(f->touchtime, &fileinfo, sizeof(fileinfo));
            a->push(f);
        } while (FindNextFileA(h,&fileinfo) != FALSE);
        FindClose(h);
    }
    return a;
#else
    assert(0);
#endif
}
开发者ID:wolfwood,项目名称:dmd,代码行数:38,代码来源:root.c

示例2: DumpFiles

void DumpFiles( const Files& files, BOOL bOnlyFileName )
{
	if(files.empty())
	{
		_tprintf(_T("Empty Files\r\n"));
	}
	else
	{
		int i=0; 
		for(Files::const_iterator it=files.begin(); it!=files.end(); ++it)
		{
			++i;
			LPCTSTR szFile = *it;
			if(bOnlyFileName)
			{
				LPCTSTR szName = _tcsrchr(szFile, _T('\\'));
				if(szName)
					szFile = ++szName;
			}
			_tprintf(_T("%d/%d %s\r\n"), i, files.size(), szFile);
		}
	}
}
开发者ID:dreamsxin,项目名称:PcManager,代码行数:23,代码来源:Utils.cpp

示例3: GetFilesInDirectory

// Get a list of files in the given directory
Files GetFilesInDirectory(const std::string &path, const std::vector<std::string> &extensions)
{
	DIR *dir;
	dirent *entry;
	Files files;

	std::string finalPath = path;
	if (finalPath[path.size() - 1] != '/')
		finalPath += '/';

	if ((dir = opendir(path.c_str())))
	{
		while ((entry = readdir(dir)))
		{
			std::string filename = std::string(entry->d_name);
			if (filename == "." || filename == "..")
				continue;
			std::string fullPath = finalPath + filename;
			// Although the following function is for checking if a directory
			// exists, it can also be used to check if a path is a directory,
			// saving a little bit of extra code
			if (DirExists(fullPath))
				continue;
			// We want to skip any files not matching the extensions we gave, if any
			std::string thisExtension = GetExtension(filename);
			auto extensionMatch = std::find_if(extensions.begin(), extensions.end(), [&](const std::string &extension)
			{
				return extension == thisExtension;
			});
			if (extensions.empty() || extensionMatch != extensions.end())
				files.push_back(fullPath);
		}
		closedir(dir);
	}

	return files;
}
开发者ID:soneek,项目名称:SDATStuff,代码行数:38,代码来源:NCSF.cpp

示例4: inputFile

  Files ParallelEnergyPlusSplitJob::outputFilesImpl() const
  {
    // Save off the set of requiredfiles, see below
    std::vector<std::pair<QUrl, openstudio::path> > requiredFiles = inputFile().requiredFiles;
    std::vector<openstudio::path> files = generateFileNames(outdir(), m_numSplits);

    Files retval;

    for (std::vector<openstudio::path>::const_iterator itr = files.begin();
         itr != files.end();
         ++itr)
    {
      if (boost::filesystem::exists(*itr))
      {
        FileInfo fi = RunManager_Util::dirFile(*itr);
        // we want to carry along the set of required files used in the original IDF to the children
        // (ie, the epw file)
        fi.requiredFiles = requiredFiles;
        retval.append(fi);
      }
    }

    return retval;
  }
开发者ID:jtanaa,项目名称:OpenStudio,代码行数:24,代码来源:ParallelEnergyPlusSplitJob.cpp

示例5: log

/**
 * @brief Get the statistics and print them if necessary
 */
static Files &files() {
  static std::ofstream log(logFileName);
  static Files sinceLast;
  static Files total;
  // print the final statistics on exit
  static DestructionExecutor finalExecutor([&]() {
    log << "Statistics for thread " << getCurrentThreadId() << "\n";
    printStatistics(log, sinceLast);
    log << "Total statistics for thread " << getCurrentThreadId() << ":\n";
    total += sinceLast;
    printStatistics(log, total);
  });
  static DeltaTimeExecutor executor([&]() {
                                      log << "Statistics for thread "
                                          << getCurrentThreadId() << "\n";
                                      printStatistics(log, sinceLast);
                                      total += sinceLast;
                                      sinceLast.resetStatistics();
                                    },
                                    std::chrono::microseconds(1000 * 1000 *
                                                              10));
  executor.callIfTimeOver();
  return sinceLast;
}
开发者ID:schulmar,项目名称:filestats,代码行数:27,代码来源:io.cpp

示例6: Job_Impl

  EnergyPlusPreProcessJob::EnergyPlusPreProcessJob(const UUID &t_uuid,
      const Tools &tools,
      const JobParams &params,
      const Files &files,
      const JobState &t_restoreData)
    : Job_Impl(t_uuid, JobType::EnergyPlusPreProcess, tools, params, files, t_restoreData)
  {
    try {
      m_idf = files.getLastByExtension("idf");
      resetFiles(m_files, m_idf);
    } catch (const std::runtime_error &) {
    }

    m_description = buildDescription("idf");
  }
开发者ID:CUEBoxer,项目名称:OpenStudio,代码行数:15,代码来源:EnergyPlusPreProcessJob.cpp

示例7: TEST_F

TEST_F(RunManagerTestFixture, Workflow_FromWorkItems)
{
  ToolInfo ti("tool", openstudio::toPath("somepath"));
  Tools tis;
  tis.append(ti);

  JobParam param("param1");
  JobParams params;
  params.append(param);

  FileInfo fi(openstudio::toPath("somefile.txt"), "txt");
  Files fis;
  fis.append(fi);

  std::vector<WorkItem> wi;
  wi.push_back(WorkItem(JobType::Null, tis, params, fis));
  wi.push_back(WorkItem(JobType::EnergyPlus));

  Workflow wf(wi);

  EXPECT_EQ(tis, wf.tools());
  EXPECT_EQ(params, wf.params());
  EXPECT_EQ(fis, wf.files());
} 
开发者ID:jtanaa,项目名称:OpenStudio,代码行数:24,代码来源:Workflow_GTest.cpp

示例8: Job_Impl

  ModelToRadPreProcessJob::ModelToRadPreProcessJob(const UUID &t_uuid,
          const Tools &tools,
          const JobParams &params,
          const Files &files,
      const JobState &t_restoreData)
    : Job_Impl(t_uuid, JobType::ModelToRadPreProcess, tools, params, files, t_restoreData)
  {
    try {
      m_osm = files.getLastByExtension("osm");
      resetFiles(m_files, m_osm);
    } catch (const std::exception &) {
    }

    m_description = buildDescription("osm");
  }
开发者ID:ChengXinDL,项目名称:OpenStudio,代码行数:15,代码来源:ModelToRadPreProcessJob.cpp

示例9: Job_Impl

  ModelToRadJob::ModelToRadJob(const UUID &t_uuid,
          const Tools &tools,
          const JobParams &params,
          const Files &files,
      const JobState &t_restoreData)
    : Job_Impl(t_uuid, JobType::ModelToRad, tools, params, files, t_restoreData)
  {
    try {
      m_model = files.getLastByExtension("osm");
      resetFiles(m_files, m_model);
    } catch (const std::runtime_error &) {
    }

    m_description = buildDescription("osm");
  }
开发者ID:airguider,项目名称:OpenStudio,代码行数:15,代码来源:ModelToRadJob.cpp

示例10: Job_Impl

  OpenStudioPostProcessJob::OpenStudioPostProcessJob(const UUID &t_uuid,
          const Tools &tools,
          const JobParams &params,
          const Files &files,
      const JobState &t_restoreData)
    : Job_Impl(t_uuid, JobType::OpenStudioPostProcess, tools, params, files, t_restoreData)
  {
    try {
      m_sql = files.getLastByFilename("eplusout.sql");
      resetFiles(m_files, m_sql);
    } catch (const std::runtime_error &) {
    }

    // what should this be?
    m_description = buildDescription("sql");
  }
开发者ID:CUEBoxer,项目名称:OpenStudio,代码行数:16,代码来源:OpenStudioPostProcessJob.cpp

示例11: Job_Impl

  ParallelEnergyPlusSplitJob::ParallelEnergyPlusSplitJob(const UUID &t_uuid,
          const Tools &tools,
          const JobParams &params,
          const Files &files,
      const JobState &t_restoreData)
    : Job_Impl(t_uuid, JobType::ParallelEnergyPlusSplit, tools, params, files, t_restoreData),
      m_numSplits(boost::lexical_cast<int>(params.get("numsplits").children.at(0).value)),
      m_offset(boost::lexical_cast<int>(params.get("offset").children.at(0).value))
  {
    try {
      m_input = files.getLastByExtension("idf");
      resetFiles(m_files, m_input);
    } catch (const std::runtime_error &) {
    }

    m_description = buildDescription("idf");
  }
开发者ID:jtanaa,项目名称:OpenStudio,代码行数:17,代码来源:ParallelEnergyPlusSplitJob.cpp

示例12: TEST_F

TEST_F(FilesTest, AttachTest)
{
  Files files;
  ASSERT_SOME(os::write("file", "body"));
  ASSERT_SOME(os::mkdir("dir"));

  AWAIT_EXPECT_READY(files.attach("file", "myname"));       // Valid file.
  AWAIT_EXPECT_READY(files.attach("dir", "mydir"));         // Valid dir.
  AWAIT_EXPECT_READY(files.attach("file", "myname"));       // Re-attach.
  AWAIT_EXPECT_FAILED(files.attach("missing", "somename")); // Missing file.

  ASSERT_SOME(os::write("file2", "body"));

  AWAIT_EXPECT_READY(files.attach("file2", "myname"));  // Overwrite.
  AWAIT_EXPECT_FAILED(files.attach("[email protected]", "foo"));       // Bad path.
}
开发者ID:Benguang,项目名称:mesos,代码行数:16,代码来源:files_tests.cpp

示例13: getFiles

  void ExpandObjectsJob::getFiles(const Files &t_files) const
  {
    if (!m_idf)
    {
      try {
        m_idf = t_files.getLastByExtension("idf");


        if (!m_idf->hasRequiredFile(toPath("Energy+.idd")))
        {
          m_idf->addRequiredFile( toPath("Energy+.idd"), toPath("Energy+.idd"));
        }

      } catch (const std::runtime_error &) {
        // no idf set
      }
    }
  }
开发者ID:CUEBoxer,项目名称:OpenStudio,代码行数:18,代码来源:ExpandObjectsJob.cpp

示例14: main

int main(int argc,char **args) {

  bool Vanka=0, Gmres=0, Asm=0;
  if(argc >= 2) {
    if( !strcmp("vanka",args[1])) 	Vanka=1;
    else if( !strcmp("gmres",args[1])) 	Gmres=1;
    else if( !strcmp("asm",args[1])) 	Asm=1;
    
    if(Vanka+Gmres+Asm==0) {
      cout << "wrong input arguments!" << endl;
      exit(0);
    }
  }
  else {
    cout << "No input argument set default smoother = Gmres" << endl;
    Gmres=1;
  }
  
  /// Init Petsc-MPI communicator
  FemusInit mpinit(argc,args,MPI_COMM_WORLD);
  
  Files files; 
        files.CheckIODirectories();
        files.RedirectCout();

  /// INIT MESH =================================  
  
  unsigned short nm,nr;
  nm=2;
  std::cout<<"MULTIGRID levels: "<< nm << endl;

  nr=0;
  std::cout<<"MAX_REFINEMENT levels: " << nr << endl<< endl;
  
  int tmp=nm;  nm+=nr;  nr=tmp;
  
  char *infile = new char [50];
 
  sprintf(infile,"./input/nsbenc.neu");
  
  //Adimensional quantity (Lref,Uref)
  double Lref = 1.;
  double Uref = 1.;
  
  //Steadystate NonLinearMultiLevelProblem  
  //MultiLevelMesh ml_msh(nm,nr,infile,"seventh",Lref,SetRefinementFlag); 
  MultiLevelMesh ml_msh;
  ml_msh.ReadCoarseMesh(infile,"seventh",Lref);
  ml_msh.RefineMesh(nm,nr,NULL);
  
  // ml_msh.EraseCoarseLevels(2);
  
  MultiLevelSolution ml_sol(&ml_msh);
  
  // generate solution vector
  ml_sol.AddSolution("T",LAGRANGE,SECOND);
  ml_sol.AddSolution("U",LAGRANGE,SECOND);
  ml_sol.AddSolution("V",LAGRANGE,SECOND);
  // the pressure variable should be the last for the Schur decomposition
  ml_sol.AddSolution("P",DISCONTINOUS_POLYNOMIAL,FIRST);
  ml_sol.AssociatePropertyToSolution("P","Pressure");
 
  //Initialize (update Init(...) function)
  ml_sol.Initialize("U",InitVariableU);
  ml_sol.Initialize("V");
  ml_sol.Initialize("P");
  ml_sol.Initialize("T");
  
  //Set Boundary (update Dirichlet(...) function)
  ml_sol.AttachSetBoundaryConditionFunction(SetBoundaryCondition);
  ml_sol.GenerateBdc("U");
  ml_sol.GenerateBdc("V");
  ml_sol.GenerateBdc("P");
  ml_sol.GenerateBdc("T");
  
  MultiLevelProblem ml_prob(&ml_sol);
  
  // add fluid material
  Parameter parameter(Lref,Uref);
  
  // Generate fluid Object (Adimensional quantities,viscosity,density,fluid-model)
  Fluid fluid(parameter,0.001,1,"Newtonian",0.001,1.);
  cout << "Fluid properties: " << endl;
  cout << fluid << endl;
  
  ml_prob.parameters.set<Fluid>("Fluid") = fluid;
   
  
  //BEGIN Navier-Stokes Multilevel Problem
  std::cout << std::endl;
  std::cout << " *********** Navier-Stokes ************  " << std::endl;
    
  NonLinearImplicitSystem & system1 = ml_prob.add_system<NonLinearImplicitSystem> ("Navier-Stokes");
  system1.AddSolutionToSystemPDE("U");
  system1.AddSolutionToSystemPDE("V");
  system1.AddSolutionToSystemPDE("P");
  
  // Set MG Options
  system1.SetAssembleFunction(AssembleMatrixResNS);  
  system1.SetMaxNumberOfNonLinearIterations(3);
//.........这里部分代码省略.........
开发者ID:rushs777,项目名称:femus,代码行数:101,代码来源:main.cpp

示例15: main

int main(int argc,char **args) {
  
  /// Init Petsc-MPI communicator
  FemusInit mpinit(argc,args,MPI_COMM_WORLD);
  
  Files files; 
        files.CheckIODirectories();
        files.RedirectCout();
	
  /// INIT MESH =================================  
  
  unsigned short nm,nr;
  nm=4;
  std::cout<<"MULTIGRID levels: "<< nm << endl;

  nr=0;
  std::cout<<"MAX_REFINEMENT levels: " << nr << endl<< endl;
  
  int tmp=nm;  nm+=nr;  nr=tmp;
  
  char *infile = new char [50];
 
  sprintf(infile,"./input/nsbenchreg.neu");
  
  //Adimensional quantity (Lref,Uref)
  double Lref = 1.;
  double Uref = 1.;
  
  MultiLevelMesh ml_msh(nm,nr,infile,"seventh",Lref,NULL);
   
  MultiLevelSolution ml_sol(&ml_msh);
   
  // generate solution vector
  ml_sol.AddSolution("U",LAGRANGE,SECOND,2);
  ml_sol.AddSolution("V",LAGRANGE,SECOND,2);
  // the pressure variable should be the last for the Schur decomposition
  ml_sol.AddSolution("P",DISCONTINOUS_POLYNOMIAL,FIRST,1);
  ml_sol.AssociatePropertyToSolution("P","Pressure");
  
  //Initialize (update Init(...) function)
  ml_sol.Initialize("All");
  
  //Set Boundary (update Dirichlet(...) function)
  ml_sol.AttachSetBoundaryConditionFunction(SetBoundaryCondition);
  ml_sol.GenerateBdc("U","Time_dependent");
  ml_sol.GenerateBdc("V");
  ml_sol.GenerateBdc("P");

  
  MultiLevelProblem ml_prob(&ml_sol);
  
  
  Parameter parameter(Lref,Uref);
  
  // Generate fluid Object (Adimensional quantities,viscosity,density,fluid-model)
  Fluid fluid(parameter,0.001,1.,"Newtonian");
  cout << "Fluid properties: " << endl;
  cout << fluid << endl;  

  // add fluid material
  ml_prob.parameters.set<Fluid>("Fluid") = fluid;
  
  
 
  //create systems
  // add the system Navier-Stokes to the MultiLevel problem
  TransientNonlinearImplicitSystem & system = ml_prob.add_system<TransientNonlinearImplicitSystem> ("Navier-Stokes");
  system.AddSolutionToSystemPDE("U");
  system.AddSolutionToSystemPDE("V");
  system.AddSolutionToSystemPDE("P");
  
  // init all the systems
  system.init();
 
  // System Navier-Stokes
  system.SetAssembleFunction(AssembleMatrixResNS);  
  system.SetMaxNumberOfLinearIterations(1);
  system.SetLinearConvergenceTolerance(1.e-8);  
  system.SetMgType(V_CYCLE);
  system.SetMaxNumberOfNonLinearIterations(15);

  // time loop parameter
  system.SetIntervalTime(0.1);
  const unsigned int n_timesteps = 20;
  const unsigned int write_interval = 1;
  
  for (unsigned time_step = 0; time_step < n_timesteps; time_step++) {
   
    // Solving Navier-Stokes system
    std::cout << std::endl;
    std::cout << " *********** Navier-Stokes ************  " << std::endl;
    ml_prob.get_system("Navier-Stokes").solve();
   
    //update Solution
    ml_prob.get_system<TransientNonlinearImplicitSystem>("Navier-Stokes").UpdateSolution();

    // print solution
    if ( !(time_step%write_interval) ) {
        
      //print solution 
//.........这里部分代码省略.........
开发者ID:coyigg,项目名称:femus,代码行数:101,代码来源:main.cpp


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