diff options
author | pacien | 2018-11-25 19:11:51 +0100 |
---|---|---|
committer | pacien | 2018-11-25 19:11:51 +0100 |
commit | 00cacbd664b1335bc8e7d9553448d1ad1f1744c7 (patch) | |
tree | 595b96a1d230aa5885d4bddbef6dd189fd21adaf /src | |
parent | 680c0a3c94f0bb84a2773bc9a95dc5399b6925fb (diff) | |
download | gziplike-00cacbd664b1335bc8e7d9553448d1ad1f1744c7.tar.gz |
Add text file identity test
Diffstat (limited to 'src')
-rw-r--r-- | src/main.nim | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/main.nim b/src/main.nim index 8f0536c..4fc137f 100644 --- a/src/main.nim +++ b/src/main.nim | |||
@@ -17,20 +17,20 @@ | |||
17 | import os, streams, sugar | 17 | import os, streams, sugar |
18 | import bitreader, bitwriter, streamblock | 18 | import bitreader, bitwriter, streamblock |
19 | 19 | ||
20 | proc transform(operation: (BitReader, BitWriter) -> void, input, output: string) = | 20 | proc transform*(operation: (BitReader, BitWriter) -> void, input, output: string) = |
21 | let inputStream = openFileStream(input, fmRead) | 21 | let inputStream = openFileStream(input, fmRead) |
22 | defer: inputStream.close() | 22 | defer: inputStream.close() |
23 | let outputStream = openFileStream(output, fmWrite) | 23 | let outputStream = openFileStream(output, fmWrite) |
24 | defer: outputStream.close() | 24 | defer: outputStream.close() |
25 | operation(inputStream.bitReader(), outputStream.bitWriter()) | 25 | operation(inputStream.bitReader(), outputStream.bitWriter()) |
26 | 26 | ||
27 | proc compress(bitReader: BitReader, bitWriter: BitWriter) = | 27 | proc compress*(bitReader: BitReader, bitWriter: BitWriter) = |
28 | while not bitReader.atEnd(): | 28 | while not bitReader.atEnd(): |
29 | let streamBlock = streamblock.readRaw(bitReader) | 29 | let streamBlock = streamblock.readRaw(bitReader) |
30 | streamBlock.writeSerialisedTo(bitWriter) | 30 | streamBlock.writeSerialisedTo(bitWriter) |
31 | bitWriter.flush() | 31 | bitWriter.flush() |
32 | 32 | ||
33 | proc decompress(bitReader: BitReader, bitWriter: BitWriter) = | 33 | proc decompress*(bitReader: BitReader, bitWriter: BitWriter) = |
34 | var hasMore = true | 34 | var hasMore = true |
35 | while hasMore: | 35 | while hasMore: |
36 | let streamBlock = streamblock.readSerialised(bitReader) | 36 | let streamBlock = streamblock.readSerialised(bitReader) |