It is all platform agnostic code. It works in my macOS.
This is strange.
Code:
HTMLResource *Book::CreateEmptyHTMLFile(const QString &folderpath)
{
HTMLResource *html_resource = CreateNewHTMLFile(folderpath);
QString version = html_resource->GetEpubVersion();
QString data;
QString template_path;
if (version.startsWith('2')) {
template_path = Utility::DefinePrefsDir() + "/" + "user-template2.xhtml";
data = EMPTY_HTML_FILE;
} else {
template_path = Utility::DefinePrefsDir() + "/" + "user-template3.xhtml";
data = EMPTY_HTML5_FILE;
}
if (QFile::exists(template_path)) {
data = CleanSource::Mend(Utility::ReadUnicodeTextFile(template_path), version);
}
html_resource->SetText(data);
SetModified(true);
return html_resource;
}
and
Code:
CSSResource *Book::CreateEmptyCSSFile(const QString &folderpath)
{
TempFolder tempfolder;
QString fullfilepath = tempfolder.GetPath() + "/" + m_Mainfolder->GetUniqueFilenameVersion(FIRST_CSS_NAME);
Utility::WriteUnicodeTextFile("", fullfilepath);
Resource * resource = m_Mainfolder->AddContentFileToFolder(fullfilepath,
true,
"text/css",
QString(),
folderpath);
CSSResource *css_resource = qobject_cast<CSSResource *>(resource);
QString version = css_resource->GetEpubVersion();
QString data = "";
QString template_path;
if (version.startsWith('2')) {
template_path = Utility::DefinePrefsDir() + "/" + "user-template2.css";
} else {
template_path = Utility::DefinePrefsDir() + "/" + "user-template3.css";
}
if (QFile::exists(template_path)) {
data = Utility::ReadUnicodeTextFile(template_path);
}
css_resource->SetText(data);
SetModified(true);
return css_resource;
}
So long as you used the correct file names it should work.
For epub2:
user-template2.xhtml
user-template2.css
and for epub3:
user-template3.xhtml
user-template3.css