Commit 431115ef authored by Oleg Korshul's avatar Oleg Korshul

fix open html file with incorrect extension

parent 206dd12a
...@@ -90,6 +90,17 @@ namespace NSCommon ...@@ -90,6 +90,17 @@ namespace NSCommon
pStr[i] = pStr[i] + 'A' - 'a'; pStr[i] = pStr[i] + 'A' - 'a';
} }
} }
static void makeUpperW(std::wstring& url)
{
int nLen = (int)url.length();
wchar_t* pStr = (wchar_t*)url.c_str();
for (int i = 0; i < nLen; ++i)
{
if (pStr[i] >= 'a' && pStr[i] <= 'z')
pStr[i] = pStr[i] + 'A' - 'a';
}
}
static void WriteLog(const std::string& sLogFile, const std::wstring& sData) static void WriteLog(const std::string& sLogFile, const std::wstring& sData)
{ {
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "../DesktopEditor/common/StringBuilder.h" #include "../DesktopEditor/common/StringBuilder.h"
#include "../DesktopEditor/common/String.h" #include "../DesktopEditor/common/String.h"
#include "../DesktopEditor/xml/include/xmlutils.h" #include "../DesktopEditor/xml/include/xmlutils.h"
#include "../DesktopEditor/fontengine/application_generate_fonts_common.h"
#include <vector> #include <vector>
#include <map> #include <map>
...@@ -242,10 +243,30 @@ int CHtmlFile::Convert(const std::vector<std::wstring>& arFiles, const std::wstr ...@@ -242,10 +243,30 @@ int CHtmlFile::Convert(const std::vector<std::wstring>& arFiles, const std::wstr
oBuilder.WriteString(L"</destination>"); oBuilder.WriteString(L"</destination>");
std::vector<std::wstring> arTmpFiles;
for (std::vector<std::wstring>::const_iterator iter = arFiles.begin(); iter != arFiles.end(); iter++) for (std::vector<std::wstring>::const_iterator iter = arFiles.begin(); iter != arFiles.end(); iter++)
{ {
oBuilder.WriteString(L"<file>"); oBuilder.WriteString(L"<file>");
oBuilder.WriteEncodeXmlString(CorrectHtmlPath(*iter));
std::wstring sFilePath = *iter;
std::wstring sExt = NSCommon::GetFileExtention(sFilePath);
NSCommon::makeUpperW(sExt);
if (sExt == L"HTML" || sExt == L"HTM")
oBuilder.WriteEncodeXmlString(CorrectHtmlPath(sFilePath));
else
{
std::wstring sTmpFile = NSFile::CFileBinary::CreateTempFileWithUniqueName(NSDirectory::GetTempPath(), L"HTM");
if (NSFile::CFileBinary::Exists(sTmpFile))
NSFile::CFileBinary::Remove(sTmpFile);
sTmpFile = sTmpFile + L".html";
NSFile::CFileBinary::Copy(sFilePath, sTmpFile);
oBuilder.WriteEncodeXmlString(CorrectHtmlPath(sTmpFile));
arTmpFiles.push_back(sTmpFile);
}
oBuilder.WriteString(L"</file>"); oBuilder.WriteString(L"</file>");
} }
...@@ -411,6 +432,12 @@ int CHtmlFile::Convert(const std::vector<std::wstring>& arFiles, const std::wstr ...@@ -411,6 +432,12 @@ int CHtmlFile::Convert(const std::vector<std::wstring>& arFiles, const std::wstr
} }
#endif #endif
for (std::vector<std::wstring>::iterator i = arTmpFiles.begin(); i != arTmpFiles.end(); i++)
{
NSFile::CFileBinary::Remove(*i);
}
arTmpFiles.clear();
NSFile::CFileBinary::Remove(sTempFileForParams); NSFile::CFileBinary::Remove(sTempFileForParams);
return nReturnCode; return nReturnCode;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment