本文整理汇总了C++中FileStream::seek方法的典型用法代码示例。如果您正苦于以下问题:C++ FileStream::seek方法的具体用法?C++ FileStream::seek怎么用?C++ FileStream::seek使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileStream
的用法示例。
在下文中一共展示了FileStream::seek方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cb_seek
int OggSoundFile::cb_seek(void* source, ogg_int64_t offset, int whence)
{
FileStream *file = static_cast<FileStream*>(source);
switch(whence) {
case SEEK_SET:
file->seek(offset);
return 0;
case SEEK_CUR:
file->seek(file->tell() + offset);
return 0;
case SEEK_END:
file->seek(file->size() + offset);
return 0;
}
return -1;
}
示例2: ReadRawData
void* FileUtil::ReadRawData(const String& filepath, size_t &size)
{
FileStream file;
if(!file.open(filepath))
return 0;
size = file.size();
file.seek(0,Seek_begin);
binary data = reinterpret_cast<binary>(base_malloc(sizeof(byte)*size));
file.read(data,size);
return data;
}
示例3: vnmalloc
Variable_array * VariableScript::parse(const FilePath &file) {
FileStream *fs = FileManager::instance().open(file);
if (!fs) {
_makeErrorMsg("open file \"%u:/%s\" failed!", file.fsId, file.fileName.c_str());
return 0;
}
fs->seek(0, DataStream::kEnd);
size_t size = (size_t)fs->tell();
fs->seek(0);
c8 *ptr = vnmalloc(c8, size);
if (fs->read(ptr, size) != size) {
_makeErrorMsg("read file \"%u:/%s\" failed!", file.fsId, file.fileName.c_str());
fs->close();
vnfree(ptr);
return 0;
}
fs->close();
c8 *txt = ptr;
// utf8 bom
if (strncmp(txt, "\xEF\xBB\xBF", 3) == 0) {
txt += 3;
size -= 3;
}
Token::File *tf = vnnew Token::File();
c8 buf[512];
int len = sprintf(buf, "%u:/%s", file.fsId, file.fileName.c_str());
tf->name.assign(buf, len);
Variable_array *ret = parse(txt, size, tf);
vnfree(ptr);
tf->drop();
return ret;
}
示例4: ftRead
unsigned long FontFreeType::ftRead(FT_Stream stream, unsigned long offset, unsigned char *buffer, unsigned long count) {
FileStream *fs = (FileStream *)stream->descriptor.pointer;
fs->seek(offset);
return fs->read(buffer, count);
}