Changeset 234


Ignore:
Timestamp:
03/22/07 20:58:37 (17 years ago)
Author:
r2d
Message:
  • mpc2sv8 doesn't overwrite output file anymore
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libmpc/branches/r2d/mpc2sv8/mpc2sv8.c

    r233 r234  
    103103
    104104        if (si.stream_version >= 8) {
    105                 fprintf(stderr, "Error : this file is already a sv8 file\n");
    106                 mpc_demux_exit(demux);
    107                 mpc_reader_exit_stdio(&reader);
    108                 return MPC_STATUS_INVALIDSV;
     105                fprintf(stderr, "Error : the file \"%s\" is already a sv8 file\n", argv[1]);
     106                exit(MPC_STATUS_INVALIDSV);
    109107        }
    110108
    111109        mpc_encoder_init(&e, si.samples, 6, 1);
     110        e.outputFile = fopen( argv[2], "rb" );
     111        if ( e.outputFile != 0 ) {
     112                fprintf(stderr, "Error : output file \"%s\" already exists\n", argv[2]);
     113                exit(MPC_STATUS_FILE);
     114        }
    112115        e.outputFile = fopen( argv[2], "w+b" );
    113116        e.MS_Channelmode = si.ms;
     
    120123                size_t tmp_size = fread(buf, 1, mini(TMP_BUF_SIZE, r_size), in_file);
    121124                if (fwrite(buf, 1, tmp_size, e.outputFile) != tmp_size) {
    122                         fprintf(stderr, "Error writing to target file\n");
    123                         exit(!MPC_STATUS_OK);
     125                        fprintf(stderr, "Error writing to target file : \"%s\"\n", argv[2]);
     126                        exit(MPC_STATUS_FILE);
    124127                }
    125128                r_size -= tmp_size;
Note: See TracChangeset for help on using the changeset viewer.