예제 #1
0
zfindex _ZFP_ZFCoreStringW::findCaseInsensitive(const zfcharW *s, zfindex pos /* = 0 */) const
{
    zfindex srcLen = zfslenW(s);
    if(srcLen == 0 || pos + srcLen > this->length())
    {
        return zfindexMax;
    }

    _ZFP_ZFCoreStringW selfTmp(this->length() - pos);
    _ZFP_ZFCoreString_toLower(selfTmp, this->cString() + pos);

    _ZFP_ZFCoreStringW srcTmp(zfslenW(s));
    _ZFP_ZFCoreString_toLower(srcTmp, s);

    zfindex result = selfTmp.find(srcTmp.cString(), 0);
    if(result == zfindexMax)
    {
        return zfindexMax;
    }
    else
    {
        return pos + result;
    }
}
예제 #2
0
void FileManager::copyFolder(QString scrPath, QString dstPath)
{
    QFileInfoList fList;
    fList.clear();
    getFolderFiles(scrPath, fList);
    if(fList.size() == 0)
    {
        //QMessageBox::warning(this, tr("Error"), tr("文件夹是空的:").arg(scrPath), 0, 0);
        qDebug() << tr("文件夹是空的:").arg(srcfileName);
        return;
    }

    if(srcfileName.compare(destinationPath) == 0) return;

    bool stopped = false;
    int curIndex = 0;
    while( !stopped )
    {
        if( curIndex == fList.size() )
        {
            stopped = true;
            continue;
        }
        QFileInfo curFileInfo = fList.at(curIndex);
        QString srcFileName = curFileInfo.filePath();
        QFile src(srcFileName);

        QFileInfo srcTmp(srcfileName);
        QString srcTripname = srcFileName.remove(srcfileName);
        QString dstFileName = srcTripname.insert(0, dstPath+srcTmp.fileName());
        QFile dst(dstFileName);
        QFileInfo tmp(dstFileName);
        qDebug() << tmp.path();
        QDir d(tmp.path());
        if(!d.exists())
            d.mkpath(d.absolutePath());
        //now copy
        if(!src.open(QFile::ReadOnly) || !dst.open(QFile::WriteOnly)) continue;
        fileSize = src.bytesAvailable();
        qint64 BUFF_SIZE = 61440;
        char* buffer = new char[BUFF_SIZE];
        //int oldPercent = 0;
        while( !src.atEnd() )
        {
            dst.write(buffer, src.read(buffer, BUFF_SIZE));
            //dst.flush();
        }
        src.close();
        dst.close();
        delete[] buffer;
        buffer = NULL;

        curIndex++;
        int percent = (curIndex*100) / fList.size();//((curIndex + 1) * 100) / fileSize;
        //if (oldPercent != percent)
        {
            emit verificationProgressSignal(percent);
            //oldPercent = percent;
        }
    }
    fList.clear();
}