本文整理汇总了C++中PHYSFS_tell函数的典型用法代码示例。如果您正苦于以下问题:C++ PHYSFS_tell函数的具体用法?C++ PHYSFS_tell怎么用?C++ PHYSFS_tell使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PHYSFS_tell函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例3: PHYSFS_tell
bool FileReadObject::seek(long finalPos, bool relativeMovement)
{
if (relativeMovement)
finalPos += PHYSFS_tell(mFileHandle);
return PHYSFS_seek(mFileHandle, finalPos);
}
示例4: return
int File::tell()
{
if(file == 0)
return -1;
return (int)PHYSFS_tell(file);
}
示例5: PHYSFS_tell
uint FileStream::tell()
{
if(!m_caching)
return PHYSFS_tell(m_fileHandle);
else
return m_pos;
}
示例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;
}
示例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;
}
示例8: PHYSFS_fixedEof
int PHYSFS_fixedEof(PHYSFS_File *handle) {
if((PHYSFS_eof(handle)) ||
(PHYSFS_fileLength(handle) == PHYSFS_tell(handle))) {
return 1;
}
return 0;
}
示例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
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}