当前位置: 首页>>代码示例>>C++>>正文


C++ PHYSFS_exists函数代码示例

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


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

示例1: WzConfigHack

WzConfig::WzConfig(const QString &name, WzConfig::warning warning, QObject *parent)
	: WzConfigHack(name, (int)warning), m_settings(QString("wz::") + name, QSettings::IniFormat, parent), m_overrides()
{
	if (m_settings.status() != QSettings::NoError && (warning != ReadOnly || PHYSFS_exists(name.toUtf8().constData())))
	{
		debug(LOG_FATAL, "Could not open \"%s\"", name.toUtf8().constData());
	}
	char **diffList = PHYSFS_enumerateFiles("diffs");
	char **i;
	int j;
	for (i = diffList; *i != NULL; i++) 
	{
		std::string str(std::string("diffs/") + *i + std::string("/") + name.toUtf8().constData());
		if (!PHYSFS_exists(str.c_str())) 
			continue;
		QSettings tmp(QString("wz::") + str.c_str(), QSettings::IniFormat);
		if (tmp.status() != QSettings::NoError)
		{
			debug(LOG_FATAL, "Could not read an override for \"%s\"", name.toUtf8().constData());
		}
		QStringList keys(tmp.allKeys());
		for (j = 0; j < keys.length(); j++)
		{
			m_overrides.insert(keys[j],tmp.value(keys[j]));
		}
	}
	PHYSFS_freeList(diffList);
}
开发者ID:Cjkjvfnby,项目名称:warzone2100,代码行数:28,代码来源:wzconfig.cpp

示例2: debug

WzConfig::WzConfig(const QString &name, WzConfig::warning warning, QObject *parent)
{
	UDWORD size;
	char *data;
	QJsonParseError error;

	mFilename = name;
	mStatus = true;
	mWarning = warning;

	if (!PHYSFS_exists(name.toUtf8().constData()))
	{
		if (warning == ReadOnly)
		{
			mStatus = false;
			debug(LOG_ERROR, "IGNORED %s", name.toUtf8().constData());
			return;
		}
		else if (warning == ReadAndWrite)
		{
			mJson = QJsonDocument();
			mObj = mJson.object();
			debug(LOG_ERROR, "PREPARED %s", name.toUtf8().constData());
			return;
		}
	}
	if (!loadFile(name.toUtf8().constData(), &data, &size))
	{
		debug(LOG_FATAL, "Could not open \"%s\"", name.toUtf8().constData());
	}
	mJson = QJsonDocument::fromJson(QByteArray(data, size), &error);
	ASSERT(!mJson.isNull(), "JSON document from %s is invalid: %s", name.toUtf8().constData(), error.errorString().toUtf8().constData());
	ASSERT(mJson.isObject(), "JSON document from %s is not an object. Read: \n%s", name.toUtf8().constData(), data);
	mObj = mJson.object();
#if 0
	char **diffList = PHYSFS_enumerateFiles("diffs");
	char **i;
	int j;
	for (i = diffList; *i != NULL; i++) 
	{
		std::string str(std::string("diffs/") + *i + std::string("/") + name.toUtf8().constData());
		if (!PHYSFS_exists(str.c_str())) 
			continue;
		QSettings tmp(QString("wz::") + str.c_str(), QSettings::IniFormat);
		if (tmp.status() != QSettings::NoError)
		{
			debug(LOG_FATAL, "Could not read an override for \"%s\"", name.toUtf8().constData());
		}
		QStringList keys(tmp.allKeys());
		for (j = 0; j < keys.length(); j++)
		{
			m_overrides.insert(keys[j],tmp.value(keys[j]));
		}
	}
	PHYSFS_freeList(diffList);
#endif
}
开发者ID:henryfung01,项目名称:warzone2100,代码行数:57,代码来源:wzconfig.cpp

示例3: PHYSFSX_exists

int PHYSFSX_exists(const char *filename, int ignorecase)
{
	char filename2[PATH_MAX];

	if (!ignorecase)
		return PHYSFS_exists(filename);

	snprintf(filename2, sizeof(filename2), "%s", filename);
	PHYSFSEXT_locateCorrectCase(filename2);

	return PHYSFS_exists(filename2);
}
开发者ID:Pickle,项目名称:dxx-rebirth,代码行数:12,代码来源:physfsx.cpp

示例4: impl

File::File(const MountedFilePath& mountedFilePath, DataStream::OpenMode openMode)
   : impl(std::make_unique<File_Impl>()), mountedFilePath(mountedFilePath)
{
   const char* path = mountedFilePath.path.c_str();

   int fileExists = PHYSFS_exists(path);

   if (fileExists == 0)
   {
      throw Exception(std::string("File ") + path + " does not exist in the search path");
   }

   switch (openMode)
   {
   case OpenMode::Read:
      impl->physfsFileHandle = PHYSFS_openRead(path);
      break;

   case OpenMode::Write:
      impl->physfsFileHandle = PHYSFS_openWrite(path);
      break;

   case OpenMode::Append:
      impl->physfsFileHandle = PHYSFS_openAppend(path);
      break;
   }

   if (impl->physfsFileHandle == nullptr)
   {
      throw Exception(std::string("Failed to open file ") + path + "\n" + PHYSFS_getLastError());
   }
}
开发者ID:ShacharAvni,项目名称:Locus-Game-Engine,代码行数:32,代码来源:File.cpp

示例5:

bool j1Physfs::OpenFile(const char* file)
{
	if (0 == PHYSFS_exists(file))
	{
		return false; //file doesn't exist
	}

	PHYSFS_file* myfile = PHYSFS_openRead(file);

	// Get the lenght of the file
	file_lenght = PHYSFS_fileLength(myfile);

	// Get the file data.
	file_data = new Uint32[file_lenght];

	int length_read = PHYSFS_read(myfile, file_data, 1, file_lenght);

	if (length_read != (int)file_lenght)
	{
		delete[] file_data;
		file_data = 0;
		return false;
	}

	PHYSFS_close(myfile);


	return true;
}
开发者ID:kellazo,项目名称:GameDevelopment,代码行数:29,代码来源:j1Physfs.cpp

示例6: loadLevFile

static bool loadLevFile(const char* filename, searchPathMode datadir, bool ignoreWrf, char const *realFileName)
{
	char *pBuffer;
	UDWORD size;

	if (realFileName == NULL)
	{
		debug(LOG_WZ, "Loading lev file: \"%s\", builtin\n", filename);
	}
	else
	{
		debug(LOG_WZ, "Loading lev file: \"%s\" from \"%s\"\n", filename, realFileName);
	}

	if (!PHYSFS_exists(filename) || !loadFile(filename, &pBuffer, &size))
	{
		debug(LOG_ERROR, "loadLevFile: File not found: %s\n", filename);
		return false; // only in NDEBUG case
	}
	if (!levParse(pBuffer, size, datadir, ignoreWrf, realFileName))
	{
		debug(LOG_ERROR, "loadLevFile: Parse error in %s\n", filename);
		return false;
	}
	free(pBuffer);

	return true;
}
开发者ID:kerbys,项目名称:warzone2100,代码行数:28,代码来源:init.cpp

示例7: FileReadException

//==================================================
//! Load a file from the VFS into memory, can throw a FileIOException
//==================================================
void System::VFS::LoadRaw( const string& strFilename, vector<byte>& data ) {
	// Check to see if it exists
	if( !PHYSFS_exists(strFilename.c_str()) ) {
		THROW_EXCEPTION( FileReadException() << FileIOExceptionFilename(strFilename) );
	}
	
	// Open the file
	shared_ptr<PHYSFS_file> pFile( PHYSFS_openRead(strFilename.c_str()), PHYSFS_close );
	if( pFile.get() == NULL ) {
		THROW_EXCEPTION( FileReadException() << FileIOExceptionFilename(strFilename) );
	}

	// Try to read the number of bytes, fail if we can't
	PHYSFS_sint64 nBytes= PHYSFS_fileLength( pFile.get() );
	if( nBytes < 0 ) {
		THROW_EXCEPTION( FileReadException() << FileIOExceptionFilename(strFilename) );
	}
	data.resize( unsigned(nBytes) );

	// Try to read the data
	PHYSFS_sint64 nBytesRead= PHYSFS_read( pFile.get(), &data[0], sizeof(byte), data.size() );
	// Check for unexpected length
	if( nBytesRead != nBytes ) {
		data.resize( unsigned(nBytesRead) );
		THROW_EXCEPTION( FileReadException() << FileIOExceptionFilename(strFilename) );
	}
}
开发者ID:schnarf,项目名称:Phaedrus-FPS,代码行数:30,代码来源:VFS.cpp

示例8: fileExists

bool ResourceManager::exists(const std::string &path, bool lookInSearchPath)
{
    if (!lookInSearchPath)
        return fileExists(path);

    return PHYSFS_exists(path.c_str());
}
开发者ID:Ablu,项目名称:manaserv,代码行数:7,代码来源:resourcemanager.cpp

示例9: sprite

Block::Block(const ReaderMapping& lisp, const std::string& sprite_file) :
  sprite(),
  sprite_name(),
  default_sprite_name(),
  bouncing(false),
  breaking(false),
  bounce_dir(0),
  bounce_offset(0),
  original_y(-1)
{
  lisp.get("x", bbox.p1.x);
  lisp.get("y", bbox.p1.y);

  std::string sf;
  lisp.get("sprite", sf);
  if (sf.empty() || !PHYSFS_exists(sf.c_str())) {
    sf = sprite_file;
  }
  sprite = SpriteManager::current()->create(sf);
  sprite_name = sf;
  default_sprite_name = sprite_name;

  bbox.set_size(32, 32.1f);
  set_group(COLGROUP_STATIC);
  SoundManager::current()->preload("sounds/upgrade.wav");
  SoundManager::current()->preload("sounds/brick.wav");
}
开发者ID:christ2go,项目名称:supertux,代码行数:27,代码来源:block.cpp

示例10: FS_loadFile

int FS_loadFile(lua_State *L, const char *filename) {
	char *buffer;		/* buffer for the file */
	char *entryPoint;	/* entry point of file (differs from buffer, if "#!" in the first line is skipped */
	int err;
	PHYSFS_file *Hndfile = NULL;
	PHYSFS_sint64 fileLength, size;

	if (PHYSFS_exists(filename) == 0) {
		lua_pushfstring(L, "Error loading '%s': file not found.", filename);
		return FILEIO_ERROR;
	}

	Hndfile = PHYSFS_openRead(filename); /* open file to read! */
	if (Hndfile == NULL) {
		lua_pushfstring(L, "Error while reading from '%s': %s", filename, PHYSFS_getLastError());
		return FILEIO_ERROR;
	}

	size = PHYSFS_fileLength(Hndfile);
	if (size == -1) {
		lua_pushfstring(L, "Error while determining the size of %s.", filename);
		return FILEIO_ERROR;
	}

	buffer = (char *)malloc((unsigned int)size);
	if (buffer == NULL) {
		lua_pushfstring(L, "Error loading %s: Insufficient memory available.", filename);
		return FILEIO_ERROR;
	}

	fileLength = PHYSFS_read(Hndfile, buffer, 1, (unsigned int)size);
	if (fileLength < size) {
		free(buffer);
		lua_pushfstring(L, "Error while reading from %s: %s", filename, PHYSFS_getLastError());
		return FILEIO_ERROR;
	}
	/* close the file */
	err = PHYSFS_close(Hndfile);
	if (err == 0) {
		free(buffer);
		lua_pushfstring(L, "Error closing %s: %s", filename, PHYSFS_getLastError());
		return FILEIO_ERROR;
	}
	/* skip #! if nescessary */
	entryPoint = buffer;
	if (buffer[0] == '#') {
		while ((*entryPoint != 0x0D) && (*entryPoint != 0x0A) && (*entryPoint != EOF)) {
			entryPoint++;
			fileLength--;
		}
	}
	err = luaL_loadbuffer(L, entryPoint, (size_t)fileLength, filename);
	free(buffer);
	if (err != 0) {
		/* error message is on the stack */
		return FILEIO_ERROR;
	}

	return FILEIO_SUCCESS;
}
开发者ID:scriptum,项目名称:Engine,代码行数:60,代码来源:FileIO.c

示例11: gSetError

gSurface *gLoadImage(const char *name)
{
   gSurface    *ret;
   SDL_RWops   *ops;

   if(!PHYSFS_exists(name))
   {
      gSetError("gLoadImage was unable to load the image %s", name);
      return NULL;
   }

   ops = PHYSFSRWOPS_openRead(name);
   if(!ops)
   {
      gSetError("gLoadImage was unable to load the image %s: failed _openRead", name);
      return NULL;
   }

   if(!(ret = IMG_Load_RW(ops, true)))
   {
      gSetError("gLoadImage was unable to load the image %s: %s", name, SDL_GetError());
      return NULL;
   }

   return ret;
}
开发者ID:gitustc,项目名称:d2imdev,代码行数:26,代码来源:gmainframe.c

示例12: SetWindowIcon

void SetWindowIcon(photon_window &window, const std::string &filename){
    if(PHYSFS_exists(filename.c_str())){
        auto fp = PHYSFS_openRead(filename.c_str());
        intmax_t length = PHYSFS_fileLength(fp);
        if(length > 0){
            uint8_t *buffer = new uint8_t[length];

            PHYSFS_read(fp, buffer, 1, length);

            PHYSFS_close(fp);

            SDL_RWops *rw = SDL_RWFromMem(buffer, length);
            SDL_Surface *icon = IMG_Load_RW(rw, 1);

            if(icon == nullptr){
                PrintToLog("ERROR: icon loading failed! %s", IMG_GetError());
            }

            SDL_SetWindowIcon(window.window_SDL, icon);

            SDL_FreeSurface(icon);
            delete[] buffer;
        }else{
            PrintToLog("ERROR: Unable to open image file \"%s\"!");
        }
    }else{
        PrintToLog("ERROR: Image file \"%s\" does not exist!", filename.c_str());
    }
}
开发者ID:chipgw,项目名称:photon-legacy,代码行数:29,代码来源:window_managment.cpp

示例13: strcpy

bool physfsDrive::FileOpen(DOS_File * * file,const char * name,Bit32u flags) {
	char newname[CROSS_LEN];
	strcpy(newname,basedir);
	strcat(newname,name);
	CROSS_FILENAME(newname);
	dirCache.ExpandName(newname);
	normalize(newname,basedir);

	PHYSFS_file * hand;
	
	if (!PHYSFS_exists(newname)) return false;
	if ((flags&0xf) == OPEN_READ) {
		hand = PHYSFS_openRead(newname);
	} else {

		/* open for reading, deal with writing later */
		hand = PHYSFS_openRead(newname);
	}

	if (!hand) { 
		if((flags&0xf) != OPEN_READ) {
			PHYSFS_file *hmm = PHYSFS_openRead(newname);
			if (hmm) {
				PHYSFS_close(hmm);
				LOG_MSG("Warning: file %s exists and failed to open in write mode.\nPlease mount a write directory (see docs).",newname);
			}
		}
		return false;
	}
   
	*file=new physfsFile(name,hand,0x202,newname,false);
	(*file)->flags=flags;  //for the inheritance flag and maybe check for others.
	return true;
}
开发者ID:Cliff-F,项目名称:Boxer,代码行数:34,代码来源:drive_physfs.cpp

示例14: ZipInputStream

Sp<AIOStream> ZipFileSystem::open(const String& uri, AIOStream::Mode mode){
	if(!PHYSFS_exists(uri.c_str())){
		LOGW("File \"%s\" does not exist in zip archive", uri.c_str());
	}

	return new ZipInputStream(PHYSFS_openRead(uri.c_str()));
}
开发者ID:spiricn,项目名称:Wt,代码行数:7,代码来源:ZipFileSystem.cpp

示例15: loadMultiStats

// ////////////////////////////////////////////////////////////////////////////
// Load Player Stats
bool loadMultiStats(char *sPlayerName, PLAYERSTATS *st)
{
	char				fileName[255];
	UDWORD				size;
	char				*pFileData;

	memset(st, 0, sizeof(PLAYERSTATS));	// clear in case we don't get to load

	// Prevent an empty player name (where the first byte is a 0x0 terminating char already)
	if (!*sPlayerName)
	{
		strcpy(sPlayerName, _("Player"));
	}

	snprintf(fileName, sizeof(fileName), "%s%s.sta", MultiPlayersPath, sPlayerName);

	debug(LOG_WZ, "loadMultiStats: %s", fileName);

	// check player already exists
	if ( !PHYSFS_exists( fileName ) )
	{
		PLAYERSTATS			blankstats;

		memset(&blankstats, 0, sizeof(PLAYERSTATS));
		saveMultiStats(sPlayerName,sPlayerName,&blankstats);		// didnt exist so create.
	}
	else
	{
		int num = 0;

		loadFile(fileName,&pFileData,&size);

		if (strncmp(pFileData, "WZ.STA.v3", 9) != 0)
		{
			return false; // wrong version or not a stats file
		}

		num = sscanf(pFileData, "WZ.STA.v3\n%u %u %u %u %u",
		             &st->wins, &st->losses, &st->totalKills, &st->totalScore, &st->played);
		if (num < 5)
		{
			st->played = 0;	// must be old, buggy format still
		}
		free(pFileData);
	}

	// reset recent scores
	st->recentKills = 0;
	st->recentScore = 0;

	// clear any skirmish stats.
	for(size = 0;size<MAX_PLAYERS;size++)
	{
		ingame.skScores[size][0] =0;
		ingame.skScores[size][1] =0;
	}

	return true;
}
开发者ID:mvancompernolle,项目名称:ai_project,代码行数:61,代码来源:multistat.cpp


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