本文整理汇总了C++中PHYSFS_getDirSeparator函数的典型用法代码示例。如果您正苦于以下问题:C++ PHYSFS_getDirSeparator函数的具体用法?C++ PHYSFS_getDirSeparator怎么用?C++ PHYSFS_getDirSeparator使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PHYSFS_getDirSeparator函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
}
示例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;
}
}
示例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);
}
示例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 );
}
示例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);
}
}
示例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;
}
示例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 );
}
示例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 */
示例9: getSaveDir
std::string getSaveDir()
{
std::string saveDir = PHYSFS_getWriteDir();
if (Utils::endsWith(saveDir, "\\") == false &&
Utils::endsWith(saveDir, "/") == false)
{
saveDir += PHYSFS_getDirSeparator();
}
return saveDir;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
}