7
|
1 # Python script to get both the data and resource fork from a BinHex encoded
|
|
2 # file.
|
3614
|
3 # 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.
|
7
|
8
|
|
9 import sys
|
|
10 import binhex
|
|
11
|
|
12 input = sys.argv[1]
|
|
13 conv = binhex.HexBin(input)
|
|
14 info = conv.FInfo
|
|
15 out = conv.FName
|
|
16 out_data = out
|
|
17 out_rsrc = out + '.rsrcfork'
|
|
18 #print 'out_rsrc=' + out_rsrc
|
|
19 print 'In file: ' + input
|
|
20
|
|
21 outfile = open(out_data, 'wb')
|
|
22 print ' Out data fork: ' + out_data
|
|
23 while 1:
|
|
24 d = conv.read(128000)
|
|
25 if not d: break
|
|
26 outfile.write(d)
|
|
27 outfile.close()
|
|
28 conv.close_data()
|
|
29
|
|
30 d = conv.read_rsrc(128000)
|
|
31 if 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
|
|
41 conv.close()
|
|
42
|
|
43 # vim:set ts=8 sts=4 sw=4 et:
|