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

C++ PHYSFS_enumerateFiles函数代码示例

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

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



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

示例1: FS_Init

void FS_Init(const char *argv0) {
	int err = PHYSFS_init(argv0);

	if (err == 0) {
		Con_Errorf(ERR_FATAL, "Error in PHYSFS_init: %s", PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode()));
		return;
	}

	const char *baseDir = PHYSFS_getBaseDir();
	fs_basepath = Con_GetVarDefault("fs.basepath", baseDir, CONVAR_STARTUP);
	fs_basegame = Con_GetVarDefault("fs.basegame", "base", CONVAR_STARTUP);
	fs_game = Con_GetVarDefault("fs.game", DEFAULT_GAME, CONVAR_STARTUP);

	bool modLoaded = fs_game->string[0] != '\0';

	char **baseFiles, **gameFiles;

	// get the file listing for the basegame dir, then immediately unmount
	const char *fullBasePath = tempstr("%s/%s", fs_basepath->string, fs_basegame->string);
	PHYSFS_mount(fullBasePath, "/", 1);
	baseFiles = PHYSFS_enumerateFiles("/");
	PHYSFS_removeFromSearchPath(fullBasePath);

	// if fs_game is set, do the same thing for the fs_game dir
	if (modLoaded) {
		const char *fullGamePath = tempstr("%s/%s", fs_basepath->string, fs_game->string);
		PHYSFS_mount(fullGamePath, "/", 1);
		gameFiles = PHYSFS_enumerateFiles("/");
		PHYSFS_removeFromSearchPath(fullGamePath);

		// mount the mod dir first, then mount mod PK3s
		PHYSFS_mount(tempstr("%s/%s", fs_basepath->string, fs_game->string), "/", 1);
		FS_AddPaksFromList(gameFiles, fs_basepath->string, fs_game->string);
		PHYSFS_freeList(gameFiles);
	}

	// then mount the base game dir, then the mount base game PK3s
	PHYSFS_mount(tempstr("%s/%s", fs_basepath->string, fs_basegame->string), "/", 1);
	FS_AddPaksFromList(baseFiles, fs_basepath->string, fs_basegame->string);
	PHYSFS_freeList(baseFiles);

	// print all the files we've found in order of priority
	Con_Printf("Current filesystem search path:\n");
	PHYSFS_getSearchPathCallback(printSearchPath, NULL);
	Con_Printf("\n");

	// add command handler for dir to view virtual filesystem
	Con_AddCommand("dir", Cmd_Dir_f);
}
开发者ID:sponge,项目名称:sdlgame,代码行数:49,代码来源:files.cpp


示例2: buildMapList

bool buildMapList(void)
{
	char ** filelist, ** file;
	size_t len;

	if (!loadLevFile("gamedesc.lev", mod_campaign, false))
	{
		return false;
	}
	loadLevFile("addon.lev", mod_multiplay, false);

	filelist = PHYSFS_enumerateFiles("");
	for ( file = filelist; *file != NULL; ++file )
	{
		len = strlen( *file );
		if ( len > 10 // Do not add addon.lev again
				&& !strcasecmp( *file+(len-10), ".addon.lev") )
		{
			loadLevFile(*file, mod_multiplay, true);
		}
		// add support for X player maps using a new name to prevent conflicts.
		if ( len > 13 && !strcasecmp( *file+(len-13), ".xplayers.lev") )
		{
			loadLevFile(*file, mod_multiplay, true);
		}

	}
	PHYSFS_freeList( filelist );
	return true;
}
开发者ID:tomworld10,项目名称:warzone2100,代码行数:30,代码来源:init.cpp


示例3: file_getdirlist

static PHYSFSX_counted_list file_getdirlist(const char *dir)
{
	ntstring<PATH_MAX - 1> path;
	auto dlen = path.copy_if(dir);
	if ((!dlen && dir[0] != '\0') || !path.copy_if(dlen, "/"))
		return nullptr;
	++ dlen;
	PHYSFSX_counted_list list{PHYSFS_enumerateFiles(dir)};
	if (!list)
		return nullptr;
	const auto predicate = [&](char *i) -> bool {
		if (path.copy_if(dlen, i) && PHYSFS_isDirectory(path))
			return false;
		free(i);
		return true;
	};
	auto j = std::remove_if(list.begin(), list.end(), predicate);
	*j = NULL;
	auto NumDirs = j.get() - list.get();
	qsort(list.get(), NumDirs, sizeof(char *), string_array_sort_func);
	if (*dir)
	{
		// Put the 'go to parent directory' sequence '..' first
		++NumDirs;
		auto r = reinterpret_cast<char **>(realloc(list.get(), sizeof(char *)*(NumDirs + 1)));
		if (!r)
			return list;
		list.release();
		list.reset(r);
		std::move_backward(r, r + NumDirs, r + NumDirs + 1);
		list[0] = d_strdup("..");
	}
	list.set_count(NumDirs);
	return list;
}
开发者ID:btb,项目名称:dxx-rebirth,代码行数:35,代码来源:file.cpp


示例4: PHYSFS_getDirSeparator

void
ResourceManager::searchAndAddArchives(const std::string &path,
                                      const std::string &ext,
                                      bool append)
{
    const char *dirSep = PHYSFS_getDirSeparator();
    char **list = PHYSFS_enumerateFiles(path.c_str());

    for (char **i = list; *i != NULL; i++)
    {
        size_t len = strlen(*i);

        if (len > ext.length() && !ext.compare((*i)+(len - ext.length())))
        {
            std::string file, realPath, archive;

            file = path + (*i);
            realPath = std::string(PHYSFS_getRealDir(file.c_str()));
            archive = realPath + dirSep + file;

            addToSearchPath(archive, append);
        }
    }

    PHYSFS_freeList(list);
}
开发者ID:igneus,项目名称:particled,代码行数:26,代码来源:resourcemanager.cpp


示例5: cmd_enumerate

static int cmd_enumerate(char *args)
{
    char **rc;

    if (*args == '\"')
    {
        args++;
        args[strlen(args) - 1] = '\0';
    } /* if */

    rc = PHYSFS_enumerateFiles(args);

    if (rc == NULL)
        printf("Failure. reason: %s.\n", PHYSFS_getLastError());
    else
    {
        int file_count;
        char **i;
        for (i = rc, file_count = 0; *i != NULL; i++, file_count++)
            printf("%s\n", *i);

        printf("\n total (%d) files.\n", file_count);
        PHYSFS_freeList(rc);
    } /* else */

    return(1);
} /* cmd_enumerate */
开发者ID:Gokulakrishnansr,项目名称:cdogs-sdl,代码行数:27,代码来源:test_physfs.c


示例6: glyph_width

Font::Font(GlyphWidth glyph_width_,
           const std::string& filename,
           int shadowsize_) :
  glyph_width(glyph_width_),
  glyph_surfaces(),
  shadow_surfaces(),
  char_height(),
  shadowsize(shadowsize_),
  glyphs(65536)
{
  for(unsigned int i=0; i<65536;i++) glyphs[i].surface_idx = -1;

  const std::string fontdir = FileSystem::dirname(filename);
  const std::string fontname = FileSystem::basename(filename);

  // scan for prefix-filename in addons search path
  char **rc = PHYSFS_enumerateFiles(fontdir.c_str());
  for (char **i = rc; *i != NULL; i++) {
    std::string filename(*i);
    if( filename.rfind(fontname) != std::string::npos ) {
      loadFontFile(fontdir + filename);
    }
  }
  PHYSFS_freeList(rc);
}
开发者ID:AndroidAppList,项目名称:Android-Supertux,代码行数:25,代码来源:font.cpp


示例7: l_filesystem_enumerate

static int l_filesystem_enumerate(lua_State* state) {
  int n = lua_gettop(state);

  const char * dir = l_tools_toStringOrError(state, 1);
  int error = PHYSFS_mount(dir, "/", 1);

  if (error != 1)
    return printf("%s %s %s \n", "Error: Directory or archive named : ", dir ," does not exist");

  char **rc = PHYSFS_enumerateFiles("/");
  char **i;
  int index = 1;

  if( n != 1 )
    return luaL_error(state, "Function s a single parameter.");

  lua_newtable(state);

  for (i = rc; *i != 0; i++)
    {
      lua_pushinteger(state, index);
      lua_pushstring(state, *i);
      lua_settable(state, -3);
      index++;
    }

  PHYSFS_freeList(rc);
  return 1;
}
开发者ID:Murii,项目名称:CLove,代码行数:29,代码来源:filesystem.c


示例8: addSubdirs

/*!
 * Tries to mount a list of directories, found in /basedir/subdir/<list>.
 * \param basedir Base directory
 * \param subdir A subdirectory of basedir
 * \param appendToPath Whether to append or prepend
 * \param checkList List of directories to check. NULL means any.
 */
void addSubdirs( const char * basedir, const char * subdir, const bool appendToPath, char * checkList[], bool addToModList )
{
	char tmpstr[PATH_MAX];
	char buf[256];
	char ** subdirlist = PHYSFS_enumerateFiles( subdir );
	char ** i = subdirlist;
	while( *i != NULL )
	{
#ifdef DEBUG
		debug( LOG_NEVER, "addSubdirs: Examining subdir: [%s]", *i );
#endif // DEBUG
		if (*i[0] != '.' && (!checkList || inList(checkList, *i)))
		{
			snprintf(tmpstr, sizeof(tmpstr), "%s%s%s%s", basedir, subdir, PHYSFS_getDirSeparator(), *i);
#ifdef DEBUG
			debug( LOG_NEVER, "addSubdirs: Adding [%s] to search path", tmpstr );
#endif // DEBUG
			if (addToModList)
			{
				addLoadedMod(*i);
				snprintf(buf, sizeof(buf), "mod: %s", *i);
				addDumpInfo(buf);
			}
			PHYSFS_addToSearchPath( tmpstr, appendToPath );
		}
		i++;
	}
	PHYSFS_freeList( subdirlist );
}
开发者ID:GhostKing,项目名称:warzone2100,代码行数:36,代码来源:main.cpp


示例9: PHYSFS_enumerateFiles

/**Enumerates all files available in a path.
 * \param path String pointing to the path
 * \return Nonzero on success */
list<string> Filesystem::Enumerate( const string& path, const string &suffix )
{
	list<string> files;
	char **rc;

	rc = PHYSFS_enumerateFiles(path.c_str());
	if (rc == NULL){
		LogMsg(ERR,"Failure to enumerate %s. reason: %s.\n",
				path.c_str(),PHYSFS_getLastError());
	}
	else
	{
		int file_count;
		char **i;
		for (i = rc, file_count = 0; *i != NULL; i++, file_count++)
		{
			files.push_back( string(*i) );
		}

		LogMsg(INFO,"\n total (%d) files.\n", file_count);
		PHYSFS_freeList(rc);
		return 1;
	}
	return files;
}
开发者ID:Maka7879,项目名称:Epiar,代码行数:28,代码来源:filesystem.cpp


示例10: PHYSFS_enumerateFiles

void MainMenu::fillLoadMenu( bool save /*= false*/ )
{
    const std::string buttonNames[]={"File0","File1","File2","File3","File4","File5"};

    char** rc = PHYSFS_enumerateFiles("/");

    char* curfile;
    CheckButton *button;

    for(int i=0;i<6;i++) {
        char* recentfile = NULL;
        PHYSFS_sint64 t = 0;

        std::stringstream filestart;
        filestart << i+1 << "_";
        if( save ){
            button = getCheckButton(*saveGameMenu.get(),buttonNames[i]);
        } else {
            button = getCheckButton(*loadGameMenu.get(),buttonNames[i]);
        }
        //make sure Button is connected only once
        button->clicked.clear();
        if( save )
            button->clicked.connect(makeCallback(*this,&MainMenu::selectSaveGameButtonClicked));
        else {
            button->clicked.connect(makeCallback(*this,&MainMenu::selectLoadGameButtonClicked));
        }
        for(char** i = rc; *i != 0; i++){
            curfile = *i;
            if(std::string( curfile ).find( filestart.str() ) == 0 ) {
                // && !( curfile->d_type & DT_DIR  ) ) is not portable. So
                // don't create a directoy named 2_ in a savegame-directory or
                // you can no longer load from slot 2.
                if (t == 0) {
                    recentfile = curfile;
                    t = PHYSFS_getLastModTime(recentfile);
              } else {
                    if (PHYSFS_getLastModTime(curfile) > t) {
/*#ifdef DEBUG
                        fprintf(stderr," %s is more recent than previous %s\n",
                                          curfile, recentfile);
#endif*/
                        recentfile = curfile;
                        t = PHYSFS_getLastModTime(recentfile);
                    }
                }
            }
        }
#ifdef DEBUG
        fprintf(stderr,"Most recent file: %s\n\n",recentfile);
#endif

        if(t != 0) {
            std::string f= recentfile;
            button->setCaptionText(f);
        } else {
            button->setCaptionText(_("empty"));
        }
    }
}
开发者ID:okosan,项目名称:lincity-xg,代码行数:60,代码来源:MainMenu.cpp


示例11: WzConfigHack

WzConfig::WzConfig(const QString &name, WzConfig::warning warning, QObject *parent)
	: WzConfigHack(name, (int)warning), m_settings(QString("wz::") + name, QSettings::IniFormat, parent), m_overrides()
{
	if (m_settings.status() != QSettings::NoError && (warning != ReadOnly || PHYSFS_exists(name.toUtf8().constData())))
	{
		debug(LOG_FATAL, "Could not open \"%s\"", name.toUtf8().constData());
	}
	char **diffList = PHYSFS_enumerateFiles("diffs");
	char **i;
	int j;
	for (i = diffList; *i != NULL; i++) 
	{
		std::string str(std::string("diffs/") + *i + std::string("/") + name.toUtf8().constData());
		if (!PHYSFS_exists(str.c_str())) 
			continue;
		QSettings tmp(QString("wz::") + str.c_str(), QSettings::IniFormat);
		if (tmp.status() != QSettings::NoError)
		{
			debug(LOG_FATAL, "Could not read an override for \"%s\"", name.toUtf8().constData());
		}
		QStringList keys(tmp.allKeys());
		for (j = 0; j < keys.length(); j++)
		{
			m_overrides.insert(keys[j],tmp.value(keys[j]));
		}
	}
	PHYSFS_freeList(diffList);
}
开发者ID:Cjkjvfnby,项目名称:warzone2100,代码行数:28,代码来源:wzconfig.cpp


示例12: getGameView

void Game::testAllHelpFiles(){
    getGameView()->printStatusMessage( "Testing Help Files...");

    std::string filename;
    std::string directory = "help/en";
    std::string fullname;
    char **rc = PHYSFS_enumerateFiles( directory.c_str() );
    char **i;
    size_t pos;
    for (i = rc; *i != NULL; i++) {
        fullname = directory;
        fullname.append( *i );
        filename.assign( *i );

        if(PHYSFS_isDirectory(fullname.c_str()))
            continue;

        pos = filename.rfind( ".xml" );
        if( pos != std::string::npos ){
            filename.replace( pos, 4 ,"");
            std::cerr << "--- Examining " << filename << "\n";
            helpWindow->showTopic( filename );
            std::cerr << "\n";
        }
    }
    PHYSFS_freeList(rc);
}
开发者ID:SirIvanMoReau,项目名称:lincity-ng,代码行数:27,代码来源:Game.cpp


示例13: decltype

std::string
AddonManager::scan_for_info(const std::string& archive_os_path) const
{
  std::unique_ptr<char*, decltype(&PHYSFS_freeList)>
    rc2(PHYSFS_enumerateFiles("/"),
        PHYSFS_freeList);
  for(char** j = rc2.get(); *j != 0; ++j)
  {
    if (has_suffix(*j, ".nfo"))
    {
      std::string nfo_filename = FileSystem::join("/", *j);

      // make sure it's in the current archive_os_path
      const char* realdir = PHYSFS_getRealDir(nfo_filename.c_str());
      if (!realdir)
      {
        log_warning << "PHYSFS_getRealDir() failed for " << nfo_filename << ": " << PHYSFS_getLastError() << std::endl;
      }
      else
      {
        if (realdir == archive_os_path)
        {
          return nfo_filename;
        }
      }
    }
  }

  return std::string();
}
开发者ID:Karkus476,项目名称:supertux,代码行数:30,代码来源:addon_manager.cpp


示例14: removeSubdirs

void removeSubdirs( const char * basedir, const char * subdir, char * checkList[] )
{
	char tmpstr[PATH_MAX];
	char ** subdirlist = PHYSFS_enumerateFiles( subdir );
	char ** i = subdirlist;
	while( *i != NULL )
	{
#ifdef DEBUG
		debug( LOG_NEVER, "removeSubdirs: Examining subdir: [%s]", *i );
#endif // DEBUG
		if( !checkList || inList( checkList, *i ) )
		{
			snprintf(tmpstr, sizeof(tmpstr), "%s%s%s%s", basedir, subdir, PHYSFS_getDirSeparator(), *i);
#ifdef DEBUG
			debug( LOG_NEVER, "removeSubdirs: Removing [%s] from search path", tmpstr );
#endif // DEBUG
			if (!PHYSFS_removeFromSearchPath( tmpstr ))
			{
#ifdef DEBUG	// spams a ton!
				debug(LOG_NEVER, "Couldn't remove %s from search path because %s", tmpstr, PHYSFS_getLastError());
#endif // DEBUG
			}
		}
		i++;
	}
	PHYSFS_freeList( subdirlist );
}
开发者ID:GhostKing,项目名称:warzone2100,代码行数:27,代码来源:main.cpp


示例15: mLeftPlayer

ReplayMenuState::ReplayMenuState() :
    mLeftPlayer(LEFT_PLAYER),
    mRightPlayer(RIGHT_PLAYER)
{
    IMGUI::getSingleton().resetSelection();
    mReplaying = false;
    mChecksumError = false;

    mReplayMatch = 0;
    mReplayRecorder = 0;
    mSelectedReplay = 0;
    char** filenames = PHYSFS_enumerateFiles("replays");
    for (int i = 0; filenames[i] != 0; ++i)
    {
        std::string tmp(filenames[i]);
        if (tmp.find(".bvr") != std::string::npos)
        {
            mReplayFiles.push_back(std::string(tmp.begin(), tmp.end()-4));
        }
    }
    if (mReplayFiles.size() == 0)
        mSelectedReplay = -1;
    std::sort(mReplayFiles.rbegin(), mReplayFiles.rend());

    mLeftPlayer.loadFromConfig("left");
    mRightPlayer.loadFromConfig("right");
}
开发者ID:angelonuffer,项目名称:blobby-volley-2,代码行数:27,代码来源:State.cpp


示例16: PHYSFS_enumerateFiles

std::list<UString> FileSystem::enumerateDirectory(const UString &basePath,
                                                  const UString &extension) const
{
	std::list<UString> result;
	bool filterByExtension = !extension.empty();

	char **elements = PHYSFS_enumerateFiles(basePath.cStr());
	for (char **element = elements; *element != NULL; element++)
	{
		if (!filterByExtension)
		{
			result.push_back(*element);
		}
		else
		{
			const UString elementString = (*element);
			if (elementString.endsWith(extension))
			{
				result.push_back(elementString);
			}
		}
	}
	PHYSFS_freeList(elements);
	return result;
}
开发者ID:JonnyH,项目名称:OpenApoc,代码行数:25,代码来源:physfs_fs.cpp


示例17: debug

WzConfig::WzConfig(const QString &name, WzConfig::warning warning, QObject *parent)
{
	UDWORD size;
	char *data;
	QJsonParseError error;

	mFilename = name;
	mStatus = true;
	mWarning = warning;

	if (!PHYSFS_exists(name.toUtf8().constData()))
	{
		if (warning == ReadOnly)
		{
			mStatus = false;
			debug(LOG_ERROR, "IGNORED %s", name.toUtf8().constData());
			return;
		}
		else if (warning == ReadAndWrite)
		{
			mJson = QJsonDocument();
			mObj = mJson.object();
			debug(LOG_ERROR, "PREPARED %s", name.toUtf8().constData());
			return;
		}
	}
	if (!loadFile(name.toUtf8().constData(), &data, &size))
	{
		debug(LOG_FATAL, "Could not open \"%s\"", name.toUtf8().constData());
	}
	mJson = QJsonDocument::fromJson(QByteArray(data, size), &error);
	ASSERT(!mJson.isNull(), "JSON document from %s is invalid: %s", name.toUtf8().constData(), error.errorString().toUtf8().constData());
	ASSERT(mJson.isObject(), "JSON document from %s is not an object. Read: \n%s", name.toUtf8().constData(), data);
	mObj = mJson.object();
#if 0
	char **diffList = PHYSFS_enumerateFiles("diffs");
	char **i;
	int j;
	for (i = diffList; *i != NULL; i++) 
	{
		std::string str(std::string("diffs/") + *i + std::string("/") + name.toUtf8().constData());
		if (!PHYSFS_exists(str.c_str())) 
			continue;
		QSettings tmp(QString("wz::") + str.c_str(), QSettings::IniFormat);
		if (tmp.status() != QSettings::NoError)
		{
			debug(LOG_FATAL, "Could not read an override for \"%s\"", name.toUtf8().constData());
		}
		QStringList keys(tmp.allKeys());
		for (j = 0; j < keys.length(); j++)
		{
			m_overrides.insert(keys[j],tmp.value(keys[j]));
		}
	}
	PHYSFS_freeList(diffList);
#endif
}
开发者ID:henryfung01,项目名称:warzone2100,代码行数:57,代码来源:wzconfig.cpp


示例18: enumerateFiles

StringList enumerateFiles(const string& directory) {
	StringList files;
	char ** listBegin = PHYSFS_enumerateFiles(directory.c_str());
	for (char ** file = listBegin; *file != NULL; file++) {
		files.push_back(*file);
	}
	PHYSFS_freeList(listBegin);
	return files;
}
开发者ID:dekimsey,项目名称:physfs-cpp,代码行数:9,代码来源:physfs.cpp


示例19: enumerateFiles

 StringVector enumerateFiles(const std::string& dir)
 {
   StringVector list;
   char** lst = PHYSFS_enumerateFiles(dir.c_str());
   for (char** l = lst; *l != 0; ++l)
     list.push_back(*l);
   PHYSFS_freeList(lst);
   return list;
 }
开发者ID:yildiz-online,项目名称:module-graphic-ogre,代码行数:9,代码来源:PhysFS++.cpp


示例20: Cmd_Dir_f

void Cmd_Dir_f() {
	const char *path = Con_GetArgsCount() > 1 ? Con_GetArg(1) : "/";
	char **rc = PHYSFS_enumerateFiles(path);
	char **i;

	Con_Printf("Directory listing of %s\n", path);
	for (i = rc; *i != NULL; i++)
		Con_Printf("%s\n", *i);

	PHYSFS_freeList(rc);
}
开发者ID:sponge,项目名称:sdlgame,代码行数:11,代码来源:files.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ PHYSFS_exists函数代码示例发布时间:2022-05-30
下一篇:
C++ PHYSFS_close函数代码示例发布时间: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