本文整理汇总了C++中QFile::seek方法的典型用法代码示例。如果您正苦于以下问题:C++ QFile::seek方法的具体用法?C++ QFile::seek怎么用?C++ QFile::seek使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QFile
的用法示例。
在下文中一共展示了QFile::seek方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: read_pkm_data
void MainWindow::read_pkm_data(QFile &romfile)
{
QDataStream read(&romfile);
for(short i=1;i<=total_pkm_name;i++){
rom_offset = 0x71B8A + i*23;
romfile.seek(rom_offset);
read>>pkm_base_hp[i];
read>>pkm_base_atk[i];
read>>pkm_base_def[i];
read>>pkm_base_speed[i];
read>>pkm_base_spc[i];
read>>pkm_type_1[i];
read>>pkm_type_2[i];
read>>pkm_catch_rate[i];
read>>pkm_base_experience[i];
read>>pkm_start_move_1[i];
read>>pkm_start_move_2[i];
read>>pkm_start_move_3[i];
read>>pkm_start_move_4[i];
read>>pkm_growth_rate[i];
read>>pkm_tmhm_flags[i][0];
read>>pkm_tmhm_flags[i][1];
read>>pkm_tmhm_flags[i][2];
read>>pkm_tmhm_flags[i][3];
read>>pkm_tmhm_flags[i][4];
read>>pkm_tmhm_flags[i][5];
read>>pkm_tmhm_flags[i][6];
if(pkm_type_1[i]>19) pkm_type_1[i] -= 11;
if(pkm_type_2[i]>19) pkm_type_2[i] -= 11;
}
// RB Level-up moves
for(short i=1;i<=total_pkm_name;i++){
rom_offset = 0x77FB00+(i*32);
romfile.seek(rom_offset);
for(short j=0;j<10;j++){
read>>pkm_rb_lvl[i][j];
}
for(short j=0;j<10;j++){
read>>pkm_rb_move[i][j];
}
}
// Y Level-up moves
for(short i=1;i<=total_pkm_name;i++){
rom_offset = 0x780DE0+(i*32);
romfile.seek(rom_offset);
for(short j=0;j<10;j++){
read>>pkm_y_lvl[i][j];
}
for(short j=0;j<10;j++){
read>>pkm_y_move[i][j];
}
}
}
示例2: copiarAquivos
void janelaPrincipal::copiarAquivos(QFile &origem, QFile &destino)
{
qint64 nCopySize = origem.size();
ui->progressBarGeral->setMaximum(nCopySize);
if(!(origem.open(QFile::ReadOnly) && destino.open(QFile::ReadWrite))){
return;
}
qDebug() << QString::number(nCopySize)+" o tamanho do arquivo";
//dialog->show();
for (qint64 i = 0; i < nCopySize; i += 1024*1024) {
if(iscopy){
destino.write(origem.read(i)); // write a byte
destino.seek(i); // move to next byte to read
origem.seek(i); // move to next byte to write
ui->progressBarGeral->setValue(i);
}else {
destino.remove();
break;
}
// ui->progressBarGeral->;
}
ui->progressBarGeral->setVisible(false);
ui->progressBarGeral->setValue(0);
modeldir->refresh();
}
示例3: fileType
quint8 fileType(QFile &file) {
file.seek(sizeof(quint32)*5);
quint8 type;
QDataStream fStr(&file);
fStr >> type;
file.seek(0);
return type;
}
示例4: read_pokedex_data
void MainWindow::read_pokedex_data(QFile &romfile)
{
// ***** Initialize Pokédex entries *****
for (short i=0;i<256;i++){
pokedex_entry[i] = "";
pokedex_entry_pointer[i] = 0;
}
// ***** Retrieve number of Pokédex entries *****
QDataStream read(&romfile);
romfile.seek(0x785843);
read>>total_pokedex_entry;
if(total_pokedex_entry == 255){
this->romtype=INVALID;
ui->label_rom_debug->setText("Corrupted ROM");
QMessageBox messageBox;
messageBox.setText("Too many Pokédex entries, 254 is the max.");
messageBox.setWindowTitle("Pokédex entries");
messageBox.exec();
}
else{
// ***** Retrieve Pokédex entries *****
for(short i=1;i<=total_pokedex_entry;i++){
// Retrieve Pokédex entry pointer
rom_offset = 0x785842 + i*4;
romfile.seek(rom_offset);
read>>buf16;
if(buf16 > 0x44D0){
this->romtype=INVALID;
ui->label_rom_debug->setText("Corrupted ROM");
QMessageBox messageBox;
messageBox.setText("Pokédex entries pointers are corrupted.");
messageBox.setWindowTitle("Pokédex entries pointers");
messageBox.exec();
}
else{
pokedex_entry_pointer[i] = buf16;
// Retrieve string
rom_offset = 0x785840 + buf16;
romfile.seek(rom_offset);
read>>buf8;
while(buf8 != 0 && buf8 != 0xFF && pokedex_entry[i].size()<192){
pokedex_entry[i] += char_table[buf8];
rom_offset++;
romfile.seek(rom_offset);
read>>buf8;
}
}
}
}
}
示例5: readTransPos
unsigned int FileTrans::readTransPos(QFile &file)
{
unsigned int postemp = file.pos(); //push file pos
file.seek(file.size()-4);
QDataStream str(&file);
str.setByteOrder(QDataStream::LittleEndian);
unsigned int pos ;
str>>pos;
file.seek(postemp); //pop file pos
if(pos<file.size())
return pos;
else
return 0;
}
示例6: read_pkm_names
void MainWindow::read_pkm_names(QFile &romfile)
{
// ***** Retrieve number of Pokémon names *****
QDataStream read(&romfile);
romfile.seek(0x7950B3);
read>>total_pkm_name;
if(total_pkm_name == 255){
this->romtype=INVALID;
ui->label_rom_debug->setText("Corrupted ROM");
QMessageBox messageBox;
messageBox.setText("Too many Pokémon names, 254 is the max.");
messageBox.setWindowTitle("Pokémon names");
messageBox.exec();
}
else{
// ***** Retrieve Pokémon names *****
for(short i=1;i<=total_pkm_name;i++){
// Retrieve string pointer
rom_offset = 0x7950B2 + i*4;
romfile.seek(rom_offset);
read>>buf16;
if(buf16 > 0x750){
this->romtype=INVALID;
ui->label_rom_debug->setText("Corrupted ROM");
QMessageBox messageBox;
messageBox.setText("Pokémon names pointers are corrupted.");
messageBox.setWindowTitle("Pokémon names pointers");
messageBox.exec();
}
else{
pkm_name_pointer[i] = buf16;
// Retrieve string
rom_offset = 0x7950B0 + buf16;
romfile.seek(rom_offset);
read>>buf8;
while(buf8 != 0 && buf8 != 0xFF && pkm_name[i].size()<11){
pkm_name[i] += char_table[buf8];
rom_offset++;
romfile.seek(rom_offset);
read>>buf8;
}
}
}
}
}
示例7: constructing_QFile
//----------------------------------------------------------------------------------
void tst_QIODevice::constructing_QFile()
{
QFile file;
QIODevice *device = &file;
QVERIFY(!device->isOpen());
file.setFileName(SRCDIR "tst_qiodevice.cpp");
QVERIFY(file.open(QFile::ReadOnly));
QVERIFY(device->isOpen());
QCOMPARE((int) device->openMode(), (int) QFile::ReadOnly);
char buf[1024];
memset(buf, 0, sizeof(buf));
qlonglong lineLength = device->readLine(buf, sizeof(buf));
QVERIFY(lineLength > 0);
QCOMPARE(file.pos(), lineLength);
file.seek(0);
char buf2[1024];
memset(buf2, 0, sizeof(buf2));
QCOMPARE(file.readLine(buf2, sizeof(buf2)), lineLength);
char *c1 = buf;
char *c2 = buf2;
while (*c1 && *c2) {
QCOMPARE(*c1, *c2);
++c1;
++c2;
}
QCOMPARE(*c1, *c2);
}
示例8: QFile
QFile *getAudioLabelHeaderLen(const QString &audioName, int &len)
{
QFile *pFile = new QFile(audioName);
if (!pFile->open(QIODevice::ReadOnly)) {
qDebug() << "Can not open file";
return NULL;
}
pFile->seek(0);
//读取标签头
ID3V2Header mp3ID3V2;
memset(&mp3ID3V2, 0, 10);
pFile->read((char *)&mp3ID3V2, 10);
if (0 != strncmp(mp3ID3V2.identi, "ID3", 3)) {
qDebug() << "No have ID3V2 label";
pFile->close();
return NULL;
}
len = (mp3ID3V2.size[0]&0x7f)*0x200000
+(mp3ID3V2.size[1]&0x7f)*0x4000
+(mp3ID3V2.size[2]&0x7f)*0x80
+(mp3ID3V2.size[3]&0x7f);
return pFile;
}
示例9: readBoardSize
bool GameBoard::readBoardSize( QFile & map ) {
if ( ! map.seek( 0 ) ) {
return false;
}
this->width = 0;
this->height = 0;
QTextStream in( &map );
QString line = in.readLine();
while ( ! line.isNull() ) {
int length = line.length();
if ( length > this->width ) {
this->width = length;
}
line = in.readLine();
++this->height;
}
if ( 5 > this->height || 5 > this->width ) {
return false;
}
this->width += 2;
this->height += 2;
return true;
}
示例10: play
void WavSound::play() {
QFile *file = new QFile(fileName);
file->open(QIODevice::ReadOnly);
QAudioFormat f;
readHeader(&f, file);
QAudioFormat format = f;
QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice());
if (!info.isFormatSupported(format)) {
qWarning() << "Raw audio format not supported by backend, cannot play audio.";
return;
}
//seek(0x4e*4); //...avoiding clicks from the wav files
file->seek(0x4e);
QAudioOutput *audio = new QAudioOutput(format, NULL);
if(file->size()<30000)
audio->setBufferSize(10000);
audio->setVolume(0.5);
connect(audio, SIGNAL(stateChanged(QAudio::State)), this, SLOT(handleStateChanged(QAudio::State)));
audio->start(file);
}
示例11: SetPosAbsCallback
//static
int SoundSourceWV::SetPosAbsCallback(void* id, unsigned int pos)
{
QFile* pFile = static_cast<QFile*>(id);
if (!pFile) {
return 0;
}
return pFile->seek(pos) ? 0 : -1;
}
示例12: readFileHeader
void Robotino::readFileHeader(QFile& file)
{
unsigned buflen = 20;
char buffer[buflen];
recordSize = 0;
file.seek(0);
file.readLine(buffer, buflen);
while(!file.atEnd() && strncmp(buffer,"end", strlen("end"))!=0)
{
if(strncmp(buffer,"action:", strlen("action:"))==0)
{
actionOffset = recordSize;
actionSize = atoi(buffer+strlen("action:"));
recordSize += actionSize;
}
else if(strncmp(buffer,"distance:", strlen("distance:"))==0)
{
distanceOffset = recordSize;
distanceSize = atoi(buffer+strlen("distance:"));
recordSize += distanceSize;
}
else if(strncmp(buffer,"accel:", strlen("accel:"))==0)
{
accelOffset = recordSize;
accelSize = atoi(buffer+strlen("accel:"));
recordSize += accelSize;
}
else if(strncmp(buffer,"current:", strlen("current:"))==0)
{
currentOffset = recordSize;
currentSize = atoi(buffer+strlen("current:"));
recordSize += currentSize;
}
else if(strncmp(buffer,"power:", strlen("power:"))==0)
{
powerOffset = recordSize;
powerSize = atoi(buffer+strlen("power:"));
recordSize += powerSize;
}
else if(strncmp(buffer,"bumper:", strlen("bumper:"))==0)
{
bumperOffset = recordSize;
bumperSize = atoi(buffer+strlen("bumper:"));
recordSize += bumperSize;
}
else if(strncmp(buffer,"audio:", strlen("audio:"))==0)
{
audioOffset = recordSize;
audioSize = atoi(buffer+strlen("audio:"));
recordSize += audioSize;
}
file.readLine(buffer, buflen);
}
headerSize = file.pos();
//std::cout << "Fertig" << std::endl;
}
示例13: SetPosRelCallback
//static
int SoundSourceWV::SetPosRelCallback(void *id, int delta, int mode)
{
QFile* pFile = static_cast<QFile*>(id);
if (!pFile) {
return 0;
}
switch(mode) {
case SEEK_SET:
return pFile->seek(delta) ? 0 : -1;
case SEEK_CUR:
return pFile->seek(pFile->pos() + delta) ? 0 : -1;
case SEEK_END:
return pFile->seek(pFile->size() + delta) ? 0 : -1;
default:
return -1;
}
}
示例14: qfileSeekCallback
int qfileSeekCallback( void * _udata, ogg_int64_t _offset, int _whence )
{
QFile * f = static_cast<QFile *>( _udata );
if( _whence == SEEK_CUR )
{
f->seek( f->pos() + _offset );
}
else if( _whence == SEEK_END )
{
f->seek( f->size() + _offset );
}
else
{
f->seek( _offset );
}
return 0;
}
示例15: SeekCallback
//static
int SoundSourceOggVorbis::SeekCallback(void *datasource, ogg_int64_t offset,
int whence) {
QFile* pFile = static_cast<QFile*>(datasource);
if (!pFile) {
return 0;
}
switch(whence) {
case SEEK_SET:
return pFile->seek(offset) ? 0 : -1;
case SEEK_CUR:
return pFile->seek(pFile->pos() + offset) ? 0 : -1;
case SEEK_END:
return pFile->seek(pFile->size() + offset) ? 0 : -1;
default:
return -1;
}
}