2 * Written 1999 Jan 29 by Josh Cogliati
3 * I grant this program to public domain.
5 * Modified for mvl by Bradley Bell, 2002
6 * All modifications under GPL, version 2 or later
12 #include <sys/types.h>
20 main(int argc, char *argv[])
22 FILE *mvlfile, *readfile;
25 int i, nfiles = 0, len[MAX_FILES];
26 char filename[MAX_FILES][13];
31 printf("Usage: mvlcreate mvlfile\n"
32 "creates mvlfile using all the files in the current directory\n");
38 while ((ep = readdir(dp))) {
39 strcpy(filename[nfiles], ep->d_name);
40 stat(filename[nfiles], &statbuf);
41 if(! S_ISDIR(statbuf.st_mode)) {
42 len[nfiles] = (int)statbuf.st_size;
43 printf("Filename: %s \tLength: %i\n", filename[nfiles], len[nfiles]);
50 printf("Creating: %s\n", argv[1]);
51 mvlfile = fopen(argv[1], "w");
52 buf = (char *)malloc(4);
53 strncpy(buf, "DMVL", 4);
54 fwrite(buf, 4, 1, mvlfile);
57 fwrite(&nfiles, 4, 1, mvlfile);
59 for (i = 0; i < nfiles; i++) {
60 fwrite(filename[i], 13, 1, mvlfile);
61 fwrite(&len[i], 4, 1, mvlfile);
64 for (i = 0; i < nfiles; i++) {
65 readfile = fopen(filename[i], "r");
66 buf = (char *)malloc(len[i]);
68 printf("Unable to allocate memory\n");
70 fread(buf, len[i], 1, readfile);
71 fwrite(buf, len[i], 1, mvlfile);