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


C++ QFileInfo::IsReadOnly方法代码示例

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


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

示例1: Open

EQFileSystemError QFileStream::Open(const QPath &filePath, const EQFileOpenMode &eOpenMode)
{
    QE_ASSERT_ERROR(m_bIsOpen != true, "The file stream is already open.");

    EQFileSystemError eErrorInfo = EQFileSystemError::E_Unknown;
    const bool FILE_EXISTS = SQFile::Exists(filePath, eErrorInfo);

    if((FILE_EXISTS && (eOpenMode == EQFileOpenMode::E_Append || eOpenMode == EQFileOpenMode::E_Open)) ||
       (!FILE_EXISTS && eOpenMode == EQFileOpenMode::E_Create)                                         ||
       eOpenMode == EQFileOpenMode::E_CreateOrOverwrite                                                || 
       eOpenMode == EQFileOpenMode::E_OpenOrCreate)
    {
        if(FILE_EXISTS)
        {
            QFileInfo fileInfo = SQFile::GetFileInfo(filePath, eErrorInfo);
            m_uFileSize = scast_q(fileInfo.GetSize(), pointer_uint_q);
            m_bWritingIsAllowed = !fileInfo.IsReadOnly();
            
            QE_ASSERT_ERROR(!(fileInfo.IsReadOnly() && eOpenMode == EQFileOpenMode::E_CreateOrOverwrite), string_q("The current user does not have permissions to overwrite the file \"") + filePath.GetAbsolutePath() + "\".");
        }
        else
        {
            m_uFileSize = 0;
            m_bWritingIsAllowed = true;
        }

        m_path = filePath;

        bool bOperationSuccessful = QFileStream::_OpenPlatformImplementation(m_path, eOpenMode, m_bWritingIsAllowed, m_nativeHandle, eErrorInfo);
        
        if(bOperationSuccessful)
        {
            m_bIsOpen = true;
            eErrorInfo = EQFileSystemError::E_Success;

            if(eOpenMode == EQFileOpenMode::E_Append)
                this->SetPosition(m_uFileSize);
            else
                this->SetPosition(0);

            QE_ASSERT_WARNING(m_uFileSize <= pointer_uint_q(-1), "The the file is too large, this class cannot access file offsets over 2^32 - 1 when it is compiled for x86 architecture.");

            if(m_uFileSize > pointer_uint_q(-1))
            {
                eErrorInfo = EQFileSystemError::E_FileIsTooLarge;
            }
        }
    }
    else if(FILE_EXISTS && eOpenMode == EQFileOpenMode::E_Create)
    {
        eErrorInfo = EQFileSystemError::E_AlreadyExists;
    }
    else
    {
        eErrorInfo = EQFileSystemError::E_DoesNotExist;
    }

    return eErrorInfo;
}
开发者ID:sanyaade-g2g-repos,项目名称:quimeraengine,代码行数:59,代码来源:QFileStream.cpp


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