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


C++ UDSEntry::numberValue方法代码示例

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


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

示例1: open

bool AfcDevice::open( const QString& path, QIODevice::OpenMode mode, KIO::Error& error )
{
    kDebug(KIO_AFC) << path << "mode: " << mode;

    bool ret = false;
    afc_file_mode_t file_mode = AFC_FOPEN_RDONLY;

    if ( QIODevice::ReadOnly == mode )
    {
        file_mode = AFC_FOPEN_RDONLY;
    }
    else if ( QIODevice::ReadWrite == mode )
    {
        file_mode = AFC_FOPEN_RW;
    }
    else if ( QIODevice::WriteOnly == mode )
    {
        file_mode = AFC_FOPEN_WRONLY;
    }
    else if ( ( QIODevice::ReadWrite | QIODevice::Truncate ) == mode )
    {
        file_mode = AFC_FOPEN_WR;
    }
    else if ( QIODevice::Append == mode )
    {
        file_mode = AFC_FOPEN_APPEND;
    }
    else if ( QIODevice::Truncate == mode )
    {
        file_mode = AFC_FOPEN_RDAPPEND;
    }
    else
    {
        error = KIO::ERR_COULD_NOT_ACCEPT;
        return false;
    }

    afc_error_t err = afc_file_open(_afc, (const char*) path.toLocal8Bit(), file_mode, &openFd);

    if ( checkError(err, error) )
    {
        openPath = path;
        UDSEntry entry;
        if ( createUDSEntry("", path, entry, error) )
        {
            ret = true;
            _proto->totalSize( entry.numberValue(UDSEntry::UDS_SIZE, 0) );
            _proto->position( 0 );
        }
    }
    return ret;
}
开发者ID:sunzhigang,项目名称:kio_afc,代码行数:52,代码来源:afcdevice.cpp

示例2: get

bool AfcDevice::get(const QString& path, KIO::Error& error)
{
    kDebug(KIO_AFC) << path;

    bool ret = false;
    UDSEntry entry;
    if ( createUDSEntry( "", path, entry, error ) )
    {
        if ( open(path, QIODevice::ReadOnly, error) )
        {
            KIO::filesize_t size = entry.numberValue(UDSEntry::UDS_SIZE);
            ret = read(size, error);

            close();
        }
    }
    return ret;
}
开发者ID:sunzhigang,项目名称:kio_afc,代码行数:18,代码来源:afcdevice.cpp

示例3: put

bool AfcDevice::put( const QString& path, KIO::JobFlags _flags, KIO::Error& error )
{
    kDebug(KIO_AFC) << path << _flags;

    UDSEntry entry;
    const bool bOrigExists = createUDSEntry( "", path, entry, error);

    if ( bOrigExists && !(_flags & KIO::Overwrite) && !(_flags & KIO::Resume))
    {
        if ( S_ISDIR ( entry.numberValue(UDSEntry::UDS_FILE_TYPE ) ) )
            error = KIO::ERR_DIR_ALREADY_EXIST;
        else
            error = KIO::ERR_FILE_ALREADY_EXIST;
        return false;
    }

    //open file
    if ( !path.isEmpty() )
    {
        if ( bOrigExists && !(_flags & KIO::Resume) )
        {
            kDebug(KIO_AFC) << "Deleting destination file" << path;
            if ( ! del (path, error) )
                return false;
        }

        if ( (_flags & KIO::Resume) )
        {
            if ( ! open(path, QIODevice::Append, error) )
                return false;

            if ( ! checkError (afc_file_seek(_afc, openFd, 0, SEEK_END), error ) )
            {
                close();
                return false;
            }
        }
        else
        {
            if ( ! open(path, QIODevice::ReadWrite | QIODevice::Truncate, error) )
                return false;
        }
    }

    int result;

    // Loop until we got 0 (end of data)
    do
    {
        QByteArray buffer;
        _proto->dataReq(); // Request for data
        result = _proto->readData( buffer );

        if (result >= 0)
        {
            if ( ! write( buffer, error) )
            {
                result = -1;
            }
        }
    }
    while ( result > 0 );

    // An error occurred deal with it.
    if (result < 0)
    {
        kDebug(KIO_AFC) << "Error during 'put'. Aborting.";

        if (openFd != (uint64_t)-1)
        {
            close();
        }
        return false;
    }

    if ( openFd == (uint64_t)-1 ) // we got nothing to write out, so we never opened the file
    {
        return true;
    }

    close();

    // set modification time
    const QString mtimeStr = _proto->metaData(QLatin1String("modified"));
    if ( !mtimeStr.isEmpty() )
    {
        QDateTime dt = QDateTime::fromString( mtimeStr, Qt::ISODate );
        if ( dt.isValid() )
        {
            setModificationTime(path, dt, error);
            //do not trigger error just for time
        }
    }

    // We have done our job => finish
    return true;
}
开发者ID:sunzhigang,项目名称:kio_afc,代码行数:97,代码来源:afcdevice.cpp


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