本文整理汇总了C++中idStrList类的典型用法代码示例。如果您正苦于以下问题:C++ idStrList类的具体用法?C++ idStrList怎么用?C++ idStrList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了idStrList类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: Sys_ListFiles
/*
================
Sys_ListFiles
================
*/
int Sys_ListFiles( const char *directory, const char *extension, idStrList &list ) {
struct dirent *d;
DIR *fdir;
bool dironly = false;
char search[MAX_OSPATH];
struct stat st;
bool debug;
list.Clear();
debug = cvarSystem->GetCVarBool( "fs_debug" );
if (!extension)
extension = "";
// passing a slash as extension will find directories
if (extension[0] == '/' && extension[1] == 0) {
extension = "";
dironly = true;
}
// search
// NOTE: case sensitivity of directory path can screw us up here
if ((fdir = opendir(directory)) == NULL) {
if (debug) {
common->Printf("Sys_ListFiles: opendir %s failed\n", directory);
}
return -1;
}
while ((d = readdir(fdir)) != NULL) {
idStr::snPrintf(search, sizeof(search), "%s/%s", directory, d->d_name);
if (stat(search, &st) == -1)
continue;
if (!dironly) {
idStr look(search);
idStr ext;
look.ExtractFileExtension(ext);
if (extension[0] != '\0' && ext.Icmp(&extension[1]) != 0) {
continue;
}
}
if ((dironly && !(st.st_mode & S_IFDIR)) ||
(!dironly && (st.st_mode & S_IFDIR)))
continue;
list.Append(d->d_name);
}
closedir(fdir);
if ( debug ) {
common->Printf( "Sys_ListFiles: %d entries in %s\n", list.Num(), directory );
}
return list.Num();
}
开发者ID:iodoom-gitorious,项目名称:windowshasyous-dhewg-iodoom3,代码行数:62,代码来源:posix_main.cpp
示例2: CheckForEntities
/*
============
idAASBuild::CheckForEntities
============
*/
bool idAASBuild::CheckForEntities( const idMapFile *mapFile, idStrList &entityClassNames ) const {
int i;
idStr classname;
com_editors |= EDITOR_AAS;
for( i = 0; i < mapFile->GetNumEntities(); i++ ) {
if( !mapFile->GetEntity( i )->epairs.GetString( "classname", "", classname ) ) {
continue;
}
if( aasSettings->ValidEntity( classname ) ) {
entityClassNames.AddUnique( classname );
}
}
com_editors &= ~EDITOR_AAS;
return ( entityClassNames.Num() != 0 );
}
开发者ID:SL987654,项目名称:The-Darkmod-Experimental,代码行数:20,代码来源:AASBuild.cpp
示例3: TestGuiParm
bool TestGuiParm(const char* parm, const char* value, idStrList& excludeList) {
idStr testVal = value;
//Already Localized?
if(testVal.Find("#str_") != -1) {
return false;
}
//Numeric
if(testVal.IsNumeric()) {
return false;
}
//Contains ::
if(testVal.Find("::") != -1) {
return false;
}
//Contains /
if(testVal.Find("/") != -1) {
return false;
}
if(excludeList.Find(testVal)) {
return false;
}
return true;
}
开发者ID:Deepfreeze32,项目名称:taken,代码行数:30,代码来源:Common_localize.cpp
示例4: GetSaveGameList
/*
===============
idSessionLocal::GetSaveGameList
===============
*/
void idSessionLocal::GetSaveGameList( idStrList &fileList, idList<fileTIME_T> &fileTimes ) {
int i;
idFileList *files;
// NOTE: no fs_game_base for savegames
idStr game = cvarSystem->GetCVarString( "fs_game" );
if( game.Length() ) {
files = fileSystem->ListFiles( "savegames", ".save", false, false, game );
} else {
files = fileSystem->ListFiles( "savegames", ".save" );
}
fileList = files->GetList();
fileSystem->FreeFileList( files );
for ( i = 0; i < fileList.Num(); i++ ) {
ID_TIME_T timeStamp;
fileSystem->ReadFile( "savegames/" + fileList[i], NULL, &timeStamp );
fileList[i].StripLeading( '/' );
fileList[i].StripFileExtension();
fileTIME_T ft;
ft.index = i;
ft.timeStamp = timeStamp;
fileTimes.Append( ft );
}
fileTimes.Sort( idListSaveGameCompare );
}
开发者ID:anonreclaimer,项目名称:morpheus,代码行数:35,代码来源:Session_menu.cpp
示例5: ReadManifestFile
/*
========================
idResourceContainer::ReadManifestFile
========================
*/
int idResourceContainer::ReadManifestFile( const char* name, idStrList& list )
{
idFile* inFile = fileSystem->OpenFileRead( name );
if( inFile != NULL )
{
list.SetGranularity( 16384 );
idStr str;
int num;
list.Clear();
inFile->ReadBig( num );
for( int i = 0; i < num; i++ )
{
inFile->ReadString( str );
list.Append( str );
}
delete inFile;
}
return list.Num();
}
开发者ID:Yetta1,项目名称:OpenTechBFG,代码行数:24,代码来源:File_Resource.cpp
示例6: Sys_ListFiles
/*
==============
Sys_ListFiles
==============
*/
int Sys_ListFiles(const char *directory, const char *extension, idStrList &list)
{
idStr search;
struct _finddata_t findinfo;
int findhandle;
int flag;
if (!extension) {
extension = "";
}
// passing a slash as extension will find directories
if (extension[0] == '/' && extension[1] == 0) {
extension = "";
flag = 0;
} else {
flag = _A_SUBDIR;
}
sprintf(search, "%s\\*%s", directory, extension);
// search
list.Clear();
findhandle = _findfirst(search, &findinfo);
if (findhandle == -1) {
return -1;
}
do {
if (flag ^(findinfo.attrib & _A_SUBDIR)) {
list.Append(findinfo.name);
}
} while (_findnext(findhandle, &findinfo) != -1);
_findclose(findhandle);
return list.Num();
}
开发者ID:AreaScout,项目名称:dante-doom3-odroid,代码行数:45,代码来源:win_main.cpp
示例7: WriteManifestFile
/*
========================
idResourceContainer::WriteManifestFile
========================
*/
void idResourceContainer::WriteManifestFile( const char* name, const idStrList& list )
{
idStr filename( name );
filename.SetFileExtension( "manifest" );
filename.Insert( "maps/", 0 );
idFile* outFile = fileSystem->OpenFileWrite( filename );
if( outFile != NULL )
{
int num = list.Num();
outFile->WriteBig( num );
for( int i = 0; i < num; i++ )
{
outFile->WriteString( list[ i ] );
}
delete outFile;
}
}
开发者ID:Yetta1,项目名称:OpenTechBFG,代码行数:22,代码来源:File_Resource.cpp
示例8: GetFileList
void GetFileList(const char* dir, const char* ext, idStrList& list) {
//Recurse Subdirectories
idStrList dirList;
Sys_ListFiles(dir, "/", dirList);
for(int i = 0; i < dirList.Num(); i++) {
if(dirList[i] == "." || dirList[i] == "..") {
continue;
}
idStr fullName = va("%s/%s", dir, dirList[i].c_str());
GetFileList(fullName, ext, list);
}
idStrList fileList;
Sys_ListFiles(dir, ext, fileList);
for(int i = 0; i < fileList.Num(); i++) {
idStr fullName = va("%s/%s", dir, fileList[i].c_str());
list.Append(fullName);
}
}
开发者ID:Deepfreeze32,项目名称:taken,代码行数:20,代码来源:Common_localize.cpp
示例9: LoadGuiParmExcludeList
void LoadGuiParmExcludeList(idStrList& list) {
idStr fileName = "guiparm_exclude.cfg";
const char *buffer = NULL;
idLexer src( LEXFL_NOFATALERRORS | LEXFL_NOSTRINGCONCAT | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_ALLOWBACKSLASHSTRINGCONCAT );
if ( fileSystem->ReadFile( fileName, (void**)&buffer ) > 0 ) {
src.LoadMemory( buffer, strlen(buffer), fileName );
if ( src.IsLoaded() ) {
idStr classname;
idToken token;
while ( src.ReadToken( &token ) ) {
list.Append(token);
}
}
fileSystem->FreeFile( (void*)buffer );
}
}
开发者ID:Deepfreeze32,项目名称:taken,代码行数:21,代码来源:Common_localize.cpp
示例10: addStrList
void CDialogTextures::addStrList( const char *root, const idStrList &list, int id ) {
idStr out, path;
HTREEITEM base = m_treeTextures.GetRootItem();
while (base) {
out = m_treeTextures.GetItemText(base);
if (stricmp(root, out) == 0) {
break;
}
base = m_treeTextures.GetNextSiblingItem(base);
}
if (base == NULL) {
base = m_treeTextures.InsertItem(root);
}
HTREEITEM item = base;
HTREEITEM add;
int count = list.Num();
idStr last, qt;
for (int i = 0; i < count; i++) {
idStr name = list[i];
// now break the name down convert to slashes
name.BackSlashesToSlashes();
name.Strip(' ');
int index;
int len = last.Length();
if (len == 0) {
index = name.Last('/');
if (index >= 0) {
name.Left(index, last);
}
}
else if (idStr::Icmpn(last, name, len) == 0 && name.Last('/') <= len) {
name.Right(name.Length() - len - 1, out);
add = m_treeTextures.InsertItem(out, item);
qt = root;
qt += "/";
qt += name;
quickTree.Set(qt, add);
m_treeTextures.SetItemData(add, id);
m_treeTextures.SetItemImage(add, 2, 2);
continue;
}
else {
last.Empty();
}
index = 0;
item = base;
path = "";
while (index >= 0) {
index = name.Find('/');
if (index >= 0) {
HTREEITEM newItem = NULL;
HTREEITEM *check = NULL;
name.Left( index, out );
path += out;
qt = root;
qt += "/";
qt += path;
if (quickTree.Get(qt, &check)) {
newItem = *check;
}
//HTREEITEM newItem = FindTreeItem(&m_treeTextures, item, name.Left(index, out), item);
if (newItem == NULL) {
newItem = m_treeTextures.InsertItem(out, item);
qt = root;
qt += "/";
qt += path;
quickTree.Set(qt, newItem);
m_treeTextures.SetItemImage(newItem, 0, 1);
}
assert(newItem);
item = newItem;
name.Right( name.Length() - index - 1, out );
name = out;
path += "/";
}
else {
add = m_treeTextures.InsertItem(name, item);
qt = root;
qt += "/";
qt += path;
qt += name;
quickTree.Set(qt, add);
m_treeTextures.SetItemData(add, id);
m_treeTextures.SetItemImage(add, 2, 2);
path = "";
}
}
}
}
开发者ID:CQiao,项目名称:DOOM-3,代码行数:99,代码来源:DialogTextures.cpp
示例11: Sys_ListFiles
/*
================
Sys_ListFiles
================
*/
int Sys_ListFiles( const char* directory, const char* extension, idStrList& list )
{
struct dirent* d;
DIR* fdir;
bool dironly = false;
char search[MAX_OSPATH];
struct stat st;
bool debug;
list.Clear();
debug = cvarSystem->GetCVarBool( "fs_debug" );
// DG: we use fnmatch for shell-style pattern matching
// so the pattern should at least contain "*" to match everything,
// the extension will be added behind that (if !dironly)
idStr pattern( "*" );
// passing a slash as extension will find directories
if( extension[0] == '/' && extension[1] == 0 )
{
dironly = true;
}
else
{
// so we have *<extension>, the same as in the windows code basically
pattern += extension;
}
// DG end
// NOTE: case sensitivity of directory path can screw us up here
if( ( fdir = opendir( directory ) ) == NULL )
{
if( debug )
{
common->Printf( "Sys_ListFiles: opendir %s failed\n", directory );
}
return -1;
}
// DG: use readdir_r instead of readdir for thread safety
// the following lines are from the readdir_r manpage.. fscking ugly.
int nameMax = pathconf( directory, _PC_NAME_MAX );
if( nameMax == -1 )
nameMax = 255;
int direntLen = offsetof( struct dirent, d_name ) + nameMax + 1;
struct dirent* entry = ( struct dirent* )Mem_Alloc( direntLen, TAG_CRAP );
if( entry == NULL )
{
common->Warning( "Sys_ListFiles: Mem_Alloc for entry failed!" );
closedir( fdir );
return 0;
}
while( readdir_r( fdir, entry, &d ) == 0 && d != NULL )
{
// DG end
idStr::snPrintf( search, sizeof( search ), "%s/%s", directory, d->d_name );
if( stat( search, &st ) == -1 )
continue;
if( !dironly )
{
// DG: the original code didn't work because d3 bfg abuses the extension
// to match whole filenames and patterns in the savegame-code, not just file extensions...
// so just use fnmatch() which supports matching shell wildcard patterns ("*.foo" etc)
// if we should ever need case insensitivity, use FNM_CASEFOLD as third flag
if( fnmatch( pattern.c_str(), d->d_name, 0 ) != 0 )
continue;
// DG end
}
if( ( dironly && !( st.st_mode & S_IFDIR ) ) ||
( !dironly && ( st.st_mode & S_IFDIR ) ) )
continue;
list.Append( d->d_name );
}
closedir( fdir );
Mem_Free( entry );
if( debug )
{
common->Printf( "Sys_ListFiles: %d entries in %s\n", list.Num(), directory );
}
return list.Num();
}
开发者ID:bubble8773,项目名称:RBDOOM-3-BFG,代码行数:93,代码来源:posix_main.cpp
示例12: AddStrList
HTREEITEM CDialogSound::AddStrList(const char *root, const idStrList &list, int id) {
idStr out;
HTREEITEM base = treeSounds.InsertItem(root);
HTREEITEM item = base;
HTREEITEM add;
int count = list.Num();
idStr last, path, path2;
for (int i = 0; i < count; i++) {
idStr name = list[i];
// now break the name down convert to slashes
name.BackSlashesToSlashes();
name.Strip(' ');
int index;
int len = last.Length();
if (len == 0) {
index = name.Last('/');
if (index >= 0) {
name.Left(index, last);
}
}
else if (idStr::Icmpn(last, name, len) == 0 && name.Last('/') <= len) {
name.Right(name.Length() - len - 1, out);
add = treeSounds.InsertItem(out, item);
quickTree.Set(name, add);
treeSounds.SetItemData(add, id);
treeSounds.SetItemImage(add, 2, 2);
continue;
}
else {
last.Empty();
}
index = 0;
item = base;
path = "";
path2 = "";
while (index >= 0) {
index = name.Find('/');
if (index >= 0) {
HTREEITEM newItem = NULL;
HTREEITEM *check = NULL;
name.Left( index, out );
path += out;
if (quickTree.Get(path, &check)) {
newItem = *check;
}
//HTREEITEM newItem = FindTreeItem(&treeSounds, item, name.Left(index, out), item);
if (newItem == NULL) {
newItem = treeSounds.InsertItem(out, item);
quickTree.Set(path, newItem);
treeSounds.SetItemData(newItem, WAVEDIR);
treeSounds.SetItemImage(newItem, 0, 1);
}
assert(newItem);
item = newItem;
name.Right( name.Length() - index - 1, out );
name = out;
path += "/";
}
else {
add = treeSounds.InsertItem(name, item);
treeSounds.SetItemData(add, id);
treeSounds.SetItemImage(add, 2, 2);
path = "";
}
}
}
return base;
}
开发者ID:janisl,项目名称:doom3.gpl,代码行数:76,代码来源:DialogSound.cpp
示例13: WriteResourceFile
/*
========================
idResourceContainer::Open
========================
*/
void idResourceContainer::WriteResourceFile( const char* manifestName, const idStrList& manifest, const bool& _writeManifest )
{
if( manifest.Num() == 0 )
{
return;
}
idLib::Printf( "Writing resource file %s\n", manifestName );
// build multiple output files at 1GB each
idList < idStrList > outPutFiles;
idFileManifest outManifest;
int64 size = 0;
idStrList flist;
flist.SetGranularity( 16384 );
for( int i = 0; i < manifest.Num(); i++ )
{
flist.Append( manifest[ i ] );
size += fileSystem->GetFileLength( manifest[ i ] );
if( size > 1024 * 1024 * 1024 )
{
outPutFiles.Append( flist );
size = 0;
flist.Clear();
}
outManifest.AddFile( manifest[ i ] );
}
outPutFiles.Append( flist );
if( _writeManifest )
{
idStr temp = manifestName;
temp.Replace( "maps/", "manifests/" );
temp.StripFileExtension();
temp.SetFileExtension( "manifest" );
outManifest.WriteManifestFile( temp );
}
for( int idx = 0; idx < outPutFiles.Num(); idx++ )
{
idStrList& fileList = outPutFiles[ idx ];
if( fileList.Num() == 0 )
{
continue;
}
idStr fileName = manifestName;
if( idx > 0 )
{
fileName = va( "%s_%02d", manifestName, idx );
}
fileName.SetFileExtension( "resources" );
idFile* resFile = fileSystem->OpenFileWrite( fileName );
if( resFile == NULL )
{
idLib::Warning( "Cannot open %s for writing.\n", fileName.c_str() );
return;
}
idLib::Printf( "Writing resource file %s\n", fileName.c_str() );
int tableOffset = 0;
int tableLength = 0;
int tableNewLength = 0;
uint32 resourceFileMagic = RESOURCE_FILE_MAGIC;
resFile->WriteBig( resourceFileMagic );
resFile->WriteBig( tableOffset );
resFile->WriteBig( tableLength );
idList< idResourceCacheEntry > entries;
entries.Resize( fileList.Num() );
for( int i = 0; i < fileList.Num(); i++ )
{
idResourceCacheEntry ent;
ent.filename = fileList[ i ];
ent.length = 0;
ent.offset = 0;
idFile* file = fileSystem->OpenFileReadMemory( ent.filename, false );
idFile_Memory* fm = dynamic_cast< idFile_Memory* >( file );
if( fm == NULL )
{
continue;
}
// if the entry is uncompressed, align the file pointer to a 16 byte boundary
//.........这里部分代码省略.........
开发者ID:Yetta1,项目名称:OpenTechBFG,代码行数:101,代码来源:File_Resource.cpp
示例14: ArgCompletion_FolderExtension
/*
============
idCmdSystemLocal::ArgCompletion_FolderExtension
============
*/
void idCmdSystemLocal::ArgCompletion_FolderExtension( const idCmdArgs &args, void(*callback)( const char *s ), const char *folder, bool stripFolder, ... ) {
int i;
idStr string;
const char *extension;
va_list argPtr;
string = args.Argv( 0 );
string += " ";
string += args.Argv( 1 );
common->FatalError("idCmdSystemLocal::ArgCompletion_FolderExtension TODO");
#ifdef TODO
if ( string.Icmp( completionString ) != 0 ) {
idStr parm, path;
idFileList *names;
completionString = string;
completionParms.Clear();
parm = args.Argv( 1 );
parm.ExtractFilePath( path );
if ( stripFolder || path.Length() == 0 ) {
path = folder + path;
}
path.StripTrailing( '/' );
// list folders
names = fileSystem->ListFiles( path, "/", true, true );
for ( i = 0; i < names->GetNumFiles(); i++ ) {
idStr name = names->GetFile( i );
if ( stripFolder ) {
name.Strip( folder );
} else {
name.Strip( "/" );
}
name = args.Argv( 0 ) + ( " " + name ) + "/";
completionParms.Append( name );
}
fileSystem->FreeFileList( names );
// list files
va_start( argPtr, stripFolder );
for ( extension = va_arg( argPtr, const char * ); extension; extension = va_arg( argPtr, const char * ) ) {
names = fileSystem->ListFiles( path, extension, true, true );
for ( i = 0; i < names->GetNumFiles(); i++ ) {
idStr name = names->GetFile( i );
if ( stripFolder ) {
name.Strip( folder );
} else {
name.Strip( "/" );
}
name = args.Argv( 0 ) + ( " " + name );
completionParms.Append( name );
}
fileSystem->FreeFileList( names );
}
va_end( argPtr );
}
开发者ID:sbrown345,项目名称:doom3_emscripten,代码行数:62,代码来源:CmdSystem.cpp
示例15: Shutdown
/*
============
idCmdSystemLocal::Shutdown
============
*/
void idCmdSystemLocal::Shutdown( void ) {
commandDef_t *cmd;
for ( cmd = commands; cmd; cmd = commands ) {
commands = commands->next;
Mem_Free( cmd->name );
Mem_Free( cmd->description );
delete cmd;
}
completionString.Clear();
completionParms.Clear();
tokenizedCmds.Clear();
postReload.Clear();
}
开发者ID:ProfessorKaos64,项目名称:tdm,代码行数:20,代码来源:CmdSystem.cpp
示例16: ArgCompletion_FolderExtension
/*
============
idCmdSystemLocal::ArgCompletion_FolderExtension
============
*/
void idCmdSystemLocal::ArgCompletion_FolderExtension( const idCmdArgs &args, void(*callback)( const char *s ), const char *folder, bool stripFolder, ... ) {
int i;
idStr string;
const char *extension;
va_list argPtr;
string = args.Argv( 0 );
string += " ";
string += args.Argv( 1 );
// taaaki: ensure that we clear the auto-complete list for the (d)map commands in case missions are
// installed/uninstalled while the game is running
if ( string.Icmp( completionString ) != 0 || string.Icmp( "map " ) == 0 || string.Icmp( "dmap " ) == 0 ) {
idStr parm, path;
idFileList *names;
const char* gamedir = NULL;
// check if a fan mission has been set and that the "map" or "dmap" command is being used
idStr currFm = cvarSystem->GetCVarString("fs_currentfm");
if ( currFm.Icmp( "darkmod" ) != 0 && ( string.Icmp( "map " ) == 0 || string.Icmp( "dmap " ) == 0 ) ) {
gamedir = currFm.c_str();
}
completionString = string;
completionParms.Clear();
parm = args.Argv( 1 );
parm.ExtractFilePath( path );
if ( stripFolder || path.Length() == 0 ) {
path = folder + path;
}
path.StripTrailing( '/' );
// taaaki: don't include folders if we are looking for the currentfm .map file
// this is a bit of a hack :/
if ( !gamedir ) {
names = fileSystem->ListFiles( path, "/", true, true, gamedir );
for ( i = 0; i < names->GetNumFiles(); i++ ) {
idStr name = names->GetFile( i );
if ( stripFolder ) {
name.Strip( folder );
} else {
name.Strip( "/" );
}
name = args.Argv( 0 ) + ( " " + name ) + "/";
completionParms.Append( name );
}
fileSystem->FreeFileList( names );
}
// list files
va_start( argPtr, stripFolder );
for ( extension = va_arg( argPtr, const char * ); extension; extension = va_arg( argPtr, const char * ) ) {
names = fileSystem->ListFiles( path, extension, true, true, gamedir );
for ( i = 0; i < names->GetNumFiles(); i++ ) {
idStr name = names->GetFile( i );
if ( stripFolder ) {
name.Strip( folder );
} else {
name.Strip( "/" );
}
name = args.Argv( 0 ) + ( " " + name );
completionParms.Append( name );
}
fileSystem->FreeFileList( names );
}
va_end( argPtr );
}
开发者ID:ProfessorKaos64,项目名称:tdm,代码行数:74,代码来源:CmdSystem.cpp
注:本文中的idStrList类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论