1 /*
2  * diskcontents.c - Extract the directory from disk images.
3  *
4  * Written by
5  *  Ettore Perazzoli <ettore@comm2000.it>
6  *  Andreas Boose <viceteam@t-online.de>
7  *  Tibor Biczo <crown@mail.matav.hu>
8  *
9  * This file is part of VICE, the Versatile Commodore Emulator.
10  * See README for copyright notice.
11  *
12  *  This program is free software; you can redistribute it and/or modify
13  *  it under the terms of the GNU General Public License as published by
14  *  the Free Software Foundation; either version 2 of the License, or
15  *  (at your option) any later version.
16  *
17  *  This program is distributed in the hope that it will be useful,
18  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  *  GNU General Public License for more details.
21  *
22  *  You should have received a copy of the GNU General Public License
23  *  along with this program; if not, write to the Free Software
24  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
25  *  02111-1307  USA.
26  *
27  */
28 
29 #include "vice.h"
30 
31 #include <stdio.h>
32 
33 #include "diskcontents-block.h"
34 #include "diskcontents-iec.h"
35 #include "diskcontents.h"
36 #include "imagecontents.h"
37 #include "lib.h"
38 #include "machine-bus.h"
39 #include "machine.h"
40 #include "serial.h"
41 #include "attach.h"
42 #include "vdrive-internal.h"
43 
44 
diskcontents_read(const char * file_name,unsigned int unit,unsigned int drive)45 image_contents_t *diskcontents_read(const char *file_name, unsigned int unit, unsigned int drive)
46 {
47     switch (machine_bus_device_type_get(unit)) {
48         default:
49             return diskcontents_filesystem_read(file_name);
50         case SERIAL_DEVICE_REAL:
51             return machine_diskcontents_bus_read(unit);
52         case SERIAL_DEVICE_RAW:
53             return diskcontents_block_read(file_system_get_vdrive(unit, drive));
54     }
55 }
56 
diskcontents_filesystem_read(const char * file_name)57 image_contents_t *diskcontents_filesystem_read(const char *file_name)
58 {
59     return diskcontents_block_read(vdrive_internal_open_fsimage(file_name, 1));
60 }
61 
diskcontents_read_unit8(const char * file_name)62 image_contents_t *diskcontents_read_unit8(const char *file_name)
63 {
64     /* TODO: drive 1 */
65     return diskcontents_read(file_name, 8, 0);
66 }
67 
diskcontents_read_unit9(const char * file_name)68 image_contents_t *diskcontents_read_unit9(const char *file_name)
69 {
70     return diskcontents_read(file_name, 9, 0);
71 }
72 
diskcontents_read_unit10(const char * file_name)73 image_contents_t *diskcontents_read_unit10(const char *file_name)
74 {
75     return diskcontents_read(file_name, 10, 0);
76 }
77 
diskcontents_read_unit11(const char * file_name)78 image_contents_t *diskcontents_read_unit11(const char *file_name)
79 {
80     return diskcontents_read(file_name, 11, 0);
81 }
82