home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <fcntl.h>
- #include <osbind.h>
-
- int size = 0;
- int fd, s = 0, s_max = 512 * 9 * 2 * 80;
- int track = 0, side = 0;
- int block=0;
- char buf[5120];
- long total_size = 0;
-
- int
- main(argc,argv)
- int argc;
- char *argv[];
- {
- puts("Insert raw disk in drive A. Hit CR to create file D:\\A.TAR\n");
- getchar();
- fd = open("D:\\A.TAR", O_WRONLY | O_CREAT | O_BINARY);
- if (!fd)
- fatal_error("Cannot open file D:\\A.TAR\n");
- for (;;) {
- if(convert_track(1, 0)) break;
- if(convert_track(0, 1)) break;
- }
- close(fd);
- printf("%ld bytes written. Hit CR to exit.\n", total_size);
- getchar();
- return 0;
- }
-
- convert_track(next_side, incr_track)
- int next_side, incr_track;
- {
- char mess[80];
-
- if (Floprd(buf, 0L, 0, 1, track, side, 9)) {
- sprintf(mess, "error reading track %d, side %d\n", track, side);
- fatal_error(mess);
- }
- block = print_names(block, s, s +9 < s_max ? s+9 : s_max);
- side = next_side; s += 9; track += incr_track;
- if (s >= s_max) {
- write_buf(s_max - (s - 9));
- return 1;
- } else {
- write_buf(9);
- return 0;
- }
- }
-
- write_buf(size)
- int size;
- {
- int written_size = write(fd, buf, 512 * size);
- if (written_size != 512 * size)
- fatal_error("No more room left on drive D:!\n");
- total_size += written_size;
- }
-
- int print_names(block, s, s_end)
- int block, s, s_end;
- {
- /* printf("Block %d, s = %d, s_end = %d\n", block,s,s_end); */
- while (block >= s && block < s_end) {
- if (buf[(block-s) * 512] == '\0') {
- /* end of tape reached */
- printf("End of file at block %d\n", block);
- s_max = block;
- block = -1;
- } else {
- long size;
- sscanf(buf + (block-s) * 512 + 124, " %lo", &size);
- printf("Block %d: %.100s %ld\n", block, buf + (block-s) * 512, size);
- if (size)
- block = block + 2 + (int) ((size - 1)/ 512);
- else
- block++;
- }
- }
- return block;
- }
-
- fatal_error(s)
- char *s;
- {
- puts(s);
- puts("\007Aborting... Press CR\n");
- getchar();
- exit(1);
- }
-