fork of PCE focusing on macplus, supporting DaynaPort SCSI network emulation
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

psi: Support multiple output files

Instead of writing the image to the last output file
specified on the command line, it is now written to
every output file.

+24 -24
+21 -20
src/utils/psi/main.c
··· 91 91 { 'm', 1, "merge", "filename", "Merge an image" }, 92 92 { 'n', 1, "new-dos", "size", "Create a standard image of <size> KiB" }, 93 93 { 'N', 2, "new", "type size", "Create a standard image of <size> KiB" }, 94 - { 'o', 1, "output", "filename", "Set the output file name [none]" }, 94 + { 'o', 1, "output", "filename", "Save to an output file [none]" }, 95 95 { 'O', 1, "output-format", "format", "Set the output format [auto]" }, 96 96 { 'p', 1, "operation", "name [...]", "Perform an operation" }, 97 97 { 'r', 3, "record", "c h s", "Select sectors [all all all]" }, ··· 111 111 { 112 112 pce_getopt_help ( 113 113 "psi: convert and modify PCE sector image files", 114 - "usage: psi [options] [input] [options] [output]", 114 + "usage: psi [options] [input] [options] [output...]", 115 115 opts 116 116 ); 117 117 ··· 601 601 } 602 602 603 603 static 604 - int psi_save_image (psi_img_t *img, const char *fname) 604 + int psi_save_image (psi_img_t **img, const char *fname) 605 605 { 606 606 int r; 607 607 unsigned fmt; ··· 610 610 fprintf (stderr, "%s: save image to %s\n", arg0, fname); 611 611 } 612 612 613 + if (*img == NULL) { 614 + *img = psi_img_new(); 615 + 616 + if (*img == NULL) { 617 + return (1); 618 + } 619 + } 620 + 613 621 if (strcmp (fname, "-") == 0) { 614 622 fmt = par_fmt_out; 615 623 ··· 617 625 fmt = PSI_FORMAT_PSI; 618 626 } 619 627 620 - r = psi_save_fp (stdout, img, fmt); 628 + r = psi_save_fp (stdout, *img, fmt); 621 629 } 622 630 else { 623 - r = psi_save (fname, img, par_fmt_out); 631 + r = psi_save (fname, *img, par_fmt_out); 624 632 } 625 633 626 634 if (r) { ··· 711 719 int r; 712 720 char **optarg; 713 721 psi_img_t *img; 714 - const char *out; 715 722 716 723 arg0 = argv[0]; 717 724 718 725 img = NULL; 719 - out = NULL; 720 726 721 727 while (1) { 722 728 r = pce_getopt (argc, argv, &optarg, opts); ··· 857 863 break; 858 864 859 865 case 'o': 860 - out = optarg[0]; 866 + if (psi_save_image (&img, optarg[0])) { 867 + return (1); 868 + } 861 869 break; 862 870 863 871 case 'O': ··· 933 941 return (1); 934 942 } 935 943 } 936 - else if (out == NULL) { 937 - out = optarg[0]; 938 - } 939 944 else { 940 - fprintf (stderr, "%s: unknown option (%s)\n", 941 - arg0, optarg[0] 942 - ); 943 - 944 - return (1); 945 + if (psi_save_image (&img, optarg[0])) { 946 + return (1); 947 + } 945 948 } 946 949 break; 947 950 ··· 950 953 } 951 954 } 952 955 953 - if ((img != NULL) && (out != NULL)) { 954 - if (psi_save_image (img, out)) { 955 - return (1); 956 - } 956 + if (img != NULL) { 957 + psi_img_del (img); 957 958 } 958 959 959 960 return (0);
+3 -4
src/utils/psi/psi.1
··· 1 - .TH PSI 1 "2023-11-30" "HH" "pce" 1 + .TH PSI 1 "2024-01-20" "HH" "pce" 2 2 \ 3 3 .SH NAME 4 4 psi \- convert and modify PCE sector image files 5 5 6 6 .SH SYNOPSIS 7 - .BI psi " [options] [input-file] [options] [output-file]" 7 + .BI psi " [options] [input-file] [options] [output-file...]" 8 8 9 9 .SH DESCRIPTION 10 10 \fBpsi\fR(1) is used to modify and convert sector images ··· 186 186 \ 187 187 .TP 188 188 .BI "-o, --output " filename 189 - Set the output file name. Before exiting, the current image will 190 - be written to this file. 189 + Write the current image to the output file \fIfilename\fR. 191 190 \ 192 191 .TP 193 192 .BI "-O, --output-format " format