blob: 00e8f9f34032dc884e675e1f21e3f3ec62827733 [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>
Bram Moolenaar1b2f61e2018-03-27 21:12:01 +02004# Last Change: 2018 Mar 27
Bram Moolenaar00285092012-06-29 11:46:33 +02005#
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'
Bram Moolenaar1b2f61e2018-03-27 21:12:01 +020018
19# This uses the print statement on Python 2, print function on Python 3.
20#print('out_rsrc=' + out_rsrc)
21print('In file: ' + input)
Bram Moolenaar071d4272004-06-13 20:20:40 +000022
23outfile = open(out_data, 'wb')
Bram Moolenaar1b2f61e2018-03-27 21:12:01 +020024print(' Out data fork: ' + out_data)
Bram Moolenaar071d4272004-06-13 20:20:40 +000025while 1:
26 d = conv.read(128000)
27 if not d: break
28 outfile.write(d)
29outfile.close()
30conv.close_data()
31
32d = conv.read_rsrc(128000)
33if d:
Bram Moolenaar1b2f61e2018-03-27 21:12:01 +020034 print(' Out rsrc fork: ' + out_rsrc)
Bram Moolenaar071d4272004-06-13 20:20:40 +000035 outfile = open(out_rsrc, 'wb')
36 outfile.write(d)
37 while 1:
38 d = conv.read_rsrc(128000)
39 if not d: break
40 outfile.write(d)
41 outfile.close()
42
43conv.close()
44
45# vim:set ts=8 sts=4 sw=4 et: