 					[id contents]
 					(error "Unknown frame key (%s)" key)))))))
 
-(defn ^:private read-header [path]
+(defn read-header [path]
 	(with-open [f (io/input-stream path)]
 		(b/decode id3-header f)))
 

		[clojure.java.io :as io]
		[org.clojars.smee.binary.core :as b]))

(def ^:private default-padding 1024)

(defn body-size [tag]
	(apply + (map #(+ 10 (common/frame-body-size %)) (::frames tag))))

(def ^:private id3-header (b/ordered-map
	::magic-number (b/constant (b/string latin1 :length 3) "ID3")
	::version (b/enum :byte {3 3 4 4})
	::revision :byte
	::flags (b/bits [nil nil nil nil :id3.flag/footer :id3.flag/experimental :id3.flag/extended-header :id3.flag/unsynchronized]) ; ID3v2.3 doesn't really have a footer tag, but it's not worth the complexity of separate header codecs
	::size common/synchsafe-int))

(def ^:private text-frame-keys #:id3.frame.type{
	:text [:id3.frame/content]
	:user-text [:id3.frame/description :id3.frame/content]
	:picture [:id3.frame/description]})

(def ^:private id3
	(b/header id3-header
		(fn [header] (b/compile-codec (common/body-codec header)
			#(apply dissoc % (keys header))

			:simple full->simple)]
		(downconvert tag)))

(defn add-padding [padding tag]
	(assoc tag ::size
		(+ (body-size tag)
			(or padding default-padding))))
