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


C++ NPT_XbmcFileReference::OpenForWrite方法代码示例

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


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

示例1: if

/*----------------------------------------------------------------------
|   NPT_XbmcFile::Open
+---------------------------------------------------------------------*/
NPT_Result
NPT_XbmcFile::Open(NPT_File::OpenMode mode)
{
    NPT_XbmcFileReference file;

    // check if we're already open
    if (!m_FileReference.IsNull()) {
        return NPT_ERROR_FILE_ALREADY_OPEN;
    }

    // store the mode
    m_Mode = mode;

    // check for special names
    const char* name = (const char*)m_Delegator.GetPath();
    if (NPT_StringsEqual(name, NPT_FILE_STANDARD_INPUT)) {
        return NPT_ERROR_FILE_NOT_READABLE;
    } else if (NPT_StringsEqual(name, NPT_FILE_STANDARD_OUTPUT)) {
        return NPT_ERROR_FILE_NOT_WRITABLE;
    } else if (NPT_StringsEqual(name, NPT_FILE_STANDARD_ERROR)) {
        return NPT_ERROR_FILE_NOT_WRITABLE;
    } else {

        file = CFileFactory::CreateLoader(name);
        if (file.IsNull()) {
            return NPT_ERROR_NO_SUCH_FILE;
        }

        bool result;
        CURL* url = new CURL(name);
        /* path is not fully qualified so assume it's relative to home dir */
        if (url->GetFileName().IsEmpty()) {
            delete url;
            CStdString homepath;
            CUtil::GetHomePath(homepath);
            url = new CURL(homepath + "/" + name);
        }

        // compute mode
        if (mode & NPT_FILE_OPEN_MODE_WRITE) {
            result = file->OpenForWrite(*url, (mode & NPT_FILE_OPEN_MODE_TRUNCATE)?true:false);
        } else {
            result = file->Open(*url);
        }

        delete url;
        if (!result) return NPT_ERROR_NO_SUCH_FILE;

        m_Size = (NPT_LargeSize)file->GetLength();
    }

    // store reference
    m_FileReference = file;

    return NPT_SUCCESS;
}
开发者ID:derobert,项目名称:debianlink-xbmc,代码行数:59,代码来源:NptXbmcFile.cpp

示例2: if

/*----------------------------------------------------------------------
|   NPT_XbmcFile::Open
+---------------------------------------------------------------------*/
NPT_Result
NPT_XbmcFile::Open(NPT_File::OpenMode mode)
{
    NPT_XbmcFileReference file;

    // check if we're already open
    if (!m_FileReference.IsNull()) {
        return NPT_ERROR_FILE_ALREADY_OPEN;
    }

    // store the mode
    m_Mode = mode;

    // check for special names
    const char* name = (const char*)m_Delegator.GetPath();
    if (NPT_StringsEqual(name, NPT_FILE_STANDARD_INPUT)) {
        return NPT_ERROR_FILE_NOT_READABLE;
    } else if (NPT_StringsEqual(name, NPT_FILE_STANDARD_OUTPUT)) {
        return NPT_ERROR_FILE_NOT_WRITABLE;
    } else if (NPT_StringsEqual(name, NPT_FILE_STANDARD_ERROR)) {
        return NPT_ERROR_FILE_NOT_WRITABLE;
    } else {

        file = CFileFactory::CreateLoader(name);
        if (file.IsNull()) {
            return NPT_ERROR_NO_SUCH_FILE;
        }

        bool result;
        CURL* url = new CURL(name);

        // compute mode
        if (mode & NPT_FILE_OPEN_MODE_WRITE) {
            result = file->OpenForWrite(*url, (mode & NPT_FILE_OPEN_MODE_TRUNCATE)?true:false);
        } else {
            result = file->Open(*url);
        }

        delete url;
        if (!result) return NPT_ERROR_NO_SUCH_FILE;
    }

    // store reference
    m_FileReference = file;

    return NPT_SUCCESS;
}
开发者ID:2BReality,项目名称:xbmc,代码行数:50,代码来源:NptXbmcFile.cpp


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