• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ Basename函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: PutHash

BOOL PutHash( LPCTSTR lpszFile, LPOPTIONS lpOpt )
{
	DWORD w;
	LPCTSTR lpszFormat;

	if( lpOpt->DispFilename ){
		lpszFormat = _T( "%3!s!(%4!s!) : %1!s!-%2!8.8X!.pf\n" );
	}else{
		if( lpOpt->HashXp && lpOpt->HashVista ){
			lpszFormat = _T( "(%4!s!) : %1!s!-%2!8.8X!.pf\n" );
		}else{
			lpszFormat = _T( "%1!s!-%2!8.8X!.pf\n" );
		}
	}

	if( lpOpt->HashVista ){
		w = HashVista( lpszFile );
		my_printf( hStdout, lpszFormat, Basename( lpszFile ), w, lpszFile, _T("Vista") );
	}
	if( lpOpt->HashXp ){
		w = HashXp( lpszFile );
		my_printf( hStdout, lpszFormat, Basename( lpszFile ), w, lpszFile, _T("XP") );
	}
	return TRUE;


}
开发者ID:hasegawayosuke,项目名称:prehash,代码行数:27,代码来源:prehash.c


示例2: StripExtension

/**
 * @brief
 */
static cm_material_t *Cm_LoadBspMaterials(const char *name) {

    char base[MAX_QPATH];
    StripExtension(Basename(name), base);

    return Cm_LoadMaterials(va("materials/%s.mat", base), NULL);
}
开发者ID:jdolan,项目名称:quetoo,代码行数:10,代码来源:cm_model.c


示例3: sizeof

bool COption::init(int argc, char** argv)
{
    if(m_bInit)
    {
        return true;
    }
    m_optNum = sizeof(OptTab)/sizeof(OptTab[0]);
    if(!initOption())
    {
        return false;
    }
    
    //获取程序名称
    m_myName = Basename(argv[0]);
    
    //获取命令行选项
    int oc = -1;
    char optString[sizeof(OptTab)/sizeof(OptTab[0]) * 2] = {0};
    makeOptString(optString);

    //解析命令行
    while((oc = getopt(argc, argv, optString)) != -1)
    {
        if(Unknown_key == oc || Usage_key == oc)
        {
            usage();
            return false;
        }

        setOption(oc, optarg);
    }

    return true;
}
开发者ID:chrisrow,项目名称:videoanalyzer,代码行数:34,代码来源:Option.cpp


示例4: ShowUsage

static
VOID
ShowUsage(
    PCSTR pszProgramName,
    BOOLEAN bFull
    )
{
    printf(
        "Usage: %s [ --<object type> ] [ <flags> ] [ --provider name ]\n",
        Basename(pszProgramName));
    
    if (bFull)
    {
        printf(
            "\n"
            "Object type options:\n"
            "    --user                  Return only user objects\n"
            "    --group                 Return only group objects\n"
            "\n"
            "Query flags:\n"
            "     --nss                  Omit data not necessary for NSS layer\n"
            "\n"
            "Other options:\n"
            "     --domain name          Restrict enumeration to the specified NetBIOS domain\n"
            "     --provider name        Direct request to provider with the specified name\n"
            "\n");
    }
}
开发者ID:borland667,项目名称:pbis,代码行数:28,代码来源:enum_objects.c


示例5: Cl_LoadLocations

/*
 * Cl_LoadLocations
 *
 * Parse a .loc file for the current level.
 */
void Cl_LoadLocations(void) {
	const char *c;
	char file_name[MAX_QPATH];
	FILE *f;
	int i;

	Cl_ClearLocations(); // clear any resident locations
	i = 0;

	// load the locations file
	c = Basename(cl.config_strings[CS_MODELS + 1]);
	snprintf(file_name, sizeof(file_name), "locations/%s", c);
	strcpy(file_name + strlen(file_name) - 3, "loc");

	if (Fs_OpenFile(file_name, &f, FILE_READ) == -1) {
		Com_Debug("Couldn't load %s\n", file_name);
		return;
	}

	while (i < MAX_LOCATIONS) {

		const int err = fscanf(f, "%f %f %f %[^\n]", &locations[i].loc[0],
				&locations[i].loc[1], &locations[i].loc[2], locations[i].desc);

		num_locations = i;
		if (err == EOF)
			break;
		i++;
	}

	Cl_LoadProgress(100);

	Com_Print("Loaded %i locations.\n", num_locations);
	Fs_CloseFile(f);
}
开发者ID:darkshade9,项目名称:aq2w,代码行数:40,代码来源:cl_loc.c


示例6: do_stat

/* -------------------------------------------------------------
 * do_stat: print all important inode info for the path INODE 
 *      (1) get INODE of path into a minode[] table 
 *      (2) print all important info 
 * 
 * Note: This is the lazy way. KC's recommended way utilizes
 * the stat struct 
 --------------------------------------------------------------*/
void do_stat(char* path)
{
    MINODE* dir; 
    char timebuf[256]; 
    int ino; 
    int dev = running->cwd->dev; 
    
    //(1) get INODE of path into a minode[table]
    ino = getino(&dev, path);   // get ino 
    dir = iget(dev, ino);       // get MINODE* 
    
    if(dir == NULL)
    {
        printf("Error: unable to stat %s\n", path); 
        return; 
    }
    
    // Copy dir's modified time into timebuf
    ctime_r(&dir->INODE.i_mtime, timebuf); 
    timebuf[24] = 0;    // add NULL terminator 
    
    
    printf("-------------------------------------------------------\n"); 
    printf("file: %s\n", Basename(path)); 
    printf("dev: %d\t\tinode number: %i\tmode:%3x\n", dir->dev, dir->ino, dir->INODE.i_mode); 
    printf("uid: %i\tgid: %i\tlink count: %d\n", running->uid, running->gid, dir->INODE.i_links_count); 
    printf("size: %d\t\t%5s\n", dir->INODE.i_size, timebuf); 
    printf("-------------------------------------------------------\n"); 
    
    iput(dir); 
    
    
}
开发者ID:griffinfujioka,项目名称:Early-Final,代码行数:41,代码来源:functions.c


示例7: LoadSoundReader

bool RageSound::Load( CString sSoundFilePath, bool bPrecache )
{
	LOG->Trace( "RageSound::LoadSound( '%s', %d )", sSoundFilePath.c_str(), bPrecache );

	CString error;
	SoundReader *pSound = SoundReader_FileReader::OpenFile( sSoundFilePath, error );
	if( pSound == NULL )
	{
		LOG->Warn( "RageSound::Load: error opening sound \"%s\": %s",
			sSoundFilePath.c_str(), error.c_str() );

		pSound = new RageSoundReader_Silence;
	}

	LoadSoundReader( pSound );

	/* Try to precache.  Do this after calling LoadSoundReader() to put the
	 * sound in this->m_pSource, so we preload after resampling. */
	if( bPrecache )
		RageSoundReader_Preload::PreloadSound( m_pSource );

	m_sFilePath = sSoundFilePath;

	m_Mutex.SetName( ssprintf("RageSound (%s)", Basename(sSoundFilePath).c_str() ) );

	return true;
}
开发者ID:TaroNuke,项目名称:openitg,代码行数:27,代码来源:RageSound.cpp


示例8: Basename

const char* FileInfo::tail()
{
	const char* name = Basename();
	const char* pt =  strrchr(name, '.');

	return (pt == NULL ? "" : pt);
}
开发者ID:eroux,项目名称:transcriber-ag,代码行数:7,代码来源:FileInfo.cpp


示例9: Basename

void ScreenTestSound::UpdateText(int n)
{
	RString fn = Basename( s[n].s.GetLoadedFilePath() );

	vector<RageSound *> &snds = m_sSoundCopies[n];

	RString pos;
	for(unsigned p = 0; p < snds.size(); ++p)
	{
		if(p) pos += ", ";
		pos += ssprintf("%.3f", snds[p]->GetPositionSeconds());
	}

	s[n].txt.SetText(ssprintf(
		"%i: %s\n"
		"%s\n"
		"%s\n"
		"(%s)\n"
		"%s",
		n+1, fn.c_str(),
		s[n].s.IsPlaying()? "Playing":"Stopped",
		s[n].s.GetParams().StopMode == RageSoundParams::M_STOP?
			"Stop when finished":
		s[n].s.GetParams().StopMode == RageSoundParams::M_CONTINUE?
			"Continue until stopped":
			"Loop",
		pos.size()? pos.c_str(): "none playing",
		selected == n? "^^^^^^":""
		));
}
开发者ID:goofwear,项目名称:stepmania,代码行数:30,代码来源:ScreenTestSound.cpp


示例10: MakeTempFilename

static RString MakeTempFilename( const RString &sPath )
{
	/* "Foo/bar/baz" -> "Foo/bar/new.baz.new".  Both prepend and append: we don't
	 * want a wildcard search for the filename to match (foo.txt.new matches foo.txt*),
	 * and we don't want to have the same extension (so "new.foo.sm" doesn't show up
	 * in *.sm). */
	return Dirname(sPath) + "new." + Basename(sPath) + ".new";
}
开发者ID:SamDecrock,项目名称:stepmania5-http-post-scores,代码行数:8,代码来源:RageFileDriverDirect.cpp


示例11: main

/*
 * grpck - verify group file integrity
 */
int main (int argc, char **argv)
{
	int errors = 0;
	bool changed = false;

	/*
	 * Get my name so that I can use it to report errors.
	 */
	Prog = Basename (argv[0]);

	(void) setlocale (LC_ALL, "");
	(void) bindtextdomain (PACKAGE, LOCALEDIR);
	(void) textdomain (PACKAGE);

	process_root_flag ("-R", argc, argv);

	OPENLOG ("grpck");

	/* Parse the command line arguments */
	process_flags (argc, argv);

	open_files ();

	if (sort_mode) {
		gr_sort ();
#ifdef	SHADOWGRP
		if (is_shadow) {
			sgr_sort ();
		}
		changed = true;
#endif
	} else {
		check_grp_file (&errors, &changed);
#ifdef	SHADOWGRP
		if (is_shadow) {
			check_sgr_file (&errors, &changed);
		}
#endif
	}

	/* Commit the change in the database if needed */
	close_files (changed);

	nscd_flush_cache ("group");

	/*
	 * Tell the user what we did and exit.
	 */
	if (0 != errors) {
		if (changed) {
			printf (_("%s: the files have been updated\n"), Prog);
		} else {
			printf (_("%s: no changes\n"), Prog);
		}
	}

	return ((0 != errors) ? E_BAD_ENTRY : E_OKAY);
}
开发者ID:DavidChenLiang,项目名称:study,代码行数:61,代码来源:grpck.c


示例12: main

/*
 * main - groupadd command
 */
int main (int argc, char **argv)
{
	/*
	 * Get my name so that I can use it to report errors.
	 */
	Prog = Basename (argv[0]);

	(void) setlocale (LC_ALL, "");
	(void) bindtextdomain (PACKAGE, LOCALEDIR);
	(void) textdomain (PACKAGE);

	process_root_flag ("-R", argc, argv);
	prefix = process_prefix_flag ("-P", argc, argv);

	OPENLOG ("groupadd");
#ifdef WITH_AUDIT
	audit_help_open ();
#endif

	if (atexit (do_cleanups) != 0) {
		fprintf (stderr,
		         _("%s: Cannot setup cleanup service.\n"),
		         Prog);
		exit (1);
	}

	/*
	 * Parse the command line options.
	 */
	process_flags (argc, argv);

	check_perms ();

#ifdef SHADOWGRP
	is_shadow_grp = sgr_file_present ();
#endif

	/*
	 * Do the hard stuff - open the files, create the group entries,
	 * then close and update the files.
	 */
	open_files ();

	if (!gflg) {
		if (find_new_gid (rflg, &group_id, NULL) < 0) {
			exit (E_GID_IN_USE);
		}
	}

	grp_update ();
	close_files ();

	nscd_flush_cache ("group");

	return E_SUCCESS;
}
开发者ID:fariouche,项目名称:shadow,代码行数:59,代码来源:groupadd.c


示例13: main

/*!
*
*/
int
main(int argc, char** argv)
{
  char *progname = argv[0];

  glutInit(&argc, argv);

  for(++argv; --argc > 0; ++argv)
  {
    if( strcmp(*argv, "-help") ==  0 || strcmp(*argv, "--help") == 0 )
    {
      fputs("View a 3DS model file using OpenGL.\n", stderr);
      fputs("Usage: 3dsplayer [-nodb|-aa|-flush] <filename>\n", stderr);
#ifndef USE_SDL
      fputs("Texture rendering is not available; install SDL_image and recompile.\n", stderr);
#endif
      exit(0);
    }
    else if( strcmp(*argv, "-nodb") == 0 )
      dbuf = 0;
    else if( strcmp(*argv, "-aa") == 0 )
      anti_alias = 1;
    else if( strcmp(*argv, "-flush") == 0 )
      flush = 1;
    else {
      filepath = *argv;
      decompose_datapath(filepath);
    }
  }

  if (filepath == NULL) {
    fputs("3dsplayer: Error: No 3DS file specified\n", stderr);
    exit(1);
  }

  glutInitDisplayMode(GLUT_DEPTH | GLUT_RGB | (dbuf ? GLUT_DOUBLE:0) );
  glutInitWindowSize(500, 500);
  glutInitWindowPosition(100, 100);
  glutCreateWindow(filepath != NULL ? Basename(filepath) : progname);

  init();
  create_icons();
  load_model();

  build_menu();
  glutAttachMenu(2);

  glutDisplayFunc(display);
  glutReshapeFunc(reshape);
  glutKeyboardFunc(keyboard);
  glutMouseFunc(mouse_cb);
  glutMotionFunc(drag_cb);
  glutTimerFunc(10, timer_cb, 0);
  glutMainLoop();
  return(0);
}
开发者ID:gdh1995,项目名称:GhostFace,代码行数:59,代码来源:3dsplay.c


示例14: GetDumpLocalID

static string GetDumpLocalID()
{
  string localId = Basename(gReporterDumpFile);
  string::size_type dot = localId.rfind('.');

  if (dot == string::npos)
    return "";

  return localId.substr(0, dot);
}
开发者ID:Wafflespeanut,项目名称:gecko-dev,代码行数:10,代码来源:crashreporter.cpp


示例15: GetSizedFilesFromDir

void DataFlowTrace::ReadCoverage(const std::string &DirPath) {
  Vector<SizedFile> Files;
  GetSizedFilesFromDir(DirPath, &Files);
  for (auto &SF : Files) {
    auto Name = Basename(SF.File);
    if (Name == kFunctionsTxt) continue;
    std::ifstream IF(SF.File);
    Coverage.AppendCoverage(IF);
  }
}
开发者ID:matrc,项目名称:llvm-project,代码行数:10,代码来源:FuzzerDataFlowTrace.cpp


示例16: CHECKPOINT_M

void DirectFilenameDB::CacheFile( const RString &sPath )
{
	CHECKPOINT_M( root+sPath );
	RString sDir = Dirname( sPath );
	FileSet *pFileSet = GetFileSet( sDir, false );
	if( pFileSet == NULL )
	{
		// This directory isn't cached so do nothing.
		m_Mutex.Unlock(); // Locked by GetFileSet()
		return;
	}
	while( !pFileSet->m_bFilled )
		m_Mutex.Wait();
		
#if defined(WIN32)
	// There is almost surely a better way to do this
	WIN32_FIND_DATA fd;
	HANDLE hFind = DoFindFirstFile( root+sPath, &fd );
	if( hFind == INVALID_HANDLE_VALUE )
	{
		m_Mutex.Unlock(); // Locked by GetFileSet()
		return;
	}
	File f( fd.cFileName );
	f.dir = !!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
	f.size = fd.nFileSizeLow;
	f.hash = fd.ftLastWriteTime.dwLowDateTime;
	
	pFileSet->files.insert( f );
	FindClose( hFind );
#else
	File f( Basename(sPath) );
	
	struct stat st;
	if( DoStat(root+sPath, &st) == -1 )
	{
		int iError = errno;
		/* If it's a broken symlink, ignore it.  Otherwise, warn. */
		/* Huh? */
		WARN( ssprintf("File '%s' is gone! (%s)",
			       sPath.c_str(), strerror(iError)) );
	}
	else
	{
		f.dir = (st.st_mode & S_IFDIR);
		f.size = (int)st.st_size;
		f.hash = st.st_mtime;
	}
	
	pFileSet->files.insert(f);
#endif
	m_Mutex.Unlock(); // Locked by GetFileSet()	
}
开发者ID:ycaihua,项目名称:fingermania,代码行数:53,代码来源:RageFileDriverDirectHelpers.cpp


示例17: strdup

const char* FileInfo::realpath()
{

	char* pt = strdup( _path.c_str());
    string dir = ::dirname(pt);
	free(pt);

	_realpath = _path;

	if ( dir[0] == '~' )
	{
//		const char* pt = getenv("HOME");
		const gchar* pt = g_get_home_dir() ;
		if ( pt != NULL )
			dir = pt + dir.substr(1);
	}
	else if ( dir[0] == '$' )
	{
		char varname[80];
		const char* pt;
		int i;
		for ( i=0, pt = dir.c_str()+1;
			*pt && *pt != ')' && strncmp(pt,_path_delim,1) ; ++pt )
			if ( *pt == '(' ) continue;
			else varname[i++] = *pt;
		varname[i] = 0;
		if ( *pt == ')' ) ++pt;

		if ( varname[0] ) {
			const char* pt2 = getenv(varname);
			if ( pt2 != NULL ) {
				dir = string(pt2) + string(pt);
			} else
				Log::err() << "Error in FileInfo::realpath : undefined environment variable " << varname << endl;
		}
	}
	else if ( dir[0] == '.' )
	{
  		char resolved[MAXPATHLEN];
		char current[MAXPATHLEN];
		if ( getcwd(current, sizeof(current)) == NULL )
			return "";  // rep courant indefini
		if ( chdir(dir.c_str()) != 0 )
			return ""; // path invalide
		getcwd(resolved, sizeof(resolved));
		chdir (current);
		dir=resolved;
	}

	_realpath = FileInfo(dir).join(Basename());

	return _realpath.c_str();
}
开发者ID:eroux,项目名称:transcriber-ag,代码行数:53,代码来源:FileInfo.cpp


示例18: GetDirListing

void BackgroundUtil::GetGlobalBGAnimations( const Song *pSong, const RString &sMatch, vector<RString> &vsPathsOut, vector<RString> &vsNamesOut )
{
	vsPathsOut.clear();
	GetDirListing( BG_ANIMS_DIR+sMatch+"*", vsPathsOut, true, true );
	GetDirListing( BG_ANIMS_DIR+sMatch+"*.xml", vsPathsOut, false, true );

	vsNamesOut.clear();
	FOREACH_CONST( RString, vsPathsOut, s )
		vsNamesOut.push_back( Basename(*s) );

	StripCvsAndSvn( vsPathsOut, vsNamesOut );
}
开发者ID:goofwear,项目名称:stepmania,代码行数:12,代码来源:BackgroundUtil.cpp


示例19: MoveCrashData

static bool MoveCrashData(const string& toDir,
                          string& dumpfile,
                          string& extrafile,
                          string& memoryfile)
{
  if (!UIEnsurePathExists(toDir)) {
    UIError(gStrings[ST_ERROR_CREATEDUMPDIR]);
    return false;
  }

  string newDump = toDir + UI_DIR_SEPARATOR + Basename(dumpfile);
  string newExtra = toDir + UI_DIR_SEPARATOR + Basename(extrafile);
  string newMemory = toDir + UI_DIR_SEPARATOR + Basename(memoryfile);

  if (!UIMoveFile(dumpfile, newDump)) {
    UIError(gStrings[ST_ERROR_DUMPFILEMOVE]);
    return false;
  }

  if (!UIMoveFile(extrafile, newExtra)) {
    UIError(gStrings[ST_ERROR_EXTRAFILEMOVE]);
    return false;
  }

  if (!memoryfile.empty()) {
    // Ignore errors from moving the memory file
    if (!UIMoveFile(memoryfile, newMemory)) {
      UIDeleteFile(memoryfile);
      newMemory.erase();
    }
    memoryfile = newMemory;
  }

  dumpfile = newDump;
  extrafile = newExtra;

  return true;
}
开发者ID:Wafflespeanut,项目名称:gecko-dev,代码行数:38,代码来源:crashreporter.cpp


示例20: make_dir

/* -------------------------------------------------------
 * make_dir: 
 *      must understand perfectly!!!
 * 
 *      Takes a pathname as parameter 
 * 
 *      (1) set the device 
 *      (2) get parent MINODE by using dirname with 
 *              getino 
 *          Load MINODE using iget 
 *      (3) call my_mkdir(MINODE* parent, char* name)
 * 
 --------------------------------------------------------*/
void make_dir(char* path)
{
    MINODE* pip;                // parent MINODE* 
    int dev, pino;              // device, parent ino 
    
    // parent = path to parent directory, child = basename 
    char* parent, *child;        
    
    // (1) Set device according to relative or absolute path 
    if(path[0] == '/')
        dev = root->dev; 
    else 
        dev = running->cwd->dev; 
    
    // (2) Separate path into dirname and basename 
    parent = strdup(Dirname(path));     // make copies 
    child = strdup(Basename(path)); 
    
    // Debug print 
    //printf("parent: %s\n", parent);
    //printf("child: %s\n", child);
    
    // (3) get in memory MINODE of parent directory 
    pino = getino(&dev, parent); // First, get parent ino 
    pip = iget(dev, pino); // Then use it to load INODE into minode[] table
    
    
    // (4) Error checking on found MINODE
    if(pip == NULL)                     // (4.1) ensure the MINODE was found 
    {
        printf("Error: unable to locate %s\n", parent); 
    }
    else if(!isdir(pip))                // (4.2) is DIR 
    {
        printf("Error: %s is not a directory\n", parent);
    }
    else if(search(pip, child) != 0)    // (4.3) child does not already exist    
    {
        // the child was already found 
        printf("Error: %s already exists in %s\n", child, parent); 
    }
    // (5) We've verified that parent path exists, is a directory 
        // and child does not exist in it, so add to it  
    else
        my_mkdir(pip,child); 
    
    // No matter what, dont forget to write back! 
    // Release parent from minode[] table and write back to disk 
    iput(pip);
}
开发者ID:griffinfujioka,项目名称:Early-Final,代码行数:63,代码来源:functions.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ Basic函数代码示例发布时间:2022-05-30
下一篇:
C++ BaseWindingForPlane函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap