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


C++ PHYSFS_getRealDir函数代码示例

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


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


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