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


C++ fexists函数代码示例

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


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

示例1: main

int main() {

  // Read in the graph
  // Verify the input files are available for reading
  bool rc;
  std::string graphfile = "g10.txt";
  std::string searchfile = "g10_search.txt";

  rc = fexists(graphfile);
  if ( !rc ) {
    std::cerr << " File " << graphfile << " not found! Exiting... " << std::endl;
    return 0;
  }
  rc = fexists(searchfile);
  if ( !rc ) {
    std::cerr << " File " << searchfile << " not found! Exiting... " << std::endl;
    return 0;
  }

  std::vector<std::size_t> nodelist,neighborlist;
  {
    std::ifstream myfile(graphfile.c_str());
    if (myfile.is_open()) {
      std::size_t node, neighbor;
      while (myfile >> node >> neighbor) {
        // increment all nodes and neighbors by 1; the smallest edge number is 1
        // edge 0 is reserved for the parent of the root and for unvisited edges
        nodelist.push_back(node+1);
        neighborlist.push_back(neighbor+1);
      }
    }
  }
开发者ID:hengzhang,项目名称:hpx_bfs_test,代码行数:32,代码来源:bfsc.cpp

示例2: _load_index

// load index if it hasn't been set already:
void
bam_streamer::
_load_index()
{
    /// TODO: Find out whether _hidx can be destroyed after the HTS
    /// iterator is created, in which case this could be a local
    /// variable. Until we know, _hidx should persist for the lifetime
    /// of _hiter
    if (nullptr != _hidx) return;

    std::string index_base(name());

    // hack to allow GATK/Picard bai name convention:
    if ((! fexists((index_base+".bai").c_str())) &&
        (! fexists((index_base+".csa").c_str())) &&
        (! fexists((index_base+".crai").c_str())))
    {
        static const std::string bamext(".bam");
        if (hasEnding(index_base,bamext))
        {
            index_base=index_base.substr(0,index_base.length()-bamext.length());
        }
    }

    _hidx = sam_index_load(_bfp->file, index_base.c_str());
    if (nullptr == _hidx)
    {
        log_os << "ERROR: BAM/CRAM index is not available for file: " << name() << "\n";
        exit(EXIT_FAILURE);
    }
}
开发者ID:EthidiumIodide,项目名称:manta,代码行数:32,代码来源:bam_streamer.cpp

示例3: dirname

bool SettingRegistry::getDefinitionFile(const std::string machine_id, const std::string parent_file, std::string& result)
{
    // check for file in same directory as the file provided
    std::string parent_filename_copy = std::string(parent_file.c_str()); // copy the string because dirname(.) changes the input string!!!
    char* parent_filename_cstr = (char*)parent_filename_copy.c_str();
    result = std::string(dirname(parent_filename_cstr)) + std::string("/") + machine_id + std::string(".def.json");
    if (fexists(result.c_str()))
    {
        return true;
    }

    // check for file in the directories supplied in the environment variable CURA_ENGINE_SEARCH_PATH
    char* paths = getenv("CURA_ENGINE_SEARCH_PATH");
    if (paths)
    {
#if defined(__linux__) || (defined(__APPLE__) && defined(__MACH__))
        char delims[] = ":"; // colon
#else
        char delims[] = ";"; // semicolon
#endif
        char* path = strtok(paths, delims); // search for next path delimited by any of the characters in delims
        while (path != NULL)
        {
            result = std::string(path) + std::string("/") + machine_id + std::string(".def.json");
            if (fexists(result.c_str()))
            {
                return true;
            }
            path = strtok(NULL, ";:,"); // continue searching in last call to strtok
        }
    }
    return false;
}
开发者ID:sparklexy,项目名称:CuraEngine,代码行数:33,代码来源:SettingRegistry.cpp

示例4: getline

//Basic Init, create the font, backbuffer, etc
WINDOW *initscr(void)
{
    lastchar=-1;
    inputdelay=-1;

    std::string typeface = "";
	std::ifstream fin;
    int fontsize = 0; //actuall size
	fin.open("data/FONTDATA");
	if (!fin.is_open()){
        fontheight=16;
        fontwidth=8;
	} else {
        getline(fin, typeface);
        fin >> fontwidth;
        fin >> fontheight;
        fin >> fontsize;
        if ((fontwidth <= 4) || (fontheight <=4)){
            fontheight=16;
            fontwidth=8;
		}
		fin.close();
	}

    halfwidth=fontwidth / 2;
    halfheight=fontheight / 2;
    WindowWidth= (55 + (OPTIONS[OPT_VIEWPORT_X] * 2 + 1)) * fontwidth;
    WindowHeight= (OPTIONS[OPT_VIEWPORT_Y] * 2 + 1) *fontheight;
    if(!WinCreate()) {}// do something here
    
    //make fontdata compatible with wincurse
    if(!fexists(typeface.c_str()))
        typeface = "data/font/" + typeface + ".ttf";

    //different default font with wincurse
    if(!fexists(typeface.c_str()))
        typeface = "data/font/fixedsys.ttf";

    if(fontsize<=0) fontsize=fontheight-1;
	font = TTF_OpenFont(typeface.c_str(), fontsize);

    //if(!font) something went wrong

	TTF_SetFontStyle(font, TTF_STYLE_NORMAL);
	//TTF_SetFontOutline(font, 0);
	//TTF_SetFontKerning(font, 0);
	//TTF_SetFontHinting(font, TTF_HINTING_MONO);

	// glyph height hack by utunnels 
	// SDL_ttf doesn't use FT_HAS_VERTICAL for function TTF_GlyphMetrics
	// this causes baseline problems for certain fonts 
	// I can only guess by check a certain tall character...
    cache_glyphs();


    mainwin = newwin((OPTIONS[OPT_VIEWPORT_Y] * 2 + 1),(55 + (OPTIONS[OPT_VIEWPORT_Y] * 2 + 1)),0,0);
    return mainwin;   //create the 'stdscr' window and return its ref
}
开发者ID:Vengarr,项目名称:Cataclysm-DDA,代码行数:59,代码来源:sdlcurse.cpp

示例5: slasher

///////////////////////////////////////////////////////////
/// Find font
///////////////////////////////////////////////////////////
std::string FileFinder::FindFont(std::string name) {
	name = slasher(name);
	std::string path;
	path = name;
	if (fexists(path)) return path;
	path = name; path += ".ttf";
	if (fexists(path)) return path;

	path = fonts_path; path += name;
	if (fexists(path)) return path;
	path = fonts_path; path += name; path += ".ttf";
	if (fexists(path)) return path;

	std::string real_name;
	real_name = Registry::ReadStrValue(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts", name + " (TrueType)");
	if (real_name.length() > 0) {
		path = real_name;
		if (fexists(path)) return path;
		path = fonts_path; path += real_name;
		if (fexists(path)) return path;
	}

	real_name = Registry::ReadStrValue(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Fonts", name + " (TrueType)");
	if (real_name.length() > 0) {
		path = real_name;
		if (fexists(path)) return path;
		path = fonts_path; path += real_name;
		if (fexists(path)) return path;
	}

	return "";
}
开发者ID:cstrahan,项目名称:argss,代码行数:35,代码来源:filefinder.cpp

示例6: file_is_modified

long file_is_modified(const char *inputfile, char **final_file, struct stat *input_stat) {
  struct stat filestat;
  char *tempfile=NULL;
  const char *tmpinput=NULL;
  
  if (!fexists(inputfile)) {
    fprintf(stderr,"%s file does not exist!\n",inputfile);
    exit(1);
  }
  if (*final_file && !fexists(*final_file)) {
    fprintf(stderr,"linked file %s of inputfile %s does not exist!\n",*final_file,inputfile);
    exit(1);
  }
  if (!input_stat) {
    fprintf(stderr,"The previous state of file %s is not known.\n",inputfile);
    exit(1);
  }
  
  tempfile=read_last_link_to_file(inputfile);
  
  /*the final link name changed */
  if (tempfile && *final_file && strcmp(tempfile,*final_file)) {
    if (*final_file) free(*final_file);
    *final_file=tempfile;
    return 1;
  }
  if ((tempfile && !(*final_file)) || (!tempfile && *final_file)) {
    if (*final_file) free(*final_file);
    *final_file=tempfile;
    return 1;
  }
  /* the final link name did not change, check if the file state changed */
  if (tempfile) free(tempfile);
  if (*final_file)
    tmpinput=*final_file;
  else 
    tmpinput=inputfile;
  filestat=*input_stat;
  if (stat(tmpinput,input_stat)!=0) {
    fprintf(stderr, "Problem getting modification time for %s\n", tmpinput);
    exit(1);
  }
  if (input_stat->st_ctime != filestat.st_ctime) {
    /* file state is changed */
    return 1;
  }
  return 0;
}
开发者ID:veprbl,项目名称:epics-sdds,代码行数:48,代码来源:filestat.c

示例7: strlen

char *download_from_remote(const char *url)
{
  const int buf_size = 1 * 1024 * 1024;
  char *fn;
  FILE *fp;
  uint8_t *buf;
  knetFile *fp_remote;
  int l;
  l = strlen(url);
  for (fn = (char*)url + l - 1; fn >= url; --fn)
    if (*fn == '/') break;
  ++fn; // fn now points to the file name
  if(fexists(fn))
    return fn;
  fprintf(stderr, "attempting to download the remote index file: %s\n",url);
  extern std::vector <char *> dumpedFiles;
  dumpedFiles.push_back(strdup(fn));
  fp_remote = knet_open(url, "r");
  if (fp_remote == 0) {
    fprintf(stderr, "Fail to open remote file:%s\n",url);
    exit(0);
  }
  if ((fp = fopen(fn, "wb")) == 0) {
    fprintf(stderr, "Fail to save remote file:%s in working dir\n",url);
    exit(0);
    knet_close(fp_remote);
  }
  buf = (uint8_t*)calloc(buf_size, 1);
  while ((l = knet_read(fp_remote, buf, buf_size)) != 0)
    fwrite(buf, 1, l, fp);
  free(buf);
  fclose(fp);
  knet_close(fp_remote);
  return fn;
}
开发者ID:libor-m,项目名称:angsd,代码行数:35,代码来源:bammer_main.cpp

示例8: getRegions

std::vector<char*> getRegions(const char * name){
  if(!fexists(name)){
    fprintf(stderr,"\t-> Problems opening file: %s\n",name);
    exit(0);
  }
  const char* delims = " \t\n\r";
  std::vector<char*> ret;
  FILE *fp =getFILE(name,"r");
  char buffer[fsize(name)+1];
  if(fsize(name)!=fread(buffer,1,fsize(name),fp))
    fprintf(stderr,"[%s] Problems reading %lu from: %s\n",__FUNCTION__,fsize(name),name);
  buffer[fsize(name)]='\0';
  
  char *tok = strtok(buffer,delims);

  while(tok!=NULL){
    if(tok[0]!='#'){
      ret.push_back(strdup(tok));
    }
    tok = strtok(NULL,delims);
  }

  fprintf(stderr,"\t-> From regionsfile: %s we read %lu\n",name,ret.size());
  fclose(fp);
  return ret;
}
开发者ID:libor-m,项目名称:angsd,代码行数:26,代码来源:bammer_main.cpp

示例9: do_savefit_proc

static void do_savefit_proc(Widget w, XtPointer client_data, XtPointer call_data)
{
    char *s;
    
    XmFileSelectionBoxCallbackStruct *cbs = (XmFileSelectionBoxCallbackStruct *) call_data;
    if (!XmStringGetLtoR(cbs->value, charset, &s)) {
	errmsg("Error converting XmString to char string in do_savefit_proc()");
	return;
    }
    
    if (!fexists(s)) {
	FILE *pp = fopen(s, "w");
	if (pp != NULL) {
	    set_wait_cursor();
	    strcpy(nonl_opts.title, (char *) xv_getstr(save_title_item));
	    put_fitparms(pp, 0);
	    fclose(pp);
	    unset_wait_cursor();
	} else {
	    errmsg("Unable to open file");
	}
    }
    
    XtFree(s);
}
开发者ID:TehTreag,项目名称:xmgr-resurrection,代码行数:25,代码来源:nonlwin.c

示例10: DebugPrintToFile

	int HtlDebugPrinter::DebugPrintToFile(char *format, va_list args)
	{
		int intReturn = 0;
		try{
			//va_start( args, format );

			if(m_blnPrintToFile)
				//FILE OUTPUT SECTION
			{//print to the file...
				//Open the output file to append to it
				FILE *stream;
				std::string strFile = m_strFileName.c_str();
				if(fexists(strFile.c_str()))
				{
					//stream = fopen( m_strPrintFileName.c_str(),"w"); //We want this one to overwrite
					stream = fopen(  strFile.c_str() ,"a");//a for appending to existing file
				}else{
					stream = fopen(  strFile.c_str() ,"w");//We want this one to overwrite
				}
				intReturn = vfprintf( stream, format, args );
				fclose(stream);
			};
			//va_end(args);
			return intReturn;
		}catch(...){
			return -1;
		};
		return 0;
	};
开发者ID:trident99,项目名称:HpcTemplateLibrary,代码行数:29,代码来源:HtlDebugPrinter.cpp

示例11: load

// Load tiles
void tile_type_manager::load( std::string newFile){
  // Load biomes from file
  rapidxml::xml_document<> doc;
  std::ifstream file;

  // Check exist
  if( fexists(newFile.c_str())){
    file.open(newFile.c_str());
  }
  else{
    abort_on_error( std::string("Cannot find file " + newFile + " \n Please check your files and try again").c_str());
  }

  std::stringstream buffer;
  buffer << file.rdbuf();
  std::string content(buffer.str());
  doc.parse<0>(&content[0]);

  rapidxml::xml_node<> *allTiles = doc.first_node();

  // Loading
  std::cout << "   TILES\n-------------\n";

  // Load tiles
  for(rapidxml::xml_node<> *cTile=allTiles-> first_node("tile"); cTile; cTile=cTile->next_sibling()){
    // Read xml variables
    // General
    int tileID = atoi(cTile-> first_attribute("id") -> value());
    std::string name = cTile-> first_node("name") -> value();
    std::string image1 = cTile-> first_node("images") -> first_node("image") -> value();
    std::string image2 = cTile-> first_node("images") -> first_node("image2") -> value();
    std::string model = cTile-> first_node("model") -> value();
    int randomness = atoi(cTile-> first_node("random") -> value());

    std::string attrubite_string = cTile-> first_node("attrubite") -> value();
    int attrubite = ATTRIBUTE_GAS;

    // Get attrubite
    if( attrubite_string == "ATTRIBUTE_GAS")
      attrubite = ATTRIBUTE_GAS;
    else if( attrubite_string == "ATTRIBUTE_SOLID")
      attrubite = ATTRIBUTE_SOLID;
    else if( attrubite_string == "ATTRIBUTE_LIQUID")
      attrubite = ATTRIBUTE_LIQUID;

    // Draw to screen (debug)
    std::cout << "-> Loading Tile:" << name << "  ID:" <<  tileID << "  MODEL:" << model << "  ATTRIBUTE:" << attrubite_string << "  RANDOMNESS:" << randomness << "\n";

    // Create tile, set variables and add it to the tile list
    tile_type newTileType( name, tileID, NULL, model, attrubite, randomness);

    // Set images
    newTileType.setImages( image1, image2);

    // Add the tile
    tile_defs.push_back( newTileType);
  }

  std::cout << "\n\n";
}
开发者ID:alegemaate,项目名称:Forager,代码行数:61,代码来源:tile_type_manager.cpp

示例12: getFILE

// getFILE is a wrapper for getting files
bool getFILE(std::fstream &fp, const char* fname, const char* mode)
{
	int writeFile = 0;
	if (strcmp(mode, "out") == 0)
	{
		writeFile = 1;
		if(writeFile && fexists(fname))
		{
			fprintf(stderr,"File already exists: %s\n",fname);
			return false;
		}

		fp.open(fname, std::ios::out);
	}
	else if (strcmp(mode, "app") == 0)
		fp.open(fname, std::ios::app);
	else if (strcmp(mode, "in") == 0)
		fp.open(fname, std::ios::in);

	if( !fp )
	{
		fprintf(stderr,"Error opening FILE handle for file: %s\n",fname);
		fp.close();
		return false;
	}
	return true;
}
开发者ID:tplinderoth,项目名称:ngsParalog,代码行数:28,代码来源:generalUtils.cpp

示例13: copy_plist

/*
 * Copy unmarked files in packing list to playpen - marked files
 * have already been copied in an earlier pass through the list.
 */
void
copy_plist(char *home, Package *plist)
{
    PackingList p = plist->head;
    char *where = home;

    while (p) {
	if (p->type == PLIST_CWD)
	    where = p->name;
	else if (p->type == PLIST_IGNORE)
	    p = p->next;
	else if (p->type == PLIST_FILE && !p->marked) {
	    char fn[FILENAME_MAX];

	    /* First, look for it in the "home" dir */
	    sprintf(fn, "%s/%s", home, p->name);
	    if (fexists(fn))
		copy_hierarchy(home, p->name, FALSE);
	    /*
	     * Otherwise, try along the actual extraction path..
	     */
	    else
		copy_hierarchy(where, p->name, FALSE);
	}
	p = p->next;
    }
}
开发者ID:unusual-thoughts,项目名称:freebsd-1.x-ports,代码行数:31,代码来源:pl.c

示例14: check_lockout

static int
check_lockout(const char *hostname) {

    char frog[85];
    FILE *fp = NULL;

    if (fexists(".nonew")) {
        more(NONEWMSG, 0);
        sleep(1);
        return 0;
    }

    fp = xfopen(LOCKOUTFILE, "r", FALSE);
    if (fp != NULL) {
        while (fgets(frog, 84, fp)) {
            if (frog[0] == '#' || strlen(frog) <= 2)
                continue;       /* #'s are like REM's */

            frog[strlen(frog)-1] = '\0';

            if (strstr(hostname, frog) != NULL) {
                fclose(fp);
                cprintf("\n\rYou are not welcome here. Your login attempt has been logged.\n\r");
                more(BBSDIR "/share/newuser/prohibnew", 0);
                log_it("prohiblog", "Failed new user login from %s", hostname);
                sleep(2);
                return 0;
            }
        }

    }
    fclose(fp);
    return 1;
}
开发者ID:cafuego,项目名称:monolith,代码行数:34,代码来源:newuser.c

示例15: rdr

std::set<std::string> FileSniffer::getLastResult()
{
	std::set<std::string> lastresult;
	try{
		
		std::string* resultfile = new std::string();
		if(fexists(resultFilePath.c_str()))	//Check if result text file exists
		{
			resultfile = loadFile(resultFilePath);
			XmlReader rdr(*resultfile);
			while(rdr.next())		
			{							//Scan through the xml and search for filepath tag
				if(rdr.tag() == "listsize")
				{
					if(rdr.body() == "0")
						break;
				}
				if(rdr.tag() == "filepath")
					lastresult.insert(rdr.body());
			}
			delete resultfile;
		}
		
	}catch(std::exception& ex){
    std::cout << "\n\n    " << ex.what() << "\n\n"; }	
	return lastresult;
}
开发者ID:ayelkawar2,项目名称:HTML5basedCrossPlatformSniffer,代码行数:27,代码来源:Filesniffer.cpp


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