blob: 34d9ae4b0be90bc2912d0a16b16eaff2764b299c [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001# Python script to get both the data and resource fork from a BinHex encoded
2# file.
Bram Moolenaar00285092012-06-29 11:46:33 +02003# Author: MURAOKA Taro <koron.kaoriya@gmail.com>
4# Last Change: 2012 Jun 29
5#
6# Copyright (C) 2003,12 MURAOKA Taro <koron.kaoriya@gmail.com>
7# THIS FILE IS DISTRIBUTED UNDER THE VIM LICENSE.
Bram Moolenaar071d4272004-06-13 20:20:40 +00008
9import sys
10import binhex
11
12input = sys.argv[1]
13conv = binhex.HexBin(input)
14info = conv.FInfo
15out = conv.FName
16out_data = out
17out_rsrc = out + '.rsrcfork'
18#print 'out_rsrc=' + out_rsrc
19print 'In file: ' + input
20
21outfile = open(out_data, 'wb')
22print ' Out data fork: ' + out_data
23while 1:
24 d = conv.read(128000)
25 if not d: break
26 outfile.write(d)
27outfile.close()
28conv.close_data()
29
30d = conv.read_rsrc(128000)
31if d:
32 print ' Out rsrc fork: ' + out_rsrc
33 outfile = open(out_rsrc, 'wb')
34 outfile.write(d)
35 while 1:
36 d = conv.read_rsrc(128000)
37 if not d: break
38 outfile.write(d)
39 outfile.close()
40
41conv.close()
42
43# vim:set ts=8 sts=4 sw=4 et: