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

C++ PHYSFS_getDirSeparator函数代码示例

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

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



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

示例1: replaceSeparators

	static void replaceSeparators(std::string& path)
	{
		static const std::regex pattern_replace("[\\\\\\/]");
		path = std::regex_replace(path, pattern_replace, PHYSFS_getDirSeparator());

		static const std::regex pattern_match("^.*[\\\\\\/]$");
		if (std::regex_match(path, pattern_match))
			path.append(PHYSFS_getDirSeparator());
	}
开发者ID:Wezthal,项目名称:DerpEngine,代码行数:9,代码来源:fileManager.cpp


示例2: registerSearchPath

/*!
 * Register searchPath above the path with next lower priority
 * For information about what can be a search path, refer to PhysFS documentation
 */
void registerSearchPath(const char path[], unsigned int priority)
{
	wzSearchPath *curSearchPath = searchPathRegistry, * tmpSearchPath = nullptr;

	tmpSearchPath = (wzSearchPath *)malloc(sizeof(*tmpSearchPath));
	sstrcpy(tmpSearchPath->path, path);
	if (path[strlen(path) - 1] != *PHYSFS_getDirSeparator())
	{
		sstrcat(tmpSearchPath->path, PHYSFS_getDirSeparator());
	}
	tmpSearchPath->priority = priority;

	debug(LOG_WZ, "registerSearchPath: Registering %s at priority %i", path, priority);
	if (!curSearchPath)
	{
		searchPathRegistry = tmpSearchPath;
		searchPathRegistry->lowerPriority = nullptr;
		searchPathRegistry->higherPriority = nullptr;
		return;
	}

	while (curSearchPath->higherPriority && priority > curSearchPath->priority)
	{
		curSearchPath = curSearchPath->higherPriority;
	}
	while (curSearchPath->lowerPriority && priority < curSearchPath->priority)
	{
		curSearchPath = curSearchPath->lowerPriority;
	}

	if (priority < curSearchPath->priority)
	{
		tmpSearchPath->lowerPriority = curSearchPath->lowerPriority;
		tmpSearchPath->higherPriority = curSearchPath;
	}
	else
	{
		tmpSearchPath->lowerPriority = curSearchPath;
		tmpSearchPath->higherPriority = curSearchPath->higherPriority;
	}

	if (tmpSearchPath->lowerPriority)
	{
		tmpSearchPath->lowerPriority->higherPriority = tmpSearchPath;
	}
	if (tmpSearchPath->higherPriority)
	{
		tmpSearchPath->higherPriority->lowerPriority = tmpSearchPath;
	}
}
开发者ID:perim,项目名称:warzone2100,代码行数:54,代码来源:init.cpp


示例3: 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


示例4: 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


示例5: splitPath

/* extracts the dirname and the basename from the path */
static void splitPath(const char *path, char **dir, char **base) {
	char *ptr;
	const char *dirsep = NULL;
	*base = (char *)path;
	*dir = (char *)".";
	dirsep = PHYSFS_getDirSeparator();
	if (strlen(dirsep) == 1) { /* fast path. */
		ptr = strrchr(path, *dirsep);
	}
	else {
		ptr = strstr(path, dirsep);
		if (ptr != NULL) {
			char *p = ptr;
			while (p != NULL) {
				ptr = p;
				p = strstr(p + 1, dirsep);
			}
		}
	}
	if (ptr != NULL) {
		size_t size = (size_t) (ptr - path);
		*dir = (char *) malloc(size + 1);
		memcpy(*dir, path, size);
		(*dir)[size] = '\0';
		*base = ptr + strlen(dirsep);
	}
}
开发者ID:scriptum,项目名称:Engine,代码行数:28,代码来源:FileIO.c


示例6: PHYSFS_getRealDir

/**Returns the full path to the file
 * \return path successful.*/
string File::GetAbsolutePath(){
	string abs = PHYSFS_getRealDir( validName.c_str() );

	abs += PHYSFS_getDirSeparator() + validName;

	return abs;
}
开发者ID:cthielen,项目名称:epiar,代码行数:9,代码来源:file.cpp


示例7: 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


示例8: PHYSFS_getDirSeparator

static DirHandle *DIR_openArchive(const char *name, int forWriting)
{
    const char *dirsep = PHYSFS_getDirSeparator();
    DirHandle *retval = NULL;
    size_t namelen = strlen(name);
    size_t seplen = strlen(dirsep);

    BAIL_IF_MACRO(!DIR_isArchive(name, forWriting),
                    ERR_UNSUPPORTED_ARCHIVE, NULL);

    retval = (DirHandle *) malloc(sizeof (DirHandle));
    BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);
    retval->opaque = malloc(namelen + seplen + 1);
    if (retval->opaque == NULL)
    {
        free(retval);
        BAIL_MACRO(ERR_OUT_OF_MEMORY, NULL);
    } /* if */

        /* make sure there's a dir separator at the end of the string */
    strcpy((char *) (retval->opaque), name);
    if (strcmp((name + namelen) - seplen, dirsep) != 0)
        strcat((char *) (retval->opaque), dirsep);

    retval->funcs = &__PHYSFS_DirFunctions_DIR;

    return(retval);
} /* DIR_openArchive */
开发者ID:UIKit0,项目名称:paragui,代码行数:28,代码来源:dir.c


示例9: getSaveDir

	std::string getSaveDir()
	{
		std::string saveDir = PHYSFS_getWriteDir();
		if (Utils::endsWith(saveDir, "\\") == false &&
			Utils::endsWith(saveDir, "/") == false)
		{
			saveDir += PHYSFS_getDirSeparator();
		}
		return saveDir;
	}
开发者ID:dgengin,项目名称:DGEngine,代码行数:10,代码来源:FileUtils.cpp


示例10: PHYSFS_getWriteDir

std::string Resources::getRealWriteName(const char* filename) {
    const char* dir = PHYSFS_getWriteDir();
    if (dir == 0) {
        PError << "no writedir defined" << endl;
        return NULL;
    }
    std::string realname = dir;
    realname += PHYSFS_getDirSeparator();
    realname += filename;
    return realname;
}
开发者ID:ezh,项目名称:ENikiBENiki,代码行数:11,代码来源:Resources.cpp


示例11: PHYSFS_getRealDir

std::string Resources::getRealName(const char* filename) {
    const char* dir = PHYSFS_getRealDir(filename);
    if (dir == 0) {
        PError << "no such path '" << filename << "'" << endl;
        return NULL;
    };
    std::string realname = dir;
    realname += PHYSFS_getDirSeparator();
    realname += filename;
    return realname;
}
开发者ID:ezh,项目名称:ENikiBENiki,代码行数:11,代码来源:Resources.cpp


示例12: getRealWriteName

std::string getRealWriteName(const char* filename)
{
    const char* dir = PHYSFS_getWriteDir();
    if (dir == 0) {
        throw Exception("no writedir defined");
    }
    std::string realname = dir;
    realname += PHYSFS_getDirSeparator();
    realname += filename;
    return realname;
}
开发者ID:BackupTheBerlios,项目名称:netpanzer-svn,代码行数:11,代码来源:FileSystem.cpp


示例13: basename

const char * basename(const char * filename)
{
    const char * last_found = filename;
    const char * sep;
    do
    {
        sep = strstr(last_found, PHYSFS_getDirSeparator());
        last_found = sep ? sep + 1 : last_found;
    } while (sep);
    return last_found;
}
开发者ID:Chingliu,项目名称:seed,代码行数:11,代码来源:seed.c


示例14: getRealName

std::string getRealName(const char* filename)
{
    const char* dir = PHYSFS_getRealDir(filename);
    if (dir == 0) {
        throw Exception("no such path '%s'", filename);
    }
    std::string realname = dir;
    realname += PHYSFS_getDirSeparator();
    realname += filename;
    return realname;
}
开发者ID:BackupTheBerlios,项目名称:netpanzer-svn,代码行数:11,代码来源:FileSystem.cpp


示例15: getPlatformUserDir

static void getPlatformUserDir(char * const tmpstr, size_t const size)
{
#if defined(WZ_OS_WIN)
	wchar_t tmpWStr[MAX_PATH];
	if ( SUCCEEDED( SHGetFolderPathW( NULL, CSIDL_PERSONAL|CSIDL_FLAG_CREATE, NULL, SHGFP_TYPE_CURRENT, tmpWStr ) ) )
	{
		if (WideCharToMultiByte(CP_UTF8, 0, tmpWStr, -1, tmpstr, size, NULL, NULL) == 0)
		{
			debug(LOG_ERROR, "Encoding conversion error.");
			exit(1);
		}
		strlcat(tmpstr, PHYSFS_getDirSeparator(), size);
	}
	else
#elif defined(WZ_OS_MAC)
	FSRef fsref;
	OSErr error = FSFindFolder(kUserDomain, kApplicationSupportFolderType, false, &fsref);
	if (!error)
		error = FSRefMakePath(&fsref, (UInt8 *) tmpstr, size);
	if (!error)
		strlcat(tmpstr, PHYSFS_getDirSeparator(), size);
	else
#endif
	if (PHYSFS_getUserDir())
	{
		strlcpy(tmpstr, PHYSFS_getUserDir(), size); // Use PhysFS supplied UserDir (As fallback on Windows / Mac, default on Linux)
	}
	// If PhysicsFS fails (might happen if environment variable HOME is unset or wrong) then use the current working directory
	else if (getCurrentDir(tmpstr, size))
	{
		strlcat(tmpstr, PHYSFS_getDirSeparator(), size);
	}
	else
	{
		debug(LOG_FATAL, "Can't get UserDir?");
		abort();
	}
}
开发者ID:omgbebebe,项目名称:warzone2100,代码行数:38,代码来源:main.cpp


示例16: setupPHYSFS

void setupPHYSFS()
{
    std::string separator = PHYSFS_getDirSeparator();
    // Game should be playable out of the source package on all 
    // platforms
    PHYSFS_addToSearchPath("data", 1);
    PHYSFS_addToSearchPath("data/gfx.zip", 1);
    PHYSFS_addToSearchPath("data/sounds.zip", 1);
    PHYSFS_addToSearchPath("data/scripts.zip", 1);
    PHYSFS_addToSearchPath("data/backgrounds.zip", 1);

#if defined(WIN32)
    // Just write in installation directory
    PHYSFS_setWriteDir("data");
#else
    // handle the case when it is installed
    PHYSFS_addToSearchPath(BLOBBY_INSTALL_PREFIX  "/share/blobby", 1);
    PHYSFS_addToSearchPath(BLOBBY_INSTALL_PREFIX  "/share/blobby/gfx.zip", 1);
    PHYSFS_addToSearchPath(BLOBBY_INSTALL_PREFIX  "/share/blobby/sounds.zip", 1);
    PHYSFS_addToSearchPath(BLOBBY_INSTALL_PREFIX  "/share/blobby/scripts.zip", 1);
    PHYSFS_addToSearchPath(BLOBBY_INSTALL_PREFIX  "/share/blobby/backgrounds.zip", 1);

    // Create a search path in the home directory and ensure that
    // all paths exist and are actually directories
    std::string userdir = PHYSFS_getUserDir();
    std::string userAppend = ".blobby";
    std::string homedir = userdir + userAppend;
    PHYSFS_addToSearchPath(userdir.c_str(), 0);
    PHYSFS_setWriteDir(userdir.c_str());
    probeDir(userAppend);
    probeDir(userAppend + separator + "replays");
    probeDir(userAppend + separator + "gfx");
    probeDir(userAppend + separator + "sounds");
    probeDir(userAppend + separator + "scripts");
    probeDir(userAppend + separator + "backgrounds");
    PHYSFS_removeFromSearchPath(userdir.c_str());
    PHYSFS_setWriteDir(homedir.c_str());
    PHYSFS_addToSearchPath(homedir.c_str(), 0);
#if defined(GAMEDATADIR)
    // A global installation path makes only sense on non-Windows
    // platforms
    std::string basedir = GAMEDATADIR;
    PHYSFS_addToSearchPath(basedir.c_str(), 1);
    PHYSFS_addToSearchPath((basedir + separator + "gfx.zip").c_str(), 1);
    PHYSFS_addToSearchPath((basedir + separator + "sounds.zip").c_str(), 1);
    PHYSFS_addToSearchPath((basedir + separator + "scripts.zip").c_str(), 1);
    PHYSFS_addToSearchPath((basedir + separator + "backgrounds.zip").c_str(), 1);
#endif
#endif
}
开发者ID:angelonuffer,项目名称:blobby-volley-2,代码行数:50,代码来源:main.cpp


示例17: LogMsg

/**\brief Save an XML file for this player
 * \details The filename is by default the player's name.
 */
void Player::Save( string scenario ) {
	xmlDocPtr xmlPtr;
	LogMsg( INFO, "Creation of %s", GetFileName().c_str() );

	// Create new XML Document
	xmlPtr = xmlNewDoc( BAD_CAST "1.0" );
	xmlNodePtr root_node = ToXMLNode("player");
	xmlDocSetRootElement(xmlPtr, root_node);

	xmlSaveFormatFileEnc( (std::string(PHYSFS_getWriteDir()) + std::string(PHYSFS_getDirSeparator()) + GetFileName()).c_str(), xmlPtr, "ISO-8859-1", 1);

	// Update and Save this player's info in the master players list.
	PlayerList::Instance()->GetPlayerInfo( GetName() )->Update( this, scenario );
	PlayerList::Instance()->Save();
}
开发者ID:cthielen,项目名称:epiar,代码行数:18,代码来源:player.cpp


示例18: PHYSFSX_getRealPath

int PHYSFSX_getRealPath(const char *stdPath, char *realPath)
{
	const char *realDir = PHYSFS_getRealDir(stdPath);
	const char *sep = PHYSFS_getDirSeparator();
	char *p;
	
	if (!realDir)
	{
		realDir = PHYSFS_getWriteDir();
		if (!realDir)
			return 0;
	}
	
	strncpy(realPath, realDir, PATH_MAX - 1);
	if (strlen(realPath) >= strlen(sep))
	{
		p = realPath + strlen(realPath) - strlen(sep);
		if (strcmp(p, sep)) // no sep at end of realPath
			strncat(realPath, sep, PATH_MAX - 1 - strlen(realPath));
	}
	
	if (strlen(stdPath) >= 1)
		if (*stdPath == '/')
			stdPath++;
	
	while (*stdPath)
	{
		if (*stdPath == '/')
			strncat(realPath, sep, PATH_MAX - 1 - strlen(realPath));
		else
		{
			if (strlen(realPath) < PATH_MAX - 2)
			{
				p = realPath + strlen(realPath);
				p[0] = *stdPath;
				p[1] = '\0';
			}
		}
		stdPath++;
	}
	
	return 1;
}
开发者ID:Pickle,项目名称:dxx-rebirth,代码行数:43,代码来源:physfsx.cpp


示例19: PHYSFS_getDirSeparator

static void *DIR_openArchive(const char *name, int forWriting)
{
    const char *dirsep = PHYSFS_getDirSeparator();
    char *retval = NULL;
    size_t namelen = strlen(name);
    size_t seplen = strlen(dirsep);

    /* !!! FIXME: when is this not called right before openArchive? */
    BAIL_IF_MACRO(!DIR_isArchive(name, forWriting),
                    ERR_UNSUPPORTED_ARCHIVE, 0);

    retval = allocator.Malloc(namelen + seplen + 1);
    BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);

        /* make sure there's a dir separator at the end of the string */
    strcpy(retval, name);
    if (strcmp((name + namelen) - seplen, dirsep) != 0)
        strcat(retval, dirsep);

    return(retval);
} /* DIR_openArchive */
开发者ID:leonlee,项目名称:tome,代码行数:21,代码来源:dir.c


示例20: PHYSFS_getDirSeparator

void ResourceManager::discoverWorkDir(const std::string& appName, const std::string& existentFile)
{
    // search for modules directory
    std::string sep = PHYSFS_getDirSeparator();
    std::string possiblePaths[] = { "",
                                    g_resources.getBaseDir(),
                                    g_resources.getBaseDir() + ".." + sep,
                                    g_resources.getBaseDir() + ".." + sep + "share" + sep + appName + sep,
                                    g_resources.getBaseDir() + appName + sep };
    bool found = false;
    for(const std::string& dir : possiblePaths) {
        // try to directory to modules path to see if it exists
        std::ifstream fin(dir + existentFile);
        if(fin) {
            g_logger.debug(stdext::format("Found work dir at '%s'", dir.c_str()));
            m_workDir = dir;
            found = true;
            break;
        }
    }

    if(!found)
        g_logger.fatal(stdext::format("Unable to find %s, the application cannot be initialized.", existentFile));
}
开发者ID:LeandroPerrotta,项目名称:otclient,代码行数:24,代码来源:resourcemanager.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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