当前位置: 首页>>代码示例>>C++>>正文


C++ QFile::pos方法代码示例

本文整理汇总了C++中QFile::pos方法的典型用法代码示例。如果您正苦于以下问题:C++ QFile::pos方法的具体用法?C++ QFile::pos怎么用?C++ QFile::pos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QFile的用法示例。


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

示例1: TellCallback

//static
long SoundSourceOggVorbis::TellCallback(void* datasource) {
   QFile* pFile = static_cast<QFile*>(datasource);
   if (!pFile) {
       return 0;
   }
   return pFile->pos();
}
开发者ID:MK-42,项目名称:mixxx,代码行数:8,代码来源:soundsourceoggvorbis.cpp

示例2: 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);
}
开发者ID:KDE,项目名称:android-qt,代码行数:33,代码来源:tst_qiodevice.cpp

示例3: GetPosCallback

// static
uint32_t SoundSourceWV::GetPosCallback(void *id)
{
    QFile* pFile = static_cast<QFile*>(id);
    if (!pFile) {
        return 0;
    }
    return pFile->pos();
}
开发者ID:MK-42,项目名称:mixxx,代码行数:9,代码来源:soundsourcewv.cpp

示例4: 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;
}
开发者ID:eSMCs,项目名称:eSMCs-Robotino,代码行数:57,代码来源:robotino.cpp

示例5: find

bool ReaderDataBlockHeader::find(DataBlockHeader* outHeader, QFile& fin) {
    unsigned char buffer[BUFFER_SIZE];

    unsigned int nReadBytes;

    while ((nReadBytes = fin.read(reinterpret_cast<char*>(buffer), BUFFER_SIZE)) >
            HEADER_SIZE) {
        unsigned char* findPos =
            std::search(buffer, buffer + nReadBytes + 1, JAA::ARCHIVER_ID,
                        JAA::ARCHIVER_ID + JAA::ARCHIVER_ID_SIZE);

        if (findPos == buffer + nReadBytes + 1) {
            fin.seek(-(std::streamoff)(HEADER_SIZE - 1) + fin.pos());
        } else {
            // found at findPos

            if ((BUFFER_SIZE - (findPos - buffer)) > HEADER_SIZE) {
                // enough space in buffer

                outHeader->setData(findPos);

                if (!outHeader->checkCRC()) {
                    // valid CRC
                    fin.seek(-(std::streamoff)(nReadBytes - (findPos - buffer) - HEADER_SIZE) + fin.pos());
                    return false;
                } else {
                    // not valid CRC may be not header?
                    fin.seek(-static_cast<std::streamoff>(nReadBytes - (findPos - buffer) - 2) + fin.pos());
                    // try again with offset
                }
            } else {
                // not enough space
                fin.seek(-(nReadBytes - (findPos - buffer) - 1) + fin.pos());
            }
        }
    }

    return true;
}
开发者ID:Hexta,项目名称:JAA,代码行数:39,代码来源:readerDataBlockHeader.cpp

示例6: readNullTerminatedString

QString readNullTerminatedString(QFile &file, QTextCodec *codec, qint64 &length)
{
    if(codec == NULL)
    {
        throw std::runtime_error("Codec is NULL");
    }
    qint64 pos = file.pos();
    while (true)
    {
        quint8 nextSymbol = 0;
        if (file.read(reinterpret_cast<char *> (&nextSymbol),
                Q_INT64_C(1)) != Q_INT64_C(1))
        {
            throw std::runtime_error("Unable to read file");
        }
        if (nextSymbol == 0)
        {
            break;
        }
    }
    qint64 stringLength = file.pos() - pos;
    length = stringLength;
    seekFile(file, pos);
    QScopedArrayPointer<quint8> stringIn(new quint8[stringLength]);
    if (file.read(reinterpret_cast<char *> (stringIn.data()),
            stringLength) != stringLength)
    {
        throw std::runtime_error("Unable to read file");
    }
    QScopedPointer<QTextDecoder> decoder(codec->makeDecoder());
    if (decoder.isNull())
    {
        throw std::runtime_error("Unable to create text decoder");
    }
    return decoder->toUnicode(
        reinterpret_cast<const char *> (stringIn.data()),
        static_cast<int> (stringLength - Q_INT64_C(1)));
}
开发者ID:rel-eng,项目名称:QWinHelp,代码行数:38,代码来源:IOUtils.cpp

示例7: ReadCallback

//static
size_t SoundSourceOggVorbis::ReadCallback(void *ptr, size_t size, size_t nmemb,
       void *datasource) {
   if (!size || !nmemb) {
       return 0;
   }
   QFile* pFile = static_cast<QFile*>(datasource);
   if (!pFile) {
       return 0;
   }

   nmemb = math_min<size_t>((pFile->size() - pFile->pos()) / size, nmemb);
   pFile->read((char*)ptr, nmemb * size);
   return nmemb;
}
开发者ID:MK-42,项目名称:mixxx,代码行数:15,代码来源:soundsourceoggvorbis.cpp

示例8: 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;
}
开发者ID:httpftpli,项目名称:wm,代码行数:14,代码来源:qcomm.cpp

示例9: writeHeader

void FileWriter::writeHeader(QDataStream & dataStream, QFile & file, AssetInformation & info)
{
    if (info.properties().empty())
        return;

    dataStream << static_cast<quint16>(RawFile::s_signature);

    quint64 rawDataOffsetPosition = file.pos();
    dataStream << static_cast<quint64>(0);

    QMapIterator<QVariantMap::key_type, QVariantMap::mapped_type> iterator(info.properties());

    while (iterator.hasNext())
    {
        iterator.next();

        QString key = iterator.key();
        QVariant value = iterator.value();

		RawFile::PropertyType type = propertyType(value.type());

        if (type == RawFile::PropertyType::Unknown)
            continue;

        dataStream << static_cast<uint8_t>(type);
        writeString(dataStream, key);

        writeValue(dataStream, value);
    }

    quint64 rawDataOffset = file.pos();

    file.seek(rawDataOffsetPosition);
    dataStream << rawDataOffset;
    file.seek(rawDataOffset);
}
开发者ID:Highlife1911,项目名称:glraw,代码行数:36,代码来源:FileWriter.cpp

示例10: saveTablesInfo

void Table_Control::saveTablesInfo(QFile &archivo, int sizeBlock, int HeadSize){
    for(int i=0;i<this->metaData.count();i++){
        archivo.write(reinterpret_cast<char*>(&this->metaData[i]),sizeof(MetaDataTable));
    }
    qDebug()<<"Cantidad campo to save:"<<this->campos.count();
    QMap<int,Table_Fields>::ConstIterator it;
    for(it=this->campos.constBegin();it!=this->campos.constEnd();it++){
        Table_Fields tempField=it.value();
        archivo.seek(HeadSize+this->metaData.at(it.key()).pointerToFields*sizeBlock);
        qDebug()<<archivo.pos();
        for(int i=0;i<tempField.campos.count();i++){
            qDebug()<<tempField.campos[i].name<<i<<HeadSize+this->metaData.at(it.key()).pointerToFields*sizeBlock+(i*sizeof(Field))<<it.key()<<this->metaData.at(it.key()).pointerToFields*sizeBlock;
            archivo.write(reinterpret_cast<char*>(&tempField.campos[i]),sizeof(Field));
        }
    }
    this->campos.clear();
}
开发者ID:slipmar,项目名称:BASE_DATOS,代码行数:17,代码来源:table_control.cpp

示例11: 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;
   }
}
开发者ID:MK-42,项目名称:mixxx,代码行数:19,代码来源:soundsourceoggvorbis.cpp

示例12: 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;
}
开发者ID:floft,项目名称:lmms,代码行数:18,代码来源:SampleBuffer.cpp

示例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;
    }
}
开发者ID:MK-42,项目名称:mixxx,代码行数:19,代码来源:soundsourcewv.cpp

示例14: loadRaw

qint64 StateImport::loadRaw(State* state, QFile& file)
{
    auto size = file.size() - file.pos();
    if (size % 8 !=0)
    {
        state->setErrorMessage(QObject::tr("Warning: file is not multiple of 8. Characters might be incomplete"));
        qDebug() << "File size not multiple of 8 (" << size << "). Characters might be incomplete";
    }

    int toRead = std::min((int)size, State::CHAR_BUFFER_SIZE);

    // clean previous memory in case not all the chars are loaded
    state->resetCharsetBuffer();

    auto total = file.read((char*)state->getCharsetBuffer(), toRead);

    Q_ASSERT(total == toRead && "Failed to read file");

    return total;
}
开发者ID:gitter-badger,项目名称:vchar64,代码行数:20,代码来源:stateimport.cpp

示例15: WriteWavHeadToFile

void DecodeAudioFile::WriteWavHeadToFile(QFile &f,int outLen, int sampleRate, int sampleSize, int channel)
{
    WAVFMT wavHeader ;
    wavHeader.RIFF[0] = 'R';
    wavHeader.RIFF[1] = 'I';
    wavHeader.RIFF[2] = 'F';
    wavHeader.RIFF[3] = 'F';

    wavHeader.totalSize = 44 + outLen;

    wavHeader.WAVE[0] = 'W';
    wavHeader.WAVE[1] = 'A';
    wavHeader.WAVE[2] = 'V';
    wavHeader.WAVE[3] = 'E';

    wavHeader.FMT[0] = 'f';
    wavHeader.FMT[1] = 'm';
    wavHeader.FMT[2] = 't';
    wavHeader.FMT[3] = ' ';

    wavHeader.FILTER = 0x00000010;
    wavHeader.formatTag = 1;
    wavHeader.channels = channel;
    wavHeader.sampleRate = sampleRate;
    wavHeader.bytesPerSec = sampleRate*sampleSize*channel/8;
    wavHeader.bytesInSample = sampleSize/8;
    wavHeader.bitsDepth = sampleSize;

    wavHeader.DATA[0] = 'd';
    wavHeader.DATA[1] = 'a';
    wavHeader.DATA[2] = 't';
    wavHeader.DATA[3] = 'a';

    wavHeader.dataSize = outLen;
    int pos = f.pos();
    f.seek(0);
    f.write((char*)&wavHeader,sizeof(WAVFMT));
    f.seek(pos);
    f.flush();
}
开发者ID:wsygzyr,项目名称:YYClient,代码行数:40,代码来源:DecodeAudioFile.cpp


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