本文整理汇总了C++中PHYSFS_getRealDir函数的典型用法代码示例。如果您正苦于以下问题:C++ PHYSFS_getRealDir函数的具体用法?C++ PHYSFS_getRealDir怎么用?C++ PHYSFS_getRealDir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PHYSFS_getRealDir函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: 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:LucasVini,项目名称:OldNetPanzer,代码行数:11,代码来源:FileSystem.cpp
示例2: disable_addon
void
AddonManager::install_addon(const AddonId& addon_id)
{
{ // remove addon if it already exists
auto it = std::find_if(m_installed_addons.begin(), m_installed_addons.end(),
[&addon_id](const std::unique_ptr<Addon>& addon)
{
return addon->get_id() == addon_id;
});
if (it != m_installed_addons.end())
{
log_debug << "reinstalling addon " << addon_id << std::endl;
if ((*it)->is_enabled())
{
disable_addon((*it)->get_id());
}
m_installed_addons.erase(it);
}
else
{
log_debug << "installing addon " << addon_id << std::endl;
}
}
auto& repository_addon = get_repository_addon(addon_id);
std::string install_filename = FileSystem::join(m_addon_directory, repository_addon.get_filename());
m_downloader.download(repository_addon.get_url(), install_filename);
MD5 md5 = md5_from_file(install_filename);
if (repository_addon.get_md5() != md5.hex_digest())
{
if (PHYSFS_delete(install_filename.c_str()) == 0)
{
log_warning << "PHYSFS_delete failed: " << PHYSFS_getLastError() << std::endl;
}
throw std::runtime_error("Downloading Add-on failed: MD5 checksums differ");
}
else
{
const char* realdir = PHYSFS_getRealDir(install_filename.c_str());
if (!realdir)
{
throw std::runtime_error("PHYSFS_getRealDir failed: " + install_filename);
}
else
{
add_installed_archive(install_filename, md5.hex_digest());
}
}
}
开发者ID:Karkus476,项目名称:supertux,代码行数:53,代码来源:addon_manager.cpp
示例3: deleteAll
bool deleteAll(const char* filePath, bool deleteRoot)
{
PHYSFS_Stat fileStat;
if (PHYSFS_stat(filePath, &fileStat) == 0)
{
return false;
}
bool ret = false;
if (fileStat.filetype == PHYSFS_FILETYPE_DIRECTORY)
{
auto paths = PHYSFS_enumerateFiles(filePath);
if (paths != nullptr)
{
auto writeDir = PHYSFS_getWriteDir();
if (writeDir != nullptr)
{
for (char** path = paths; *path != nullptr; path++)
{
auto fullPath = std::string(filePath) + '/' + *path;
if (PHYSFS_stat(fullPath.c_str(), &fileStat) == 0)
{
continue;
}
if (fileStat.filetype == PHYSFS_FILETYPE_DIRECTORY)
{
deleteAll(fullPath.c_str(), true);
}
else
{
auto realDir = PHYSFS_getRealDir(fullPath.c_str());
if (realDir != nullptr)
{
if (std::strcmp(writeDir, realDir) == 0)
{
ret = PHYSFS_delete(fullPath.c_str()) != 0;
}
}
}
}
}
PHYSFS_freeList(paths);
}
if (deleteRoot == true)
{
ret = PHYSFS_delete(filePath) != 0;
}
}
else
{
ret = PHYSFS_delete(filePath) != 0;
}
return ret;
}
开发者ID:dgengin,项目名称:DGEngine,代码行数:53,代码来源:FileUtils.cpp
示例4: dataScriptLoad
// All scripts, binary or otherwise are now passed through this routine
static bool dataScriptLoad(const char* fileName, void **ppData)
{
static const bool printHack = false;
SCRIPT_CODE** psProg = (SCRIPT_CODE**)ppData;
PHYSFS_file* fileHandle;
uint8_t *pBuffer;
PHYSFS_sint64 fileSize = 0;
debug(LOG_WZ, "COMPILING SCRIPT ...%s", GetLastResourceFilename());
fileHandle = PHYSFS_openRead(fileName);
debug(LOG_WZ, "Reading...[directory: %s] %s", PHYSFS_getRealDir(fileName), fileName);
if (fileHandle == NULL)
{
return false;
}
// due to the changes in r2531 we must do this routine a bit different.
fileSize = PHYSFS_fileLength(fileHandle);
pBuffer = malloc(fileSize * sizeof(char));
if (pBuffer == NULL)
{
debug(LOG_FATAL, "Fatal memory allocation, couldn't allocate %lld buffer", fileSize);
abort();
}
PHYSFS_read(fileHandle, pBuffer, 1, fileSize);
calcDataHash(pBuffer, fileSize, DATA_SCRIPT);
free(pBuffer);
PHYSFS_seek(fileHandle, 0); //reset position
*psProg = scriptCompile(fileHandle, SCRIPTTYPE);
PHYSFS_close(fileHandle);
if (!*psProg) // see script.h
{
debug(LOG_ERROR, "Script %s did not compile", GetLastResourceFilename());
return false;
}
if (printHack)
{
cpPrintProgram(*psProg);
}
return true;
}
开发者ID:blezek,项目名称:warzone2100,代码行数:53,代码来源:data.c
示例5: buildMapList
bool buildMapList()
{
if (!loadLevFile("gamedesc.lev", mod_campaign, false, NULL))
{
return false;
}
loadLevFile("addon.lev", mod_multiplay, false, NULL);
WZ_Maps.clear();
MapFileList realFileNames = listMapFiles();
for (MapFileList::iterator realFileName = realFileNames.begin(); realFileName != realFileNames.end(); ++realFileName)
{
bool mapmod = false;
struct WZmaps CurrentMap;
std::string realFilePathAndName = PHYSFS_getRealDir(realFileName->c_str()) + *realFileName;
PHYSFS_addToSearchPath(realFilePathAndName.c_str(), PHYSFS_APPEND);
char **filelist = PHYSFS_enumerateFiles("");
for (char **file = filelist; *file != NULL; ++file)
{
std::string checkfile = *file;
size_t len = strlen(*file);
if (len > 10 && !strcasecmp(*file + (len - 10), ".addon.lev")) // Do not add addon.lev again
{
loadLevFile(*file, mod_multiplay, true, realFileName->c_str());
}
// 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, realFileName->c_str());
}
}
PHYSFS_freeList(filelist);
if (PHYSFS_removeFromSearchPath(realFilePathAndName.c_str()) == 0)
{
debug(LOG_ERROR, "Could not unmount %s, %s", realFilePathAndName.c_str(), PHYSFS_getLastError());
}
mapmod = CheckInMap(realFilePathAndName.c_str(), "WZMap", "WZMap");
if (!mapmod)
{
mapmod = CheckInMap(realFilePathAndName.c_str(), "WZMap", "WZMap/multiplay");
}
CurrentMap.MapName = realFileName->c_str();
CurrentMap.isMapMod = mapmod;
WZ_Maps.push_back(CurrentMap);
}
return true;
}
开发者ID:henryfung01,项目名称:warzone2100,代码行数:52,代码来源:init.cpp
示例6: PHYSFS_getRealDir
bool
AddonManager::is_from_old_addon(const std::string& filename) const
{
std::string real_path = PHYSFS_getRealDir(filename.c_str());
for (auto& addon : m_installed_addons) {
if (addon->get_format() == Addon::ORIGINAL &&
addon->is_enabled() &&
addon->get_install_filename() == real_path) {
return true;
}
}
return false;
}
开发者ID:Karkus476,项目名称:supertux,代码行数:13,代码来源:addon_manager.cpp
示例7: PHYSFS_getRealDir
bool Virtual_file_system::query_resolved_path(std::string& resolved_path, const std::string& name) const
{
const char* resolved = PHYSFS_getRealDir(name.c_str());
if (!resolved)
{
return false;
}
resolved_path = std::string(resolved);
return true;
}
开发者ID:Opioid,项目名称:Substitute,代码行数:13,代码来源:Virtual_file_system.cpp
示例8: deleteFile
bool deleteFile(const char* filePath) noexcept
{
auto writeDir = PHYSFS_getWriteDir();
auto realDir = PHYSFS_getRealDir(filePath);
if (writeDir != nullptr && realDir != nullptr)
{
if (strcmp(writeDir, realDir) == 0)
{
return PHYSFS_delete(filePath) != 0;
}
}
return false;
}
开发者ID:dgengin,项目名称:DGEngine,代码行数:13,代码来源:FileUtils.cpp
示例9: PHYSFS_getRealDir
std::string ResourceManager::getDataPath(std::string file)
{
if (doesExist(file))
{
std::string path = PHYSFS_getRealDir(file.c_str());
#ifndef _WIN32
return path + "/" + file;
#else
return path + file;
#endif
}
return "";
}
开发者ID:suprafun,项目名称:smalltowns,代码行数:13,代码来源:resourcemanager.cpp
示例10: dataScriptLoadVals
// Load a script variable values file
static bool dataScriptLoadVals(const char* fileName, void **ppData)
{
bool success;
PHYSFS_file* fileHandle;
uint8_t *pBuffer;
PHYSFS_sint64 fileSize = 0;
*ppData = NULL;
// don't load anything if a saved game is being loaded
if (saveFlag)
{
return true;
}
debug(LOG_WZ, "Loading script data %s", GetLastResourceFilename());
fileHandle = PHYSFS_openRead(fileName);
debug(LOG_WZ, "Reading...[directory: %s] %s", PHYSFS_getRealDir(fileName), fileName);
if (fileHandle == NULL)
{
return false;
}
// due to the changes in r2532 we must do this routine a bit different.
fileSize = PHYSFS_fileLength(fileHandle);
pBuffer = malloc(fileSize * sizeof(char));
if (pBuffer == NULL)
{
debug(LOG_FATAL, "Fatal memory allocation, couldn't allocate %lld buffer", fileSize);
abort();
}
PHYSFS_read(fileHandle, pBuffer, 1, fileSize);
calcDataHash(pBuffer, fileSize, DATA_SCRIPTVAL);
free(pBuffer);
PHYSFS_seek(fileHandle, 0); //reset position
success = scrvLoad(fileHandle);
if (!success)
debug(LOG_FATAL, "Script %s did not compile", GetLastResourceFilename());
PHYSFS_close(fileHandle);
return success;
}
开发者ID:blezek,项目名称:warzone2100,代码行数:51,代码来源:data.c
示例11: PHYSFS_getRealDir
std::string ResourceManager::getPath(const std::string &file)
{
// get the real path to the file
const char* tmp = PHYSFS_getRealDir(file.c_str());
std::string path;
// if the file is not in the search path, then its NULL
if (tmp)
path = std::string(tmp) + "/" + file;
// if not found in search path return the default path
else
path = std::string(PKG_DATADIR) + std::string("data") + "/" + file;
return path;
}
开发者ID:stevecotton,项目名称:Aethyra,代码行数:15,代码来源:resourcemanager.cpp
示例12: cdAudio_OpenTrack
static bool cdAudio_OpenTrack(const char *filename)
{
if (!music_initialized)
{
return false;
}
debug(LOG_SOUND, "called(%s)", filename);
cdAudio_Stop();
if (strncasecmp(filename + strlen(filename) - 4, ".ogg", 4) == 0)
{
PHYSFS_file *music_file = PHYSFS_openRead(filename);
debug(LOG_WZ, "Reading...[directory: %s] %s", PHYSFS_getRealDir(filename), filename);
if (music_file == nullptr)
{
debug(LOG_ERROR, "Failed opening file [directory: %s] %s, with error %s", PHYSFS_getRealDir(filename), filename, WZ_PHYSFS_getLastError());
return false;
}
cdStream = sound_PlayStreamWithBuf(music_file, music_volume, cdAudio_TrackFinished, filename, bufferSize, buffer_count);
if (cdStream == nullptr)
{
PHYSFS_close(music_file);
debug(LOG_ERROR, "Failed creating audio stream for %s", filename);
return false;
}
debug(LOG_SOUND, "successful(%s)", filename);
stopping = false;
return true;
}
return false; // unhandled
}
开发者ID:Warzone2100,项目名称:warzone2100,代码行数:36,代码来源:cdaudio.cpp
示例13: qDebug
void PageEditTeam::lazyLoad()
{
if(m_loaded) return;
m_loaded = true;
qDebug("[LAZINESS] PageEditTeam::lazyLoad()");
HatModel * hatsModel = DataManager::instance().hatModel();
for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++)
HHHats[i]->setModel(hatsModel);
QRegExp pngSuffix("\\.png$");
DataManager & dataMgr = DataManager::instance();
QStringList list;
// voicepacks
list = dataMgr.entryList("Sounds/voices",
QDir::AllDirs | QDir::NoDotAndDotDot);
CBVoicepack->addItems(list);
QIcon dlcIcon;
dlcIcon.addFile(":/res/dlcMarker.png", QSize(), QIcon::Normal, QIcon::On);
dlcIcon.addFile(":/res/dlcMarkerSelected.png", QSize(), QIcon::Selected, QIcon::On);
QPixmap emptySpace = QPixmap(7, 15);
emptySpace.fill(QColor(0, 0, 0, 0));
QIcon notDlcIcon = QIcon(emptySpace);
// forts
list = dataMgr.entryList("Forts", QDir::Files, QStringList("*L.png"));
foreach (QString file, list)
{
QString fortPath = PHYSFS_getRealDir(QString("Forts/%1").arg(file).toLocal8Bit().data());
QString fort = file.replace(QRegExp("L\\.png$"), "");
bool isDLC = !fortPath.startsWith(datadir->absolutePath());
if (isDLC)
{
CBFort->addItem(dlcIcon, fort, fort);
}
else
{
CBFort->addItem(notDlcIcon, fort, fort);
}
}
开发者ID:CaF2,项目名称:hw,代码行数:48,代码来源:pageeditteam.cpp
示例14: dataScriptLoadVals
// Load a script variable values file
static bool dataScriptLoadVals(const char *fileName, void **ppData)
{
bool success;
PHYSFS_file *fileHandle;
uint8_t *pBuffer;
PHYSFS_sint64 fileSize = 0;
*ppData = nullptr;
// don't load anything if a saved game is being loaded
if (saveFlag)
{
return true;
}
debug(LOG_WZ, "Loading script data %s", GetLastResourceFilename());
fileHandle = PHYSFS_openRead(fileName);
debug(LOG_WZ, "Reading...[directory: %s] %s", PHYSFS_getRealDir(fileName), fileName);
if (fileHandle == nullptr)
{
return false;
}
// due to the changes in r2532 we must do this routine a bit different.
fileSize = PHYSFS_fileLength(fileHandle);
pBuffer = (uint8_t *)malloc(fileSize * sizeof(uint8_t));
ASSERT_OR_RETURN(false, pBuffer, "Out of memory");
WZ_PHYSFS_readBytes(fileHandle, pBuffer, fileSize);
calcDataHash(pBuffer, fileSize, DATA_SCRIPTVAL);
free(pBuffer);
PHYSFS_seek(fileHandle, 0); //reset position
success = scrvLoad(fileHandle);
if (!success)
{
debug(LOG_FATAL, "Script %s did not compile", GetLastResourceFilename());
}
PHYSFS_close(fileHandle);
return success;
}
开发者ID:Warzone2100,项目名称:warzone2100,代码行数:49,代码来源:data.cpp
示例15: dataAnimLoad
/* Load an anim file */
static bool dataAnimLoad(const char *fileName, void **ppData)
{
PHYSFS_file* fileHandle = PHYSFS_openRead(fileName);
debug(LOG_WZ, "Reading...[directory: %s] %s", PHYSFS_getRealDir(fileName), fileName);
if (fileHandle == NULL)
{
*ppData = NULL;
return false;
}
*ppData = anim_LoadFromFile(fileHandle);
PHYSFS_close(fileHandle);
return *ppData != NULL;
}
开发者ID:Rimbok,项目名称:warzone2100,代码行数:17,代码来源:data.cpp
示例16: PHYSFS_getWriteDir
bool physfsFile::prepareWrite() {
const char *wdir = PHYSFS_getWriteDir();
if (wdir == NULL) {
LOG_MSG("PHYSFS could not fulfill write request: no write directory set.");
return false;
}
//LOG_MSG("Goto write (%s at %i)",pname,PHYSFS_tell(fhandle));
const char *fdir = PHYSFS_getRealDir(pname);
PHYSFS_uint64 pos = PHYSFS_tell(fhandle);
char *slash = strrchr(pname,'/');
if (slash && slash != pname) {
*slash = 0;
PHYSFS_mkdir(pname);
*slash = '/';
}
if (strcmp(fdir,wdir)) { /* we need COW */
//LOG_MSG("COW",pname,PHYSFS_tell(fhandle));
PHYSFS_file *whandle = PHYSFS_openWrite(pname);
if (whandle == NULL) {
LOG_MSG("PHYSFS copy-on-write failed: %s.",PHYSFS_getLastError());
return false;
}
char buffer[65536];
PHYSFS_sint64 size;
PHYSFS_seek(fhandle, 0);
while ((size = PHYSFS_read(fhandle,buffer,1,65536)) > 0) {
if (PHYSFS_write(whandle,buffer,1,(PHYSFS_uint32)size) != size) {
LOG_MSG("PHYSFS copy-on-write failed: %s.",PHYSFS_getLastError());
PHYSFS_close(whandle);
return false;
}
}
PHYSFS_seek(whandle, pos);
PHYSFS_close(fhandle);
fhandle = whandle;
} else { // megayuck - physfs on posix platforms uses O_APPEND. We illegally access the fd directly and clear that flag.
//LOG_MSG("noCOW",pname,PHYSFS_tell(fhandle));
PHYSFS_close(fhandle);
fhandle = PHYSFS_openAppend(pname);
#ifndef WIN32
fcntl(**(int**)fhandle->opaque,F_SETFL,0);
#endif
PHYSFS_seek(fhandle, pos);
}
return true;
}
开发者ID:Cliff-F,项目名称:Boxer,代码行数:46,代码来源:drive_physfs.cpp
示例17: beginResetModel
void ThemeModel::loadThemes()
{
beginResetModel();
DataManager & datamgr = DataManager::instance();
QStringList themes =
datamgr.entryList("Themes", QDir::AllDirs | QDir::NoDotAndDotDot);
m_data.clear();
#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
m_data.reserve(themes.size());
#endif
foreach (QString theme, themes)
{
// themes without icon are supposed to be hidden
QString iconpath = QString("physfs://Themes/%1/icon.png").arg(theme);
if (!QFile::exists(iconpath))
continue;
QMap<int, QVariant> dataset;
// detect if theme is dlc
QString themeDir = PHYSFS_getRealDir(QString("Themes/%1/icon.png").arg(theme).toLocal8Bit().data());
bool isDLC = !themeDir.startsWith(datadir->absolutePath());
dataset.insert(IsDlcRole, isDLC);
// set icon path
dataset.insert(IconPathRole, iconpath);
// set name
dataset.insert(ActualNameRole, theme);
// set displayed name
dataset.insert(Qt::DisplayRole, (isDLC ? "*" : "") + theme);
// load and set preview icon
QIcon preview(QString("physfs://Themes/%1/[email protected]").arg(theme));
dataset.insert(Qt::DecorationRole, preview);
m_data.append(dataset);
}
开发者ID:JGunning,项目名称:OpenWorms2,代码行数:45,代码来源:ThemeModel.cpp
示例18: cmd_getrealdir
static int cmd_getrealdir(char *args)
{
const char *rc;
if (*args == '\"')
{
args++;
args[strlen(args) - 1] = '\0';
} /* if */
rc = PHYSFS_getRealDir(args);
if (rc)
printf("Found at [%s].\n", rc);
else
printf("Not found.\n");
return(1);
} /* cmd_getrealdir */
开发者ID:Gokulakrishnansr,项目名称:cdogs-sdl,代码行数:18,代码来源:test_physfs.c
示例19: dataAnimCfgLoad
/* Load an audio config file */
static bool dataAnimCfgLoad(const char *fileName, void **ppData)
{
bool success;
PHYSFS_file* fileHandle = PHYSFS_openRead(fileName);
*ppData = NULL;
debug(LOG_WZ, "Reading...[directory: %s] %s", PHYSFS_getRealDir(fileName), fileName);
if (fileHandle == NULL)
{
return false;
}
success = ParseResourceFile(fileHandle);
PHYSFS_close(fileHandle);
return success;
}
开发者ID:Rimbok,项目名称:warzone2100,代码行数:19,代码来源:data.cpp
示例20: 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
注:本文中的PHYSFS_getRealDir函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论