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


C++ FileName::c_str方法代码示例

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


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

示例1: waitUntilStableSize

/* Wait until file has a stable size --------------------------------------- */
void FileName::waitUntilStableSize(size_t time_step)
{
    size_t idx;
    FileName basicName;
    decompose(idx, basicName);

    if (!exists())
        return;
    Stat info1, info2;
    if (stat(basicName.c_str(), &info1))
        REPORT_ERROR(ERR_UNCLASSIFIED,
                     (String)"FileName::waitUntilStableSize: Cannot get size of file " + *this);
    off_t size1 = info1.st_size;
    do
    {
        usleep(time_step);
        if (stat(basicName.c_str(), &info2))
            REPORT_ERROR(ERR_UNCLASSIFIED,
                         (String)"FileName::waitUntilStableSize: Cannot get size of file " + *this);
        off_t size2 = info2.st_size;
        if (size1 == size2)
            break;
        size1 = size2;
    }
    while (true);
    return;
}
开发者ID:I2PC,项目名称:scipion,代码行数:28,代码来源:xmipp_filename.cpp

示例2: storeFreeImage

  void storeFreeImage(const Ref<Image>& img, const FileName& fileName)
  {
      FIBITMAP* dib = FreeImage_Allocate((int)img->width, (int)img->height, 24);

      for(size_t y = 0; y < img->height; y++)
      {
          for(size_t x = 0; x < img->width; x++)
          {
			  Color4 c = img->get(x, y);
              
              RGBQUAD Value = {0};
              Value.rgbRed   = (BYTE)(clamp(c.r) * 255.0f);
              Value.rgbGreen = (BYTE)(clamp(c.g) * 255.0f);
              Value.rgbBlue  = (BYTE)(clamp(c.b) * 255.0f);

              FreeImage_SetPixelColor(dib, (unsigned int)x, (unsigned int)y, &Value);
          }
      }

      FIBITMAP* fiLogo = loadWatermark();

      unsigned int LogoWidth  = FreeImage_GetWidth (fiLogo);
      unsigned int LogoHeight = FreeImage_GetHeight(fiLogo);

      if(LogoWidth > img->width || LogoHeight > img->height)
      {
          FreeImage_Unload(fiLogo);

          FREE_IMAGE_FORMAT fif = FreeImage_GetFIFFromFilename(fileName.c_str());
          if(FreeImage_FIFSupportsWriting(fif))
              FreeImage_Save(fif, dib, fileName.c_str());

          FreeImage_Unload(dib);
      }
      else
      {
          int x_pos = (int)img->width  - LogoWidth;
          int y_pos = (int)img->height - LogoHeight;

          FIBITMAP* fiFG = FreeImage_Allocate((int)img->width, (int)img->height, 32);
          BOOL b = FreeImage_Paste(fiFG, fiLogo, x_pos, y_pos, 255);
          FreeImage_Unload(fiLogo);

          FIBITMAP* fiNew = FreeImage_Composite(fiFG, FALSE, NULL, dib);
          FreeImage_Unload(dib);

          FREE_IMAGE_FORMAT fif = FreeImage_GetFIFFromFilename(fileName.c_str());

          int save_flags = 0;
          if(fif == FIF_JPEG)
              save_flags = JPEG_QUALITYSUPERB | JPEG_BASELINE | JPEG_OPTIMIZE;

          if(FreeImage_FIFSupportsWriting(fif))
              FreeImage_Save(fif, fiNew, fileName.c_str(), save_flags);

          FreeImage_Unload(fiNew);
      }
  }
开发者ID:remledevries,项目名称:Theseus-2.4,代码行数:58,代码来源:image_wrapper.cpp

示例3: setWorkingDirectory

bool setWorkingDirectory(const FileName &path)
{
    int result = -1;

#ifdef _WIN32
    result = _chdir(path.c_str());
#else
    result = chdir(path.c_str());
#endif

    return result >= 0;
}
开发者ID:foxostro,项目名称:heroman,代码行数:12,代码来源:FileFuncs.cpp

示例4: eval

// Compute fitness =========================================================
double ObjFunc_nma_alignment::eval(Vector X, int *nerror) {
	int dim = global_nma_prog->numberOfModes;

	for (int i = 0; i < dim; i++) {
		global_nma_prog->trial(i) = X[i];
	}

	int pyramidLevelDisc = 1;
	int pyramidLevelCont = (global_nma_prog->currentStage == 1) ? 1 : 0;

	FileName fnRandom = global_nma_prog->createDeformedPDB(pyramidLevelCont);
	const char * randStr = fnRandom.c_str();

	if (global_nma_prog->currentStage == 1) {
		global_nma_prog->performCompleteSearch(fnRandom, pyramidLevelDisc);
	} else {
		double rot, tilt, psi, xshift, yshift;
		MetaData DF;

		rot = global_nma_prog->bestStage1(
				VEC_XSIZE(global_nma_prog->bestStage1) - 5);
		tilt = global_nma_prog->bestStage1(
				VEC_XSIZE(global_nma_prog->bestStage1) - 4);
		psi = global_nma_prog->bestStage1(
				VEC_XSIZE(global_nma_prog->bestStage1) - 3);
		xshift = global_nma_prog->bestStage1(
				VEC_XSIZE(global_nma_prog->bestStage1) - 2);
		yshift = global_nma_prog->bestStage1(
				VEC_XSIZE(global_nma_prog->bestStage1) - 1);

		size_t objId = DF.addObject();
		FileName fnDown = formatString("%s_downimg.xmp", randStr);
		DF.setValue(MDL_IMAGE, fnDown, objId);
		DF.setValue(MDL_ENABLED, 1, objId);
		DF.setValue(MDL_ANGLE_ROT, rot, objId);
		DF.setValue(MDL_ANGLE_TILT, tilt, objId);
		DF.setValue(MDL_ANGLE_PSI, psi, objId);
		DF.setValue(MDL_SHIFT_X, xshift, objId);
		DF.setValue(MDL_SHIFT_Y, yshift, objId);

		DF.write(formatString("%s_angledisc.xmd", randStr));
		copyImage(global_nma_prog->currentImgName.c_str(), fnDown.c_str());
	}
	double fitness = global_nma_prog->performContinuousAssignment(fnRandom,
			pyramidLevelCont);

	runSystem("rm", formatString("-rf %s* &", randStr));

	global_nma_prog->updateBestFit(fitness, dim);
	return fitness;
}
开发者ID:josegutab,项目名称:scipion,代码行数:52,代码来源:nma_alignment.cpp

示例5: file

  /*! load an EXR file from disk */
  Ref<Image> loadExr(const FileName& filename)
  {
    Imf::RgbaInputFile file (filename.c_str());
    Imath::Box2i dw = file.dataWindow();
    ssize_t width = dw.max.x - dw.min.x + 1;
    ssize_t height = dw.max.y - dw.min.y + 1;

    Imf::Array2D<Imf::Rgba> pixels(height, width);
    file.setFrameBuffer (&pixels[0][0] - dw.min.x - dw.min.y * width, 1, width);
    file.readPixels (dw.min.y, dw.max.y);

    Ref<Image> img = new Image3f(width,height,filename);

    if (file.lineOrder() == Imf::INCREASING_Y) {
      for (ssize_t y=0; y<height; y++) {
        for (ssize_t x=0; x<width; x++) {
          Imf::Rgba c = pixels[y][x];
          img->set(x,y,Color4(c.r,c.g,c.b,c.a));
        }
      }
    }
    else {
      for (ssize_t y=0; y<height; y++) {
        for (ssize_t x=0; x<width; x++) {
          Imf::Rgba c = pixels[y][x];
          img->set(x,height-y-1,Color4(c.r,c.g,c.b,c.a));
        }
      }
    }

    return img;
  }
开发者ID:Dade916,项目名称:embree,代码行数:33,代码来源:exr.cpp

示例6: loadFile

      void loadFile(const FileName &fileName)
      {
        std::string extension = fileName.ext();

        if (extension == "vtp")
          loadVTKFile<vtkXMLPolyDataReader>(fileName.c_str());
      }
开发者ID:ingowald,项目名称:OSPRay,代码行数:7,代码来源:importVTKPolyData.cpp

示例7: isFileOnDisk

bool isFileOnDisk(const FileName &fileName)
{
	struct stat info;

	// if we can stat the file, then it does exist
	return (stat(fileName.c_str(), &info) == 0);
}
开发者ID:foxostro,项目名称:heroman,代码行数:7,代码来源:FileFuncs.cpp

示例8: getDarkfield

void ProgXrayImport::getDarkfield(const FileName &fnDir, Image<double> &IavgDark)
{
    IavgDark.clear();
    std::vector<FileName> listDir;
    fnDir.getFiles(listDir);

    for (size_t i=0; i<listDir.size(); i++)
        if (listDir[i]=="darkfields")
        {
            std::cout << formatString("Getting darkfield from %s/darkfields",fnDir.c_str()) << " ..." << std::endl;

            darkFix = true;
            std::vector<FileName> listDirDark;
            FileName(fnDir+"/darkfields").getFiles(listDirDark);
            int N = 0;

            for (size_t j=0; j<listDirDark.size(); j++)
            {
                if (!listDirDark[j].hasImageExtension())
                    continue;
                Image<double> Iaux;
                readAndCrop(fnDir+"/darkfields/"+listDirDark[j],Iaux, cropSizeX, cropSizeY);
                if (N==0)
                    IavgDark()=Iaux();
                else
                    IavgDark()+=Iaux();
                N++;
            }
            if (N==0)
                REPORT_ERROR(ERR_IO_NOTEXIST,"darkfields directory is empty");
            IavgDark()*=1.0/N;
            break;
        }
}
开发者ID:coocoky,项目名称:scipion,代码行数:34,代码来源:xray_import.cpp

示例9: loadHairASCII

  int loadHairASCII(const FileName& fileName, OBJScene::HairSet* hairset, Vec3fa& offset)
  {  
    /* open hair file */
    FILE* f = fopen(fileName.c_str(),"r");
    if (!f) throw std::runtime_error("could not open " + fileName.str());

    char line[10000];
    fgets(line,10000,f);
    int numCurves = 0;
    
    while (fgets(line,10000,f) && !feof(f))
    {
      /* comment */
      if (line[0] == '#')
	continue;
      
      if (!strncmp(line,"Curve:",strlen("Curve:")))
      {
        char name[1000];
        unsigned int tracks, points;
        sscanf(line,"Curve: %s %d Tracks %d Points",name,&tracks,&points);

        /* skip Tracks line */
        fgets(line,10000,f);
        
        const int vertex_start_id = hairset->v.size();
        
        double x,y,z,w;
        unsigned int id = 0;
        for (int i=0; i<points; i++)
        {
          fgets(line,10000,f);

          /* comment */
          if (line[0] == '#' || !strncmp(line," Tracks:",strlen(" Tracks:")))
            continue;

          Vec3fa v;
          if (i == 0) sscanf(line,"%d : Bezier %f %f %f %f",&id,&v.x,&v.y,&v.z,&v.w);
          else        sscanf(line,"%d : %f %f %f %f",&id,&v.x,&v.y,&v.z,&v.w);
          //printf("%d %d : %f %f %f %f \n",id,vertex_start_id+id,v.x,v.y,v.z,v.w);		
          v.x-=offset.x;
          v.y-=offset.y;
          v.z-=offset.z;
          hairset->v.push_back(v);
        }
        
        /* add indices to hair starts */
        for (int i=0; i<points-1; i+=3)
          hairset->hairs.push_back(OBJScene::Hair(vertex_start_id + i,numCurves));
	
        if (id != points-1) 
          throw std::runtime_error("hair parsing error");

        numCurves++;
      }
    }
    fclose(f);
    return numCurves;
  }
开发者ID:cpaalman,项目名称:embree,代码行数:60,代码来源:hair_loader.cpp

示例10: performContinuousAssignment

// Continuous assignment ===================================================
double ProgNmaAlignment::performContinuousAssignment(const FileName &fnRandom,
		int pyramidLevel) const {
	// Perform alignment
	const char * randStr = fnRandom.c_str();
	String fnResults=formatString("%s_anglecont.xmd", randStr);
	bool costSource=true;
	String program = "xmipp_angular_continuous_assign";
	String arguments =
			formatString(
					"-i %s_angledisc.xmd --ref %s_deformedPDB.vol -o %s --gaussian_Fourier %f --gaussian_Real %f --zerofreq_weight %f -v 0",
					randStr, randStr, fnResults.c_str(), gaussian_DFT_sigma,
					gaussian_Real_sigma, weight_zero_freq);
	runSystem(program, arguments, false);

	// Pick up results
	MetaData DF(fnResults);
	MDRow row;
	DF.getRow(row, DF.firstObject());
	row.getValue(MDL_ANGLE_ROT, trial(VEC_XSIZE(trial) - 5));
	row.getValue(MDL_ANGLE_TILT, trial(VEC_XSIZE(trial) - 4));
	row.getValue(MDL_ANGLE_PSI, trial(VEC_XSIZE(trial) - 3));
	row.getValue(MDL_SHIFT_X, trial(VEC_XSIZE(trial) - 2));
	trial(VEC_XSIZE(trial) - 2) *= pow(2.0, (double) pyramidLevel);
	row.getValue(MDL_SHIFT_Y, trial(VEC_XSIZE(trial) - 1));
	trial(VEC_XSIZE(trial) - 1) *= pow(2.0, (double) pyramidLevel);
	double tempvar;
	if (!costSource) {
		row.getValue(MDL_MAXCC, tempvar);
		tempvar = -tempvar;
	} else
		row.getValue(MDL_COST, tempvar);
	return tempvar;
}
开发者ID:josegutab,项目名称:scipion,代码行数:34,代码来源:nma_alignment.cpp

示例11: NetCdfException

  DataFile::DataFile (FileName const &fileName)
  {

    #ifdef DEBUG
      std::cout << "open NetCDF file : " << fileName << std::endl;
    #endif

    int status = nc_open(fileName.c_str(),
                         NC_SHARE|NC_DISKLESS|NC_MMAP,
                         &handle_);
   /* 
    * NC_SHARE : from doc : Since the buffering scheme is optimized 
    * for sequential access, programs that do not access data sequentially
    * may see some performance improvement by setting the NC_SHARE flag.
    * 
    * NC_DISKLESS : for allowing NC_MMAP. Side effect : any changes
    * performed to the files won't be saved on exit. Not an issue for us. 
    * 
    * NC_MMAP : for mapping the file to virtual memory, and let the linux
    * kernel do the RAM cache management for us. See `man mmap`.
    * To use this flag, NetCDF must be compiled with ./configure --enable-mmap
    * Ubuntu's libnetcdf doesn't include mmap support.
    */

    if (status != NC_NOERR)
    {
      throw NetCdfException ("error opening " + fileName + ":\n"
                                                        + nc_strerror(status));
    }

    #ifdef DEBUG
      std::cout << "handle : #" << handle_ << std::endl;
    #endif

  }
开发者ID:Dale-M,项目名称:MeteoDataServer,代码行数:35,代码来源:datafile.cpp

示例12: fopen

vector<KeyFrame>
ModelLoaderMD3::loadKeyFrames(const FileName &fileName,
                              const FileName &skinName,
                              TextureFactory &textureFactory) const {
	FILE * stream = fopen(fileName.c_str(), "rb");

	
	VERIFY(stream && !ferror(stream), "MD3 failed to open: "+fileName.str());
	
	Header header = readHeader(stream);
	
	Frame *frames = readFrames(stream, header);
	
	Tag *tags = readTags(stream, header);
	
	Surface *surfaces = readSurfaces(stream, header);
	
	fclose(stream);
	
	vector<KeyFrame> keyFrames = buildKeyFrame(surfaces,
	                             fileName,
	                             skinName,
	                             header,
	                             textureFactory);
	                             
	delete [] frames;
	delete [] tags;
	delete [] surfaces;
	
	return keyFrames;
}
开发者ID:,项目名称:,代码行数:31,代码来源:

示例13: run

    void run()
    {
    	std::string extension=fnStack.getExtension();
    	if (extension=="mrc")
    		fnStack+=":mrcs";
    	else if (extension=="ali")
    		fnStack+=":mrcs";

    	std::ifstream fhAngles;
    	fhAngles.open(fnAngles.c_str());
    	if (!fhAngles)
    		REPORT_ERROR(ERR_IO_NOTOPEN,fnAngles);

    	Image<double> stack;
    	stack.read(fnStack, HEADER);
    	size_t xdim, ydim, zdim, ndim;
    	stack.getDimensions(xdim, ydim, zdim, ndim);

    	MetaData MD;
    	FileName fnSlice;
    	for (unsigned long slice = FIRST_IMAGE; slice <= ndim; slice++)
    	{
    		double angle;
    		fhAngles >> angle;
    		fnSlice.compose((int)slice,fnStack);
    		size_t objId=MD.addObject();
    		MD.setValue(MDL_IMAGE,fnSlice,objId);
    		MD.setValue(MDL_ANGLE_TILT,angle,objId);
    		MD.setValue(MDL_ENABLED,1,objId);
    	}
    	MD.write(fnOut);
    }
开发者ID:I2PC,项目名称:scipion,代码行数:32,代码来源:mrc_create_metadata_main.cpp

示例14: copyFile

void FileName::copyFile(const FileName & target) const
{
    std::ifstream f1(this->c_str(), std::fstream::binary);
    std::ofstream
    f2(target.c_str(), std::fstream::trunc | std::fstream::binary);
    f2 << f1.rdbuf();
}
开发者ID:I2PC,项目名称:scipion,代码行数:7,代码来源:xmipp_filename.cpp

示例15: storeTga

  void storeTga(const Ref<Image>& img, const FileName& fileName)
  {
    FILE* file = fopen(fileName.c_str(), "wb");
    if (!file) THROW_RUNTIME_ERROR("error opening file " + fileName.str());

    fwrite_uchar(0x00, file);
    fwrite_uchar(0x00, file);
    fwrite_uchar(0x02, file);
    fwrite_ushort(0x0000, file);
    fwrite_ushort(0x0000, file);
    fwrite_ushort(0x0000, file);
    fwrite_ushort(0x0000, file);
    fwrite_uchar(0x00, file);
    fwrite_ushort((unsigned short)img->width , file);
    fwrite_ushort((unsigned short)img->height, file);
    fwrite_uchar(0x18, file);
    fwrite_uchar(0x20, file);

    for (size_t y=0; y<img->height; y++) {
      for (size_t x=0; x<img->width; x++) {
        Color c = img->get(x,y);
        fwrite_uchar((unsigned char)(clamp(c.b)*255.0f), file);
        fwrite_uchar((unsigned char)(clamp(c.g)*255.0f), file);
        fwrite_uchar((unsigned char)(clamp(c.r)*255.0f), file);
      }
    }
    fclose(file);
  }
开发者ID:appleseedhq,项目名称:appleseed-deps,代码行数:28,代码来源:tga.cpp


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