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

C++ PHYSFS_getWriteDir函数代码示例

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

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



在下文中一共展示了PHYSFS_getWriteDir函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:Cliff-F,项目名称:Boxer,代码行数:16,代码来源:drive_physfs.cpp


示例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);
	}
}
开发者ID:C1annad,项目名称:warzone2100,代码行数:28,代码来源:main.cpp


示例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;
}
开发者ID:TomCN7,项目名称:warzone2100,代码行数:28,代码来源:screen.cpp


示例4: PHYSFS_getWriteDir

std::string CResourceManager::GetSaveLocation()
{
    if (PHYSFS_isInit())
    {
        return PHYSFS_getWriteDir();
    }
    return "";
}
开发者ID:2asoft,项目名称:colobot,代码行数:8,代码来源:resourcemanager.cpp


示例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);
}
开发者ID:Cliff-F,项目名称:Boxer,代码行数:58,代码来源:drive_physfs.cpp


示例6: getSaveDirList

	std::vector<std::string> getSaveDirList()
	{
		auto writeDir = PHYSFS_getWriteDir();
		if (writeDir != nullptr)
		{
			return geDirList("", writeDir);
		}
		return {};
	}
开发者ID:dgengin,项目名称:DGEngine,代码行数:9,代码来源:FileUtils.cpp


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


示例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;
}
开发者ID:ezh,项目名称:ENikiBENiki,代码行数:11,代码来源:Resources.cpp


示例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;
}
开发者ID:BackupTheBerlios,项目名称:netpanzer-svn,代码行数:11,代码来源:FileSystem.cpp


示例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;
        }
    }
}
开发者ID:angelonuffer,项目名称:blobby-volley-2,代码行数:21,代码来源:main.cpp


示例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);
 }
开发者ID:iOSAppList,项目名称:supertux,代码行数:12,代码来源:main.cpp


示例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;
	}
开发者ID:dgengin,项目名称:DGEngine,代码行数:53,代码来源:FileUtils.cpp


示例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
}
开发者ID:Pickle,项目名称:dxx-rebirth,代码行数:15,代码来源:physfsx.cpp


示例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;
	}
开发者ID:dgengin,项目名称:DGEngine,代码行数:13,代码来源:FileUtils.cpp


示例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;
}
开发者ID:Warzone2100,项目名称:warzone2100,代码行数:13,代码来源:multistat.cpp


示例16: deleteFile

void FileSystem::probeDir(const std::string& dirname)
{
	if ( !isDirectory(dirname) )
	{
		if (exists(dirname))
		{
			/// \todo simple delete such files without a warning???
			deleteFile(dirname);
		}
		
		if (mkdir(dirname))
		{
			std::cout << PHYSFS_getWriteDir() <<
				dirname << " created" << std::endl;
		}
		 else
		{
			std::cout << "Warning: Creation of" << 
				PHYSFS_getWriteDir() << dirname <<
				" failed!" << std::endl;
		}
	}
}
开发者ID:EliasOenal,项目名称:blobby,代码行数:23,代码来源:FileSystem.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: 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


示例19: open

bool File::open(Mode mode)
{
	if (mode == CLOSED)
		return true;

	// File must exist if read mode.
	if ((mode == READ) && !PHYSFS_exists(filename.c_str()))
		throw love::Exception("Could not open file %s. Does not exist.", filename.c_str());

	// Check whether the write directory is set.
	if ((mode == APPEND || mode == WRITE) && (PHYSFS_getWriteDir() == 0) && !hack_setupWriteDirectory())
		throw love::Exception("Could not set write directory.");

	// File already open?
	if (file != 0)
		return false;

	this->mode = mode;

	switch (mode)
	{
	case READ:
		file = PHYSFS_openRead(filename.c_str());
		break;
	case APPEND:
		file = PHYSFS_openAppend(filename.c_str());
		break;
	case WRITE:
		file = PHYSFS_openWrite(filename.c_str());
		break;
	default:
		break;
	}

	if (file != 0 && !setBuffer(bufferMode, bufferSize))
	{
		// Revert to buffer defaults if we don't successfully set the buffer.
		bufferMode = BUFFER_NONE;
		bufferSize = 0;
	}

	return (file != 0);
}
开发者ID:Ghor,项目名称:LoveEngineCore,代码行数:43,代码来源:File.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_getWriteDir函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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