本文整理汇总了C++中NPT_XbmcFileReference类的典型用法代码示例。如果您正苦于以下问题:C++ NPT_XbmcFileReference类的具体用法?C++ NPT_XbmcFileReference怎么用?C++ NPT_XbmcFileReference使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NPT_XbmcFileReference类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
// 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;
}
示例3:
/*----------------------------------------------------------------------
| NPT_XbmcFileStream::Tell
+---------------------------------------------------------------------*/
NPT_Result
NPT_XbmcFileStream::Tell(NPT_Position& offset)
{
__int64 result = m_FileReference->GetPosition();
if (result >= 0) {
offset = (NPT_Position)result;
return NPT_SUCCESS;
} else {
return NPT_FAILURE;
}
}
示例4:
/*----------------------------------------------------------------------
| NPT_XbmcFileStream::Flush
+---------------------------------------------------------------------*/
NPT_Result
NPT_XbmcFileStream::Flush()
{
m_FileReference->Flush();
return NPT_SUCCESS;
}