-
Notifications
You must be signed in to change notification settings - Fork 0
/
core.clj
32 lines (24 loc) · 839 Bytes
/
core.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
(ns h3m-parser.core
(:require
[org.clojars.smee.binary.core :as binary]
[h3m-parser.h3m :as h3m]
[h3m-parser.lod :as lod]
[h3m-parser.def :as def-file])
(:import
[java.io FileInputStream BufferedInputStream]
[java.util.zip Inflater InflaterInputStream GZIPInputStream]))
(defn parse-h3m [in]
(binary/decode h3m/root (new GZIPInputStream in)))
(defn parse-lod [in]
(binary/decode lod/root in))
(defn parse-def [in]
(binary/decode def-file/root in))
(defn get-def-stream-from-lod
[lod-def-info ^FileInputStream in]
(let [{size :size
compressed-size :compressed-size
offset :offset} lod-def-info]
(.position (.getChannel in) (long offset))
(if (pos? compressed-size)
(new InflaterInputStream in (new Inflater) compressed-size)
(new BufferedInputStream in size))))