mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
Fix bug 56275
This commit is contained in:
@ -85,11 +85,71 @@ public:
|
|||||||
{
|
{
|
||||||
write(path, (BYTE*)xml.c_str(), (DWORD)xml.length());
|
write(path, (BYTE*)xml.c_str(), (DWORD)xml.length());
|
||||||
}
|
}
|
||||||
|
bool existsXml(const std::wstring& path)
|
||||||
|
{
|
||||||
|
if (exists(path))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
std::vector<std::wstring> arPieces = getFiles(path, false);
|
||||||
|
if (0 < arPieces.size())
|
||||||
|
{
|
||||||
|
std::sort(arPieces.begin(), arPieces.end());
|
||||||
|
std::vector<std::wstring>::iterator iter = arPieces.begin();
|
||||||
|
while (iter != arPieces.end())
|
||||||
|
{
|
||||||
|
std::wstring::size_type len = iter->length();
|
||||||
|
std::wstring::size_type pos = iter->rfind(L".piece");
|
||||||
|
if (std::wstring::npos != pos && ((pos + 6) == len))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
std::string readXml(const std::wstring& path)
|
std::string readXml(const std::wstring& path)
|
||||||
{
|
{
|
||||||
CBuffer* buffer = NULL;
|
CBuffer* buffer = NULL;
|
||||||
if (!read(path, buffer))
|
if (!read(path, buffer))
|
||||||
|
{
|
||||||
|
std::vector<std::wstring> arPieces = getFiles(path, false);
|
||||||
|
if (0 < arPieces.size())
|
||||||
|
{
|
||||||
|
std::sort(arPieces.begin(), arPieces.end());
|
||||||
|
std::vector<std::wstring>::iterator iter = arPieces.begin();
|
||||||
|
while (iter != arPieces.end())
|
||||||
|
{
|
||||||
|
std::wstring::size_type len = iter->length();
|
||||||
|
std::wstring::size_type pos = iter->rfind(L".piece");
|
||||||
|
if (std::wstring::npos != pos && ((pos + 6) == len))
|
||||||
|
{
|
||||||
|
iter++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
iter = arPieces.erase(iter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (0 < arPieces.size())
|
||||||
|
{
|
||||||
|
std::string sResult;
|
||||||
|
for (std::vector<std::wstring>::iterator iter = arPieces.begin(); iter != arPieces.end(); iter++)
|
||||||
|
{
|
||||||
|
CBuffer* bufferPiece = NULL;
|
||||||
|
if (read(*iter, bufferPiece))
|
||||||
|
{
|
||||||
|
sResult += std::string((char*)bufferPiece->Buffer, (size_t)bufferPiece->Size);
|
||||||
|
}
|
||||||
|
delete bufferPiece;
|
||||||
|
}
|
||||||
|
return sResult;
|
||||||
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
|
}
|
||||||
std::string sXmlUtf8((char*)buffer->Buffer, (size_t)buffer->Size);
|
std::string sXmlUtf8((char*)buffer->Buffer, (size_t)buffer->Size);
|
||||||
delete buffer;
|
delete buffer;
|
||||||
return sXmlUtf8;
|
return sXmlUtf8;
|
||||||
|
|||||||
@ -236,10 +236,10 @@ namespace XPS
|
|||||||
ReadAttribute(oReader, L"Source", wsSource);
|
ReadAttribute(oReader, L"Source", wsSource);
|
||||||
|
|
||||||
std::wstring wsPagePath = wsSource;
|
std::wstring wsPagePath = wsSource;
|
||||||
if (!m_wsPath->exists(wsPagePath))
|
if (!m_wsPath->existsXml(wsPagePath))
|
||||||
{
|
{
|
||||||
wsPagePath = wsFilePath + wsSource;
|
wsPagePath = wsFilePath + wsSource;
|
||||||
if (!m_wsPath->exists(wsPagePath))
|
if (!m_wsPath->existsXml(wsPagePath))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user