diff options
| author | Michael Williamson <mike@zwobble.org> | 2016-04-17 18:57:29 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2016-04-17 18:58:12 +0100 |
| commit | 52140d52210eda0f25ecab9f89b5c73473e9d8e0 (patch) | |
| tree | cb383edb71e44b8ae7b2b0d0890f13574d1922f0 /dotnet/Mammoth/Couscous/mammoth/internal/docx | |
| parent | 0f9ef005f063198ea2e16ca36beaead4bd5e3824 (diff) | |
Add CLI for .NET version
Diffstat (limited to 'dotnet/Mammoth/Couscous/mammoth/internal/docx')
| -rw-r--r-- | dotnet/Mammoth/Couscous/mammoth/internal/docx/InMemoryDocxFile.cs | 17 | ||||
| -rw-r--r-- | dotnet/Mammoth/Couscous/mammoth/internal/docx/ZippedDocxFile.cs | 26 |
2 files changed, 43 insertions, 0 deletions
diff --git a/dotnet/Mammoth/Couscous/mammoth/internal/docx/InMemoryDocxFile.cs b/dotnet/Mammoth/Couscous/mammoth/internal/docx/InMemoryDocxFile.cs new file mode 100644 index 0000000..a475acd --- /dev/null +++ b/dotnet/Mammoth/Couscous/mammoth/internal/docx/InMemoryDocxFile.cs @@ -0,0 +1,17 @@ +using Mammoth.Couscous.java.io; +using Mammoth.Couscous.java.util; + +namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.docx { + internal class InMemoryDocxFile : DocxFile { + internal static DocxFile fromStream(InputStream stream) { + return new InMemoryDocxFile(); + } + + public Optional<InputStream> tryGetInputStream(string name) { + throw new System.NotImplementedException(); + } + + public void close() { + } + } +} 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(); + } + } +} |
