aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpacien2018-11-25 19:11:51 +0100
committerpacien2018-11-25 19:11:51 +0100
commit00cacbd664b1335bc8e7d9553448d1ad1f1744c7 (patch)
tree595b96a1d230aa5885d4bddbef6dd189fd21adaf /src
parent680c0a3c94f0bb84a2773bc9a95dc5399b6925fb (diff)
downloadgziplike-00cacbd664b1335bc8e7d9553448d1ad1f1744c7.tar.gz
Add text file identity test
Diffstat (limited to 'src')
-rw-r--r--src/main.nim6
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 @@
17import os, streams, sugar 17import os, streams, sugar
18import bitreader, bitwriter, streamblock 18import bitreader, bitwriter, streamblock
19 19
20proc transform(operation: (BitReader, BitWriter) -> void, input, output: string) = 20proc 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
27proc compress(bitReader: BitReader, bitWriter: BitWriter) = 27proc 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
33proc decompress(bitReader: BitReader, bitWriter: BitWriter) = 33proc 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)