#!/usr/bin/python
# -*- coding: utf-8 -*-

import os
import sys
sys.path.append('./gditools')

from gditools import ISO9660

def main(filename):
    a = dict(filename=os.path.abspath(filename), mode=2336, offset=11702*2048 - 1239040, wormhole=[0, 11702*2048, 32*2048], manualRawOffset=224)
    
    b = ISO9660(a, verbose=True)
    
    for i in b._sorted_records('EX_LOC'):
        if not i['name'] in ['/0.0', '/DUMMY.DAT']:
            b.dump_file_by_record(i, './data')
            #b.dump_file_by_record(i, './'+b.get_pvd()['volume_identifier'])
    
    b.dump_sorttxt()
    b.dump_bootsector(lba=11702)


if __name__ == '__main__':
    if len(sys.argv) == 2:
        main(sys.argv[1])
    else:
        print('dumpcdi11702.py - Based on gditools\n\nError: Bad syntax\n\nUsage: dumpcdi11702.py image.cdi')



