1 /* Copyright 1997,2000-2002,2009,2011 Alain Knaff.
2 * This file is part of mtools.
4 * Mtools is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * Mtools is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with Mtools. If not, see <http://www.gnu.org/licenses/>.
18 * Copy an MSDOS files to and from Unix
23 #include "sysincludes.h"
27 #include "nameclash.h"
31 typedef struct Arg_t {
36 static int dos_showfat(direntry_t *entry, MainParam_t *mp)
38 Stream_t *File=mp->File;
39 Arg_t *arg = (Arg_t *) mp->arg;
40 fprintPwd(stdout, entry,0);
42 if(arg->offset == -1) {
45 printFatWithOffset(File, arg->offset);
51 static int unix_showfat(MainParam_t *mp UNUSEDP)
53 fprintf(stderr,"File does not reside on a Dos fs\n");
58 static void usage(int ret) NORETURN;
59 static void usage(int ret)
62 "Mtools version %s, dated %s\n", mversion, mdate);
64 "Usage: %s files\n", progname);
68 void mshowfat(int argc, char **argv, int mtype UNUSEDP) NORETURN;
69 void mshowfat(int argc, char **argv, int mtype UNUSEDP)
74 /* get command line options */
75 if(helpFlag(argc, argv))
78 while ((c = getopt(argc, argv, "i:ho:")) != EOF) {
81 arg.offset = str_to_offset(optarg);
84 set_cmd_line_image(optarg);
93 if (argc - optind < 1)
96 /* only 1 file to handle... */
98 arg.mp.arg = (void *) &arg;
100 arg.mp.callback = dos_showfat;
101 arg.mp.unixcallback = unix_showfat;
103 arg.mp.lookupflags = ACCEPT_PLAIN | ACCEPT_DIR | DO_OPEN;
104 ret=main_loop(&arg.mp, argv + optind, argc - optind);