本文整理汇总了C++中CFile::ReadFile方法的典型用法代码示例。如果您正苦于以下问题:C++ CFile::ReadFile方法的具体用法?C++ CFile::ReadFile怎么用?C++ CFile::ReadFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFile
的用法示例。
在下文中一共展示了CFile::ReadFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: defined
_UINT32 CPPTXFile::ConvertPPTYToPPTX(std::wstring bsInput, std::wstring bsOutput, std::wstring bsThemesFolder)//bsOutput и файл и директория может быть
{
OOX::CPath pathLocalTempDirectory;
if (m_fCallbackCompress)//если компрессора нет - конвертим в назначеную директорию
pathLocalTempDirectory = m_strTempDir ;
else
pathLocalTempDirectory = bsOutput; //выходной файл - папка
#ifdef _DEBUG
#if defined(_WIN32) || defined (_WIN64)
if (m_fCallbackCompress)
pathLocalTempDirectory = _T("C:\\PPTMemory\\PPTX_test");
#endif
#endif
NSBinPptxRW::CPPTXWriter oWriter;
oWriter.Init(pathLocalTempDirectory.GetPath());
CFile oFileBinary;
oFileBinary.OpenFile((std::wstring)bsInput);
LONG lFileSize = (LONG)oFileBinary.GetFileSize();
BYTE* pSrcBuffer = new BYTE[lFileSize];
oFileBinary.ReadFile(pSrcBuffer, (DWORD)lFileSize);
oFileBinary.CloseFile();
std::wstring strBsInput = bsInput;
std::wstring srcFolder = NSDirectory::GetFolderPath(strBsInput);
oWriter.OpenPPTY(pSrcBuffer, lFileSize, srcFolder, bsThemesFolder);
RELEASEARRAYOBJECTS(pSrcBuffer);
_UINT32 hRes = 0;
if (m_fCallbackCompress)
{
std::wstring strOutput = bsOutput;
std::wstring strInput = pathLocalTempDirectory.GetPath();
hRes = m_fCallbackCompress(m_pCallbackArg, strInput, strOutput) ? 0 : AVS_FILEUTILS_ERROR_CONVERT;
NSDirectory::DeleteDirectory(strInput);
}
return hRes;
}
示例2: DetectTypeDocument
std::wstring COfficeOdfFileW::DetectTypeDocument(const std::wstring & pathOOX)
{
std::wstring sRes;
CFile file;
CString fileContentType = std_string2string(pathOOX + FILE_SEPARATOR_STR + L"[Content_Types].xml");
if (file.OpenFile(fileContentType) != S_OK) return sRes;
int nBufferSize = min (file.GetFileSize(), 4096);
BYTE *pBuffer = new BYTE[nBufferSize];
file.ReadFile(pBuffer, nBufferSize);
file.CloseFile();
if (pBuffer != NULL)
{
const char *docxFormatLine = "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml";
const char *dotxFormatLine = "application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml";
const char *docmFormatLine = "application/vnd.ms-word.document.macroEnabled.main+xml";
const char *dotmFormatLine = "application/vnd.ms-word.template.macroEnabledTemplate.main+xml";
const char *xlsxFormatLine = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml";
const char *xltxFormatLine = "application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml";
const char *xlsmFormatLine = "application/vnd.ms-excel.sheet.macroEnabled.main+xml";
const char *xltmFormatLine = "application/vnd.ms-excel.template.macroEnabled.main+xml";
const char *pptxFormatLine = "application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml";
const char *ppsxFormatLine = "application/vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml";
const char *potxFormatLine = "application/vnd.openxmlformats-officedocument.presentationml.template.main+xml";
const char *pptmFormatLine = "application/vnd.ms-powerpoint.presentation.macroEnabled.main+xml";
const char *ppsmFormatLine = "application/vnd.ms-powerpoint.slideshow.macroEnabled.main+xml";
const char *potmFormatLine = "application/vnd.ms-powerpoint.template.macroEnabled.main+xml";
std::string strContentTypes((char*)pBuffer, nBufferSize);
int res = 0;
if ( (res = strContentTypes.find(docxFormatLine))>0 || (res = strContentTypes.find(dotxFormatLine))>0 ||
(res = strContentTypes.find(docmFormatLine))>0 || (res = strContentTypes.find(dotmFormatLine))>0)
{
sRes = L"text";
}
else if ((res = strContentTypes.find(xlsxFormatLine))>0 || (res = strContentTypes.find(xltxFormatLine))>0 ||
(res = strContentTypes.find(xlsmFormatLine))>0 || (res = strContentTypes.find(xltmFormatLine))>0)
{
sRes = L"spreadsheet";
}
else if ((res = strContentTypes.find(pptxFormatLine) > 0) || /*(res = strContentTypes.find(ppsxFormatLine))>0 ||*/
(res = strContentTypes.find(potxFormatLine))>0 || (res = strContentTypes.find(pptmFormatLine))>0 ||
(res = strContentTypes.find(ppsmFormatLine))>0 || (res = strContentTypes.find(potmFormatLine))>0 ||
(res = strContentTypes.find(ppsxFormatLine)) >0 )
{
}
delete []pBuffer;
pBuffer = NULL;
}
return sRes;
}