Skip to content

Commit

Permalink
CreateContainerXmlの変更
Browse files Browse the repository at this point in the history
  • Loading branch information
aiueo-1234 committed Mar 10, 2024
1 parent aaf47f2 commit 409d868
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions Epub/KoeBook.Epub/Services/EpubCreateService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ public class EpubCreateService(IFileExtensionService fileExtensionService) : IEp
private readonly IFileExtensionService _fileExtensionService = fileExtensionService;
private readonly StringBuilder _builder = new();

internal const string ContainerXml = """
<?xml version="1.0" encoding="UTF-8"?>
<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
<rootfiles>
<rootfile full-path="OEBPS/book.opf" media-type="application/oebps-package+xml" />
</rootfiles>
</container>
""";

public async ValueTask<bool> TryCreateEpubAsync(EpubDocument epubDocument, string tmpDirectory, CancellationToken ct)
{
if (!File.Exists(epubDocument.CoverFilePath))
Expand All @@ -31,7 +40,7 @@ public async ValueTask<bool> TryCreateEpubAsync(EpubDocument epubDocument, strin
var containerEntry = archive.CreateEntry("META-INF/container.xml");
using (var containerStream = new StreamWriter(containerEntry.Open()))
{
await containerStream.WriteLineAsync(CreateContainerXml()).ConfigureAwait(false);
await containerStream.WriteLineAsync(ContainerXml).ConfigureAwait(false);
await containerStream.FlushAsync(ct).ConfigureAwait(false);
}

Expand Down Expand Up @@ -255,15 +264,6 @@ internal string CreateOpf(EpubDocument epubDocument)
return _builder.ToString();
}

internal static string CreateContainerXml() => """
<?xml version="1.0" encoding="UTF-8"?>
<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
<rootfiles>
<rootfile full-path="OEBPS/book.opf" media-type="application/oebps-package+xml" />
</rootfiles>
</container>
""";

internal string CreateSectionXhtml(Section section)
{
_builder.Clear();
Expand Down

0 comments on commit 409d868

Please sign in to comment.