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

C++ PHYSFS_openWrite函数代码示例

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

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



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

示例1: PHYSFS_openWrite

// Save a whole buffer to disk
//QUE: Optimize size!!!!!!!!!!!!!!!!!!!!!!!
unsigned int j1FileSystem::Save(const char* file, const char* buffer, unsigned int size) const
{
	unsigned int ret = 0;
	//PHYSFS_addToSearchPath(file, 1);
	//PHYSFS_setWriteDir("Dev_class3_handout/Game/data_files.xml");

	PHYSFS_file* fs_file = PHYSFS_openWrite(file);

	if(fs_file != NULL)
	{
		PHYSFS_file* debug2 = PHYSFS_openWrite("data_files.xml");
		PHYSFS_sint64 written = PHYSFS_write(fs_file, (const void*)buffer, 1, size);
		if(written != size)
			LOG("File System error while writing to file %s: %s\n", file, PHYSFS_getLastError());
		else
			ret = (uint) written;

		if(PHYSFS_close(fs_file) == 0)
			LOG("File System error while closing file %s: %s\n", file, PHYSFS_getLastError());
	}
	else
		LOG("File System error while opening file %s: %s\n", file, PHYSFS_getLastError());

	return ret;
}
开发者ID:DRed96,项目名称:GameDevelopment,代码行数:27,代码来源:j1FileSystem.cpp


示例2: PHYSFS_openRead

bool ResourceManager::copyFile(const std::string &src, const std::string &dst)
{
    PHYSFS_file *srcFile = PHYSFS_openRead(src.c_str());
    if (!srcFile)
    {
        logger->log("Read error: %s", PHYSFS_getLastError());
        return false;
    }
    PHYSFS_file *dstFile = PHYSFS_openWrite(dst.c_str());
    if (!dstFile)
    {
        logger->log("Write error: %s", PHYSFS_getLastError());
        PHYSFS_close(srcFile);
        return false;
    }

    int fileSize = PHYSFS_fileLength(srcFile);
    void *buf = malloc(fileSize);
    PHYSFS_read(srcFile, buf, 1, fileSize);
    PHYSFS_write(dstFile, buf, 1, fileSize);

    PHYSFS_close(srcFile);
    PHYSFS_close(dstFile);
    free(buf);
    return true;
}
开发者ID:Ablu,项目名称:invertika,代码行数:26,代码来源:resourcemanager.cpp


示例3: writeSurfaces

static void writeSurfaces( const char *filename, std::vector< RenderSurface > &surfaces )
{
	uint64_t hashedName = HashedString( 0, filename );
	char outfile[256];
	PHYSFS_mkdir( "static_models/" );
	sprintf( outfile, "static_models/%08x_%08x.sm", (uint32_t)(hashedName>>32), (uint32_t)(hashedName&0xffffffff) );
	PHYSFS_File *model = PHYSFS_openWrite( outfile );
	if ( model )
	{
		PHYSFS_writeULE32( model, 0x090 );
		PHYSFS_writeULE32( model, surfaces.size() );
		for ( uint32_t i=0; i<surfaces.size(); i++ )
		{
			RenderSurface const &surf = surfaces[i];
			PHYSFS_writeCStr( model, surf.name.c_str() );
			PHYSFS_writeCStr( model, surf.mat->Name() );
			const ModelGeometry *geom = surf.geom;
			PHYSFS_writeSLE32( model, geom->m_numIndices );
			PHYSFS_writeSLE32( model, geom->m_numVerts );
			PHYSFS_write( model, geom->m_indices, sizeof(uint16_t)*geom->m_numIndices, 1 );
			PHYSFS_write( model, geom->m_verts, sizeof(geom->m_verts[0])*geom->m_numVerts, 1 );
		}
		PHYSFS_close( model );
	}
}
开发者ID:mikearmstrong001,项目名称:script,代码行数:25,代码来源:model_static.cpp


示例4: PHYSFS_openRead

static void *file_phys_fopen(const char *filename, const char *mode)
{
   PHYSFS_file *phys;
   ALLEGRO_FILE_PHYSFS *fp;

   /* XXX handle '+' modes */
   /* It might be worth adding a function to parse mode strings, to be
    * shared amongst these kinds of addons.
    */
   if (streq(mode, "r") || streq(mode, "rb"))
      phys = PHYSFS_openRead(filename);
   else if (streq(mode, "w") || streq(mode, "wb"))
      phys = PHYSFS_openWrite(filename);
   else if (streq(mode, "a") || streq(mode, "ab"))
      phys = PHYSFS_openAppend(filename);
   else
      phys = NULL;

   if (!phys) {
      phys_set_errno(NULL);
      return NULL;
   }

   fp = al_malloc(sizeof(*fp));
   if (!fp) {
      al_set_errno(ENOMEM);
      PHYSFS_close(phys);
      return NULL;
   }

   fp->phys = phys;
   fp->error_indicator = false;

   return fp;
}
开发者ID:EricMayberryIV,项目名称:COP3330-Introduction-to-OOP,代码行数:35,代码来源:a5_physfs.c


示例5: fs_open

fs_file fs_open(const char *path, const char *mode)
{
    fs_file fh;

    assert((mode[0] == 'r' && !mode[1]) ||
           (mode[0] == 'w' && (!mode[1] || mode[1] == '+')));

    if ((fh = malloc(sizeof (*fh))))
    {
        switch (mode[0])
        {
        case 'r':
            fh->handle = PHYSFS_openRead(path);
            break;

        case 'w':
            fh->handle = (mode[1] == '+' ?
                          PHYSFS_openAppend(path) :
                          PHYSFS_openWrite(path));
            break;
        }

        if (fh->handle)
        {
            PHYSFS_setBuffer(fh->handle, 0x2000);
        }
        else
        {
            free(fh);
            fh = NULL;
        }
    }

    return fh;
}
开发者ID:L0rdK,项目名称:neverball-sdl2,代码行数:35,代码来源:fs_physfs.c


示例6: switch

Lux::Core::OpenedFile* Lux::Core::FileHandler::OpenFile(const String a_File, FileOpenMode a_OpenMode)
{
    OpenedFile* retFile = nullptr;
    switch (a_OpenMode)
    {
    case Lux::Core::FileHandler::FILE_OPEN_READ:
        retFile = PHYSFS_openRead(a_File.c_str());
        break;
    case Lux::Core::FileHandler::FILE_OPEN_WRITE:
        retFile = PHYSFS_openWrite(a_File.c_str());
        break;
    case Lux::Core::FileHandler::FILE_OPEN_APPEND:
        retFile = PHYSFS_openAppend(a_File.c_str());
        break;
    default:
        Utility::ThrowError("Unsupported file open mode.");
        break;
    }

    if (retFile == nullptr)
    {
        Utility::ThrowError("Could not open specified file: " + a_File + " . " + PHYSFS_getLastError());
    }

    return retFile;
}
开发者ID:lotsopa,项目名称:Lux,代码行数:26,代码来源:LuxFileHandler.cpp


示例7: NETstartLogging

bool NETstartLogging(void)
{
    time_t aclock;
    struct tm *newtime;
    char buf[256];
    static char filename[256] = {'\0'};
    int i;

    for (i = 0; i < NUM_GAME_PACKETS; i++)
    {
        packetcount[0][i] = 0;
        packetsize[0][i] = 0;
        packetcount[1][i] = 0;
        packetsize[1][i] = 0;
    }

    time( &aclock );                 /* Get time in seconds */
    newtime = localtime( &aclock );  /* Convert time to struct */

    snprintf(filename, sizeof(filename), "logs/netplay-%04d%02d%02d_%02d%02d%02d.log", newtime->tm_year + 1900, newtime->tm_mon + 1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec);
    pFileHandle = PHYSFS_openWrite( filename ); // open the file
    if (!pFileHandle)
    {
        debug(LOG_ERROR, "Could not create net log %s: %s", filename,
              PHYSFS_getLastError());
        return false;
    }
    snprintf(buf, sizeof(buf), "NETPLAY log: %s\n", asctime(newtime));
    PHYSFS_write( pFileHandle, buf, strlen( buf ), 1 );
    return true;
}
开发者ID:BG1,项目名称:warzone2100,代码行数:31,代码来源:netlog.cpp


示例8: PHYSFS_openWrite

FileStreamPtr ResourceManager::createFile(const std::string& fileName)
{
    PHYSFS_File* file = PHYSFS_openWrite(fileName.c_str());
    if(!file)
        stdext::throw_exception(stdext::format("failed to create file '%s': %s", fileName, PHYSFS_getLastError()));
    return FileStreamPtr(new FileStream(fileName, file, true));
}
开发者ID:LeandroPerrotta,项目名称:otclient,代码行数:7,代码来源:resourcemanager.cpp


示例9: assert

void File::open(const std::string& filename, OpenMode mode, bool no_override)
{
	// check that we don't have anything opened!
	/// \todo maybe we could just close the old file here... but
	///		  then, this could also lead to errors...
	assert(mHandle == 0);

	// open depending on mode
	if( mode == OPEN_WRITE )
	{
		if(no_override && FileSystem::getSingleton().exists(filename))
		{
			BOOST_THROW_EXCEPTION(FileAlreadyExistsException(filename));
		}

		mHandle = PHYSFS_openWrite(filename.c_str());
	}
	 else
	{
		mHandle = PHYSFS_openRead(filename.c_str());
	}

	if (!mHandle)
	{
		BOOST_THROW_EXCEPTION(FileLoadException(filename));
	}

	mFileName = filename;
}
开发者ID:EliasOenal,项目名称:blobby,代码行数:29,代码来源:File.cpp


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


示例11: int

void
Downloader::download(const std::string& url, const std::string& filename)
{
  log_info << "download: " << url << " to " << filename << std::endl;
  std::unique_ptr<PHYSFS_file, int(*)(PHYSFS_File*)> fout(PHYSFS_openWrite(filename.c_str()),
                                                          PHYSFS_close);
  download(url, my_curl_physfs_write, fout.get());
}
开发者ID:eegorov,项目名称:supertux,代码行数:8,代码来源:downloader.cpp


示例12: PHYSFS_openWrite

ResourceWO * Resources::RetrieveWrite(PString & filename) {
    PHYSFS_file* file = PHYSFS_openWrite(filename);
    if(!file) {
        PError << "couldn't open file '" << filename << "' for writing: " << PHYSFS_getLastError() << endl;
        return NULL;
    };
    return new ResourceWO(file);
}
开发者ID:ezh,项目名称:ENikiBENiki,代码行数:8,代码来源:Resources.cpp


示例13: openWrite

WriteFile* openWrite(const char* filename)
{
    PHYSFS_file* file = PHYSFS_openWrite(filename);
    if(!file)
        throw Exception("couldn't open file '%s' for writing: %s", filename,
                        PHYSFS_getLastError());

    return new WriteFile(file);
}
开发者ID:BackupTheBerlios,项目名称:netpanzer-svn,代码行数:9,代码来源:FileSystem.cpp


示例14: s_log_error

stream_t *file_open(const char *path, stream_mode_t mode, allocator_t *alloc)
{
  PHYSFS_File *file = NULL;
  stream_t *stream = NULL;
  char *pathcopy;
  size_t pathsize;

  if (!alloc)
    alloc = g_default_allocator;

  if (!path) {
    s_log_error("NULL path for file.");
    return NULL;
  }

  stream = stream_alloc(mode, alloc);

  if (stream) {
    switch (mode) {
      case STREAM_READ:
        file = PHYSFS_openRead(path);
      break;
      case STREAM_WRITE:
        file = PHYSFS_openWrite(path);
      break;
      case STREAM_APPEND:
        file = PHYSFS_openAppend(path);
      break;
      default: /* cannot reach */ break;
    }

    // if r+ failed because the file doesn't exist, open again with w
    if (file == NULL) {
      s_log_error("Failed to open file '%s' with mode %d. Error: %s.",
        path, mode, pfs_get_error());
      stream_close(stream);
      return NULL;
    }

    stream->read = file_read;
    stream->write = file_write;
    stream->seek = file_seek;
    stream->eof = file_eof;
    stream->close = file_close;

    // copy path string
    pathsize = strlen(path) + 1;
    pathcopy = com_malloc(alloc, pathsize);
    strncpy(pathcopy, path, pathsize);

    stream->context.pfs.file = file;
    stream->context.pfs.file_path = pathcopy;
  }

  return stream;
}
开发者ID:nilium,项目名称:snow-palm,代码行数:56,代码来源:file_stream.c


示例15: openWithMode

PHYSFS_File* openWithMode(char const * filename, mode openMode) {
	switch (openMode) {
	case WRITE:
		return PHYSFS_openWrite(filename);
	case APPEND:
		return PHYSFS_openAppend(filename);
	case READ:
		return PHYSFS_openRead(filename);
	}
}
开发者ID:dekimsey,项目名称:physfs-cpp,代码行数:10,代码来源:physfs.cpp


示例16: con_init

void con_init(void)
{
	cxx_con_init();
	memset(con_buffer,0,sizeof(con_buffer));

	if (GameArg.DbgSafelog)
		gamelog_fp = PHYSFS_openWrite("gamelog.txt");
	else
		gamelog_fp = PHYSFSX_openWriteBuffered("gamelog.txt");
	atexit(con_close);
}
开发者ID:Foran,项目名称:dxx-rebirth,代码行数:11,代码来源:console.cpp


示例17: PHYSFS_openWrite

boost::shared_ptr<File> Filesystem::openWrite(const std::string &filename)
{
    PHYSFS_File *file_handle = PHYSFS_openWrite(filename.c_str());

    if (!file_handle) {
        throw_error;
    }

    boost::shared_ptr<File> file_ptr(new File(file_handle));
    return file_ptr;
}
开发者ID:joequant,项目名称:raceintospace,代码行数:11,代码来源:filesystem.cpp


示例18: toStream

bool TiXmlDocument::PHYSFS_SaveFile( const char * filename ) const
{
	std::stringstream s;
	toStream(s, 0);
	PHYSFS_file* f = PHYSFS_openWrite(filename);
	PHYSFS_sint64 length_write = PHYSFS_write(f, s.str().c_str(), 1, (PHYSFS_uint32) s.str().length());
	PHYSFS_close(f);
	if (length_write != s.str().length())
		return false;
	return true;
}
开发者ID:GreyGhost,项目名称:OpenAnno-Archive,代码行数:11,代码来源:tinyxml.cpp


示例19: TouchFile

 void TouchFile(std::string path) {
     if (!IsLoaded()) {
         Logger::begin("Filesystem", Logger::LogLevel_Error) << "FS not loaded" << Logger::end();
         return;
     }
     if (!hasSetUserDir) {
         Logger::begin("Filesystem", Logger::LogLevel_Error) << "UserDir needs to be set to touchFiles" << Logger::end();
         return;
     }
     PHYSFS_File* f = PHYSFS_openWrite(path.c_str());
     PHYSFS_close(f);
 }
开发者ID:Vbitz,项目名称:Engine2D,代码行数:12,代码来源:Filesystem.cpp


示例20: PHYSFS_openWrite

OFileStreambuf::OFileStreambuf(const std::string& filename)
{
    file = PHYSFS_openWrite(filename.c_str());
    if(file == 0) {
        std::stringstream msg;
        msg << "Couldn't open file '" << filename << "': "
            << PHYSFS_getLastError();
        throw std::runtime_error(msg.str());
    }
    
    setp(buf, buf+sizeof(buf));
}
开发者ID:BackupTheBerlios,项目名称:lincity-ng-svn,代码行数:12,代码来源:PhysfsStream.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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