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

C++ PHYSFS_tell函数代码示例

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

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



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

示例1: switch

int
OggSoundFile::cb_seek(void* source, ogg_int64_t offset, int whence)
{
  PHYSFS_file* file = reinterpret_cast<PHYSFS_file*> (source);

  switch(whence) {
    case SEEK_SET:
      if(PHYSFS_seek(file, static_cast<PHYSFS_uint64> (offset)) == 0)
        return -1;
      break;
    case SEEK_CUR:
      if(PHYSFS_seek(file, PHYSFS_tell(file) + offset) == 0)
        return -1;
      break;
    case SEEK_END:
      if(PHYSFS_seek(file, PHYSFS_fileLength(file) + offset) == 0)
        return -1;
      break;
    default:
#ifdef DEBUG
      assert(false);
#else
      return -1;
#endif
  }
  return 0;
}
开发者ID:slackstone,项目名称:tuxjunior,代码行数:27,代码来源:sound_file.cpp


示例2: switch

int OSBasics::seek(OSFILE * stream, long int offset, int origin ) {
	switch(stream->fileType) {
		case OSFILE::TYPE_FILE:
			return fseek(stream->file, offset, origin);
			break;
		case OSFILE::TYPE_ARCHIVE_FILE:
			switch(origin) {
				case SEEK_SET:
					return PHYSFS_seek(stream->physFSFile, offset);
				break;
				case SEEK_CUR: {
					PHYSFS_sint64 curoffset = PHYSFS_tell(stream->physFSFile);					
					return PHYSFS_seek(stream->physFSFile, curoffset+offset);				
				}
				break;
				case SEEK_END: {
					PHYSFS_sint64 fileLength =  PHYSFS_fileLength(stream->physFSFile);
					return PHYSFS_seek(stream->physFSFile, fileLength-offset);
				}
				break;
			}
			break;			
	}
	return 0;	
}
开发者ID:mcclure,项目名称:old-Polycode,代码行数:25,代码来源:OSBasics.cpp


示例3: PHYSFS_tell

        bool FileReadObject::seek(long finalPos, bool relativeMovement)
        {
            if (relativeMovement)
                finalPos += PHYSFS_tell(mFileHandle);

            return PHYSFS_seek(mFileHandle, finalPos);
        }
开发者ID:DraconicEnt,项目名称:KGE,代码行数:7,代码来源:CFileReader.cpp


示例4: return

	int File::tell()
	{
		if(file == 0)
			return -1;

		return (int)PHYSFS_tell(file);
	}
开发者ID:icedman,项目名称:lov8,代码行数:7,代码来源:physFile.cpp


示例5: PHYSFS_tell

uint FileStream::tell()
{
    if(!m_caching)
        return PHYSFS_tell(m_fileHandle);
    else
        return m_pos;
}
开发者ID:HeberPcL,项目名称:otclient,代码行数:7,代码来源:filestream.cpp


示例6: PHYSFS_tell

size_t
WavSoundFile::read(void* buffer, size_t buffer_size)
{
  PHYSFS_sint64 end = datastart + size;
  PHYSFS_sint64 cur = PHYSFS_tell(file);
  if(cur >= end)
    return 0;

  size_t readsize = std::min(static_cast<size_t> (end - cur), buffer_size);
  if(PHYSFS_read(file, buffer, readsize, 1) != 1)
    throw SoundError("read error while reading samples");

#ifdef WORDS_BIGENDIAN
  if (bits_per_sample != 16)
    return readsize;
  char *tmp = (char*)buffer;

  size_t i;
  char c;
  for (i = 0; i < readsize / 2; i++)
  {
    c          = tmp[2*i];
    tmp[2*i]   = tmp[2*i+1];
    tmp[2*i+1] = c;
  }

  buffer = tmp;
#endif

  return readsize;
}
开发者ID:AndroidAppList,项目名称:Android-Supertux,代码行数:31,代码来源:wav_sound_file.cpp


示例7: PHYSFS_tell

bool physfsFile::prepareRead() {
	PHYSFS_uint64 pos = PHYSFS_tell(fhandle);
	PHYSFS_close(fhandle);
	fhandle = PHYSFS_openRead(pname);
	PHYSFS_seek(fhandle, pos);
	//LOG_MSG("Goto read (%s at %i)",pname,PHYSFS_tell(fhandle));
    return true;
}
开发者ID:Cliff-F,项目名称:Boxer,代码行数:8,代码来源:drive_physfs.cpp


示例8: PHYSFS_fixedEof

int PHYSFS_fixedEof(PHYSFS_File *handle) {
    if((PHYSFS_eof(handle)) ||
       (PHYSFS_fileLength(handle) == PHYSFS_tell(handle))) {
        return 1;
    }

    return 0;
}
开发者ID:Mojofreem,项目名称:flub,代码行数:8,代码来源:physfsutil.c


示例9: wz_oggVorbis_seek

static int wz_oggVorbis_seek(void *datasource, ogg_int64_t offset, int whence)
{
	PHYSFS_file* fileHandle;
	BOOL allowSeeking;
	int newPos;

	ASSERT(datasource != NULL, "NULL decoder passed!");

	fileHandle = ((struct OggVorbisDecoderState*)datasource)->fileHandle;
	ASSERT(fileHandle != NULL, "Bad PhysicsFS file handle passed in");

	allowSeeking = ((struct OggVorbisDecoderState*)datasource)->allowSeeking;

	if (!allowSeeking)
		return -1;

	switch (whence)
	{
		// Seek to absolute position
		case SEEK_SET:
			newPos = offset;
			break;

		// Seek `offset` ahead
		case SEEK_CUR:
		{
			int curPos = PHYSFS_tell(fileHandle);
			if (curPos == -1)
				return -1;

			newPos = curPos + offset;
			break;
		}

		// Seek backwards from the end of the file
		case SEEK_END:
		{
			int fileSize = PHYSFS_fileLength(fileHandle);
			if (fileSize == -1)
				return -1;

			newPos = fileSize - 1 - offset;
			break;
		}

		// unrecognized seek instruction
		default:
			// indicate failure
			return -1;
	}

	// PHYSFS_seek return value of non-zero means success
	if (PHYSFS_seek(fileHandle, newPos) != 0)
		return newPos;   // success
	else
		return -1;  // failure
}
开发者ID:cybersphinx,项目名称:wzgraphicsmods,代码行数:57,代码来源:oggvorbis.c


示例10: seekpos

	pos_type seekpos(pos_type pos, std::ios_base::openmode mode) {
		PHYSFS_seek(file, pos);
		if (mode & std::ios_base::in) {
			setg(egptr(), egptr(), egptr());
		}
		if (mode & std::ios_base::out) {
			setp(buffer, buffer);
		}
		return PHYSFS_tell(file);
	}
开发者ID:dekimsey,项目名称:physfs-cpp,代码行数:10,代码来源:physfs.cpp


示例11: check_file_open

uint32_t File::tell() const
{
	check_file_open();

	PHYSFS_sint64 tp = PHYSFS_tell( reinterpret_cast<PHYSFS_file*> (mHandle) );

	if(tp == -1)
		BOOST_THROW_EXCEPTION( PhysfsFileException(mFileName) );

	return tp;
}
开发者ID:EliasOenal,项目名称:blobby,代码行数:11,代码来源:File.cpp


示例12: switch

long OSBasics::tell(OSFILE * stream) {
	switch(stream->fileType) {
		case OSFILE::TYPE_FILE:
			return ftell(stream->file);
			break;
		case OSFILE::TYPE_ARCHIVE_FILE:
			return PHYSFS_tell(stream->physFSFile);
			break;			
	}
	return 0;
}
开发者ID:RobLach,项目名称:Polycode,代码行数:11,代码来源:OSBasics.cpp


示例13: wz_oggVorbis_tell

static long wz_oggVorbis_tell(void *datasource)
{
	PHYSFS_file* fileHandle;

	ASSERT(datasource != NULL, "NULL decoder passed!");

	fileHandle = ((struct OggVorbisDecoderState*)datasource)->fileHandle;
	ASSERT(fileHandle != NULL, "Bad PhysicsFS file handle passed in");

	return PHYSFS_tell(fileHandle);
}
开发者ID:cybersphinx,项目名称:wzgraphicsmods,代码行数:11,代码来源:oggvorbis.c


示例14: PHYSFS_tell

std::size_t File::CurrentPosition() const
{
   PHYSFS_sint64 position = PHYSFS_tell(impl->physfsFileHandle);

   if (position == -1)
   {
      throw Exception(std::string("Could not obtain current position of file ") + mountedFilePath.path + "\n" + PHYSFS_getLastError());
   }

   return LossyCast<std::size_t, PHYSFS_sint64>(position);
}
开发者ID:ShacharAvni,项目名称:Locus-Game-Engine,代码行数:11,代码来源:File.cpp


示例15: seekoff

	pos_type seekoff(off_type pos, ios_base::seekdir dir, ios_base::openmode mode) {
		switch (dir) {
		case std::ios_base::beg:
			PHYSFS_seek(file, pos);
			break;
		case std::ios_base::cur:
			// subtract characters currently in buffer from seek position
			PHYSFS_seek(file, (PHYSFS_tell(file) + pos) - (egptr() - gptr()));
			break;
		case std::ios_base::end:
			PHYSFS_seek(file, PHYSFS_fileLength(file) + pos);
			break;
		}
		if (mode & std::ios_base::in) {
			setg(egptr(), egptr(), egptr());
		}
		if (mode & std::ios_base::out) {
			setp(buffer, buffer);
		}
		return PHYSFS_tell(file);
	}
开发者ID:dekimsey,项目名称:physfs-cpp,代码行数:21,代码来源:physfs.cpp


示例16: switch

bool physfsFile::Seek(Bit32u * pos,Bit32u type) {
	PHYSFS_sint64 mypos = (Bit32s)*pos;
	switch (type) {
	case DOS_SEEK_SET:break;
	case DOS_SEEK_CUR:mypos += PHYSFS_tell(fhandle); break;
	case DOS_SEEK_END:mypos += PHYSFS_fileLength(fhandle); break;
	default:
	//TODO Give some doserrorcode;
		return false;//ERROR
	}

	if (!PHYSFS_seek(fhandle,mypos)) {
		// Out of file range, pretend everythings ok 
		// and move file pointer top end of file... ?! (Black Thorne)
		PHYSFS_seek(fhandle,PHYSFS_fileLength(fhandle));
	};
	//LOG_MSG("Seek to %i (%i at %x) of %s (%s)",(int)mypos,(int)*pos,type,name,PHYSFS_getLastError());

	*pos=(Bit32u)PHYSFS_tell(fhandle);
	return true;
}
开发者ID:Cliff-F,项目名称:Boxer,代码行数:21,代码来源:drive_physfs.cpp


示例17: file_phys_ftell

static int64_t file_phys_ftell(ALLEGRO_FILE *f)
{
   ALLEGRO_FILE_PHYSFS *fp = cast_stream(f);
   PHYSFS_sint64 n;

   n = PHYSFS_tell(fp->phys);
   if (n < 0) {
      phys_set_errno(fp);
      return -1;
   }

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


示例18: DOS_SetError

bool physfsFile::Write(Bit8u * data,Bit16u * size) {
	if ((this->flags & 0xf) == OPEN_READ) { // check if file opened in read-only mode
		DOS_SetError(DOSERR_ACCESS_DENIED);
		return false;
	}
	if (last_action==READ) prepareWrite();
	last_action=WRITE;
	if (*size==0) {
		if (PHYSFS_tell(fhandle) == 0) {
			PHYSFS_close(PHYSFS_openWrite(pname));
            return false;
			//LOG_MSG("Truncate %s (%s)",name,PHYSFS_getLastError());
		} else {
			LOG_MSG("PHYSFS TODO: truncate not yet implemented (%s at %lld)",pname,PHYSFS_tell(fhandle));
			return false;
		}
	} else {
		PHYSFS_sint64 mysize = PHYSFS_write(fhandle,data,1,(PHYSFS_uint32)*size);
		//LOG_MSG("Wrote %i bytes (wanted %i) at %i of %s (%s)",(int)mysize,(int)*size,(int)PHYSFS_tell(fhandle),name,PHYSFS_getLastError());
		*size = (Bit16u)mysize;
		return true;
	}
}
开发者ID:Cliff-F,项目名称:Boxer,代码行数:23,代码来源:drive_physfs.cpp


示例19: physfsrwops_seek

static Sint64 physfsrwops_seek(SDL_RWops *rw, Sint64 offset, int whence)
{
    PHYSFS_file *handle = (PHYSFS_file *) rw->hidden.unknown.data1;
    int pos = 0;

    if (whence == SEEK_SET)
    {
        pos = offset;
    }
    else if (whence == SEEK_CUR)
    {
        int current = PHYSFS_tell(handle);
        if (current == -1)
        {
            SDL_SetError("Can't find position in file: %s",
                          PHYSFS_getLastError());
            return(-1);
        }

        if (offset == 0)  // this is a "tell" call. We're done.
            return( current );

        pos = current + offset;
    }
    else if (whence == SEEK_END)
    {
        int len = PHYSFS_fileLength(handle);
        if (len == -1)
        {
            SDL_SetError("Can't find end of file: %s", PHYSFS_getLastError());
            return(-1);
        }

        pos = len + offset;
    }
    else
    {
        SDL_SetError("Invalid 'whence' parameter.");
        return(-1);
    }

    if (!PHYSFS_seek(handle, pos))
    {
        SDL_SetError("PhysicsFS error: %s", PHYSFS_getLastError());
        return(-1);
    }

    return(pos);
}
开发者ID:Mojofreem,项目名称:flub,代码行数:49,代码来源:physfsrwops.c


示例20: PHYSFS_tell

/**Gets the current offset from the beginning of the file.
 * \return Offset in bytes from the beginning of the file.*/
long File::Tell( void ){
	long offset;
	offset = static_cast<long>(
#ifdef USE_PHYSICSFS
		PHYSFS_tell( fp )
#else
		ftell(fp)
#endif
		);
	if ( offset == -1 ){
		LogMsg(ERR,"%s: Error using file tell. %s",
			validName.c_str(), PHYSFS_getLastError());
	}
	return offset;
}
开发者ID:Maka7879,项目名称:Epiar,代码行数:17,代码来源:file.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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