本文整理匯總了C++中Basename函數的典型用法代碼示例。如果您正苦於以下問題:C++ Basename函數的具體用法?C++ Basename怎麽用?C++ Basename使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Basename函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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;
}
示例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);
}
示例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;
}
示例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");
}
}
示例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);
}
示例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);
}
示例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;
}
示例8: Basename
const char* FileInfo::tail()
{
const char* name = Basename();
const char* pt = strrchr(name, '.');
return (pt == NULL ? "" : pt);
}
示例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? "^^^^^^":""
));
}
示例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";
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
}