本文整理汇总了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;
}
示例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;
}