本文整理汇总了C++中TString::filename方法的典型用法代码示例。如果您正苦于以下问题:C++ TString::filename方法的具体用法?C++ TString::filename怎么用?C++ TString::filename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TString
的用法示例。
在下文中一共展示了TString::filename方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FS_CopyFiles
void FS_CopyFiles(const char *srcMask, const char *dstDir)
{
FSLog->Printf("CopyFiles(%s->%s)\n", srcMask, dstDir);
TString<256> Base; Base.filename(srcMask);
char *s = Base.rchr('/');
if (!s) s = Base;
else s++; // will point to mask start
// prepare dst string: should ends with '/'
TString<256> Pattern; Pattern.filename(dstDir);
int pos = Pattern.len();
if (!pos || Pattern[pos - 1] != '/')
Pattern[pos++] = '/';
appMakeDirectoryForFile(Pattern);
#if 1
CFileList *list = new CFileList;
appListDirectory(srcMask, *list, FS_FILE);
#else
CFileList *list = GFileSystem->List(srcMask, FS_OS);
#endif
for (TListIterator<CFileItem> it = *list; it; ++it)
{
strcpy(s, it->name); // create source filename
strcpy(Pattern + pos, it->name); // create destination filename
FS_CopyFile(Base, Pattern);
}
delete list;
}
示例2: SetGameDir
// return "true" when game was changed
bool SetGameDir(const char *name)
{
guard(CQuakeFileSystem::SetGameDir);
FSLog->Printf("Set gamedir: %s\n", name);
if (!name[0]) name = BASEDIRNAME;
if (!stricmp(GameDir, name))
return false; // not changed
// check directory
CFileList *list = List(va("./%s/*", name), FS_DIR|FS_FILE|FS_OS, NULL);
bool empty = !(*list);
delete list;
if (empty)
{
appWPrintf("Invalid game directory: %s\n", name);
return false;
}
if (GameDir != BASEDIRNAME) // base dir not umounted
{
Umount(va("./%s/*." PAK_EXTENSION, *GameDir));
if (fs_cddir->string[0])
Umount(va("%s/%s/*." PAK_EXTENSION, fs_cddir->string, *GameDir));
}
GameDir.filename(name);
GDefMountPoint = GameDir;
if (GameDir != BASEDIRNAME) // do not remount base dir
MountGame(name);
return true;
unguard;
}
示例3: sizeof
static sfx_t *S_FindName(const char *name, bool create)
{
guard(S_FindName);
int i;
sfx_t *sfx;
if (!name) appError("NULL name\n");
if (!name[0]) appError("empty name\n");
if (strlen(name) >= MAX_QPATH) appError("Sound name too long: %s", name);
TString<MAX_QPATH> Filename;
Filename.filename(name);
// see if already loaded
for (i = 0, sfx = known_sfx; i < num_sfx; i++, sfx++)
if (sfx->Name == Filename)
return sfx;
if (!create)
return NULL;
// find a free sfx
for (i = 0, sfx = known_sfx; i < num_sfx; i++, sfx++)
if (!sfx->Name[0])
break;
if (i == num_sfx)
{
// not found
if (num_sfx == MAX_SFX)
{
#if 0
appError("too much sfx records");
#else
Com_DPrintf("too much sfx records\n");
return NULL;
#endif
}
// alloc next free record
num_sfx++;
}
memset(sfx, 0, sizeof(*sfx));
sfx->Name = Filename;
sfx->registration_sequence = s_registration_sequence;
return sfx;
unguard;
}
示例4: CheckFilename
// support for checking for file current mod dir, then BASEDIRNAME
void CheckFilename(const char *name)
{
Name2[0] = 0;
TString<256> Name; Name.filename(name);
if (Name[0] == '.' && Name[1] == '/')
{
// absolute path - only 1 name
Name1 = Name;
return;
}
Name1.sprintf("./%s/%s", *GameDir, *Name);
if (!stricmp(GameDir, BASEDIRNAME)) return; // mod == BASEDIRNAME
Name2.sprintf("./" BASEDIRNAME "/%s", *Name);
}
示例5: FS_RemoveFiles
void FS_RemoveFiles(const char *mask)
{
FSLog->Printf(va("RemoveFiles(%s)\n", mask));
TString<256> Base; Base.filename(mask);
char *s = Base.rchr('/');
if (!s) s = Base;
else s++; // will point to mask start
#if 1
CFileList *list = new CFileList;
appListDirectory(mask, *list, FS_FILE);
#else
CFileList *list = GFileSystem->List(mask, FS_OS);
#endif
for (TListIterator<CFileItem> it = *list; it; ++it)
{
strcpy(s, it->name); // create full filename
remove(Base);
}
delete list;
}
示例6:
static char *ScanForCD()
{
#ifdef CD_PATH
static TString<MAX_OSPATH> CdDir;
static char drive[4] = "c:/";
// no abort/retry/fail errors
SetErrorMode(SEM_FAILCRITICALERRORS);
// scan the drives
for (drive[0] = 'c'; drive[0] <= 'z'; drive[0]++)
{
if (GetDriveType(drive) != DRIVE_CDROM) continue;
if (FILE *f = fopen(va("%s"CD_CHECK, drive), "r"))
{
fclose(f);
CdDir.filename(va("%s"CD_PATH, drive));
return CdDir;
}
}
#endif
return NULL;
}
示例7: sizeof
// false when: a) no skin file b) absent one of skin shaders
static bool SetMd3Skin(const char *skinName, CModelSkin &skin)
{
// load skin file
TString<MAX_QPATH> Filename;
Filename.sprintf("models/players/%s.skin", skinName);
char *buf;
if (!(buf = (char*) GFileSystem->LoadFile(Filename)))
{
Com_DPrintf("no skin: %s\n", *Filename);
return false;
}
// parse skin
memset(&skin, 0, sizeof(skin));
bool result = true;
CSimpleParser text;
text.InitFromBuf(buf);
int numSurfs = 0;
while (const char *line = text.GetLine())
{
const char *p = strchr(line, ',');
if (!p || !p[1]) continue; // no shader
// check/load shader
// special processing of "nodraw" shader
const char *n = strrchr(p+1, '/');
if (n) n++; else n = p+1;
if (!strnicmp(n, "nodraw", 6) && (n[6] == 0 || n[6] == '.')) // "nodraw" or "nodraw.ext"
{
Com_DPrintf("nodraw for %s/%s\n", skinName, line);
continue;
}
CBasicImage *shader = RE_RegisterSkin(p+1);
if (!shader)
{
// code based on gl_trimodel.cpp::SetMd3Skin()
TString<64> MName; // new skin name
// try to find skin forcing model directory
MName.filename(Filename);
char *mPtr = MName.rchr('/');
if (mPtr) mPtr++; // skip '/'
else mPtr = MName;
const char *sPtr = strrchr(p+1, '/');
if (sPtr) sPtr++; // skip '/'
else sPtr = p+1;
strcpy(mPtr, sPtr); // make "modelpath/skinname"
shader = RE_RegisterSkin(MName, true);
}
if (numSurfs >= ARRAY_COUNT(skin.surf))
{
appWPrintf("Too much skin surfaces in %s\n", skinName);
result = false;
break;
}
// store info
skin.surf[numSurfs].Name.toLower(line, p-line+1);
skin.surf[numSurfs].shader = shader;
// appPrintf("%s %d : [%s] <- %s\n", skinName, numSurfs, *skin.surf[numSurfs].Name, *shader->Name);
numSurfs++;
}
if (result)
skin.numSurfs = numSurfs;
delete buf;
return result;
}