本文整理汇总了C++中PHYSFS_getWriteDir函数的典型用法代码示例。如果您正苦于以下问题:C++ PHYSFS_getWriteDir函数的具体用法?C++ PHYSFS_getWriteDir怎么用?C++ PHYSFS_getWriteDir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PHYSFS_getWriteDir函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PHYSFS_getSearchPath
const char *physfsDrive::GetInfo() {
char **files = PHYSFS_getSearchPath(), **list = files;
sprintf(info,"PHYSFS directory %s in ",basedir);
while (*files != NULL) {
strcat(info,*files++);
strcat(info,", ");
}
if (PHYSFS_getWriteDir() != NULL) {
strcat(info,"writing to ");
strcat(info,PHYSFS_getWriteDir());
} else {
strcat(info,"read-only");
}
PHYSFS_freeList(list);
return info;
}
示例2: make_dir
/***************************************************************************
Make a directory in write path and set a variable to point to it.
***************************************************************************/
static void make_dir(char *dest, const char *dirname, const char *subdir)
{
strcpy(dest, dirname);
if (subdir != NULL)
{
strcat(dest, "/");
strcat(dest, subdir);
}
{
size_t l = strlen(dest);
if (dest[l - 1] != '/')
{
dest[l] = '/';
dest[l + 1] = '\0';
}
}
PHYSFS_mkdir(dest);
if (!PHYSFS_mkdir(dest))
{
debug(LOG_FATAL, "Unable to create directory \"%s\" in write dir \"%s\"!",
dest, PHYSFS_getWriteDir());
exit(EXIT_FAILURE);
}
}
示例3: wzPerfShutdown
void wzPerfShutdown()
{
if (perfList.size() == 0)
{
return;
}
QString ourfile = PHYSFS_getWriteDir();
ourfile.append("gfx-performance.csv");
// write performance counter list to file
QFile perf(ourfile);
perf.open(QIODevice::WriteOnly);
perf.write("START, EFF, TERRAIN, LOAD, PRTCL, WATER, MODELS, MISC\n");
for (int i = 0; i < perfList.size(); i++)
{
QString line;
line += QString::number(perfList[i].counters[PERF_START_FRAME]);
for (int j = 1; j < PERF_COUNT; j++)
{
line += ", " + QString::number(perfList[i].counters[j]);
}
line += "\n";
perf.write(line.toUtf8());
}
// all done, clear data
perfStarted = false;
perfList.clear();
queryActive = PERF_COUNT;
}
示例4: PHYSFS_getWriteDir
std::string CResourceManager::GetSaveLocation()
{
if (PHYSFS_isInit())
{
return PHYSFS_getWriteDir();
}
return "";
}
示例5: strcpy
physfsDrive::physfsDrive(const char * startdir,Bit16u _bytes_sector,Bit8u _sectors_cluster,Bit16u _total_clusters,Bit16u _free_clusters,Bit8u _mediaid)
:localDrive(startdir,_bytes_sector,_sectors_cluster,_total_clusters,_free_clusters,_mediaid) {
char newname[CROSS_LEN+1];
/* No writedir given, use capture directory */
if(startdir[0] == ':') {
strcpy(newname,capturedir.c_str());
strcat(newname,startdir);
} else {
strcpy(newname,startdir);
}
CROSS_FILENAME(newname);
if (!physfs_used) {
PHYSFS_init("");
PHYSFS_permitSymbolicLinks(1);
}
physfs_used++;
char *lastdir = newname;
char *dir = strchr(lastdir+(((lastdir[0]|0x20) >= 'a' && (lastdir[0]|0x20) <= 'z')?2:0),':');
while (dir) {
*dir++ = 0;
if((lastdir == newname) && !strchr(dir+(((dir[0]|0x20) >= 'a' && (dir[0]|0x20) <= 'z')?2:0),':')) {
// If the first parameter is a directory, the next one has to be the archive file,
// do not confuse it with basedir if trailing : is not there!
int tmp = strlen(dir)-1;
dir[tmp++] = ':';
dir[tmp++] = CROSS_FILESPLIT;
dir[tmp] = '\0';
}
if (*lastdir && PHYSFS_addToSearchPath(lastdir,true) == 0) {
LOG_MSG("PHYSFS couldn't add '%s': %s",lastdir,PHYSFS_getLastError());
}
lastdir = dir;
dir = strchr(lastdir+(((lastdir[0]|0x20) >= 'a' && (lastdir[0]|0x20) <= 'z')?2:0),':');
}
const char *oldwrite = PHYSFS_getWriteDir();
if (oldwrite) oldwrite = strdup(oldwrite);
if (!PHYSFS_setWriteDir(newname)) {
if (!oldwrite)
LOG_MSG("PHYSFS can't use '%s' for writing, you might encounter problems",newname);
else
PHYSFS_setWriteDir(oldwrite);
}
if (oldwrite) free((char *)oldwrite);
strcpy(basedir,lastdir);
allocation.bytes_sector=_bytes_sector;
allocation.sectors_cluster=_sectors_cluster;
allocation.total_clusters=_total_clusters;
allocation.free_clusters=_free_clusters;
allocation.mediaid=_mediaid;
dirCache.SetBaseDir(basedir, this);
}
示例6: getSaveDirList
std::vector<std::string> getSaveDirList()
{
auto writeDir = PHYSFS_getWriteDir();
if (writeDir != nullptr)
{
return geDirList("", writeDir);
}
return {};
}
示例7: getSaveDir
std::string getSaveDir()
{
std::string saveDir = PHYSFS_getWriteDir();
if (Utils::endsWith(saveDir, "\\") == false &&
Utils::endsWith(saveDir, "/") == false)
{
saveDir += PHYSFS_getDirSeparator();
}
return saveDir;
}
示例8: 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;
}
示例9: 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;
}
示例10: probeDir
void probeDir(const std::string& dirname)
{
if (PHYSFS_isDirectory(dirname.c_str()) == 0)
{
if (PHYSFS_exists(dirname.c_str()))
{
PHYSFS_delete(dirname.c_str());
}
if (PHYSFS_mkdir(dirname.c_str()))
{
std::cout << PHYSFS_getWriteDir() <<
dirname << " created" << std::endl;
}
else
{
std::cout << "Warning: Creation of" <<
PHYSFS_getWriteDir() << dirname <<
" failed!" << std::endl;
}
}
}
示例11: print_search_path
void print_search_path()
{
const char* writedir = PHYSFS_getWriteDir();
log_info << "PhysfsWritedDir: " << (writedir ? writedir : "(null)") << std::endl;
log_info << "PhysfsSearchPath:" << std::endl;
char** searchpath = PHYSFS_getSearchPath();
for(char** i = searchpath; *i != NULL; ++i)
{
log_info << " " << *i << std::endl;
}
PHYSFS_freeList(searchpath);
}
示例12: 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;
}
示例13: PHYSFSX_getFreeDiskSpace
// returns -1 if error
// Gets bytes free in current write dir
PHYSFS_sint64 PHYSFSX_getFreeDiskSpace()
{
#if defined(__linux__) || (defined(__MACH__) && defined(__APPLE__))
struct statfs sfs;
if (!statfs(PHYSFS_getWriteDir(), &sfs))
return (PHYSFS_sint64)(sfs.f_bavail * sfs.f_bsize);
return -1;
#else
return 0x7FFFFFFF;
#endif
}
示例14: 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;
}
示例15: QSettings
std::map<std::string, EcKey::Key> const &getKnownPlayers()
{
if (knownPlayersIni == nullptr)
{
knownPlayersIni = new QSettings(PHYSFS_getWriteDir() + QString("/") + "knownPlayers.ini", QSettings::IniFormat);
QStringList names = knownPlayersIni->allKeys();
for (int i = 0; i < names.size(); ++i)
{
knownPlayers[names[i].toUtf8().constData()] = base64Decode(knownPlayersIni->value(names[i]).toString().toStdString());
}
}
return knownPlayers;
}