diff options
Diffstat (limited to 'dotnet/Mammoth/Couscous/mammoth/internal/docx/ZippedDocxFile.cs')
| -rw-r--r-- | dotnet/Mammoth/Couscous/mammoth/internal/docx/ZippedDocxFile.cs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/dotnet/Mammoth/Couscous/mammoth/internal/docx/ZippedDocxFile.cs b/dotnet/Mammoth/Couscous/mammoth/internal/docx/ZippedDocxFile.cs new file mode 100644 index 0000000..cad7a2f --- /dev/null +++ b/dotnet/Mammoth/Couscous/mammoth/internal/docx/ZippedDocxFile.cs @@ -0,0 +1,26 @@ +using System.IO.Compression; +using Mammoth.Couscous.java.io; +using Mammoth.Couscous.java.util; + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class ZippedDocxFile : DocxFile { + private readonly ZipArchive _zipFile; + + internal ZippedDocxFile(File file) { + _zipFile = ZipFile.OpenRead(file.Path); + } + + public Optional<InputStream> tryGetInputStream(string name) { + var entry = _zipFile.GetEntry(name); + if (entry == null) { + return Optional.empty<InputStream>(); + } else { + return Optional.of(ToJava.StreamToInputStream(entry.Open())); + } + } + + public void close() { + _zipFile.Dispose(); + } + } +} |
