Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <unistd.h>
- int main(){
- int rc = 0;
- FILE *inc = NULL;
- FILE *out = NULL;
- char *incname = "./some.wav";
- char *outname = "./out.wav";
- if( access(incname, R_OK) == -1) {
- printf("E: no readable file '%s' was found\n", incname);
- rc = 1;
- goto safe_fail;
- }
- if( access(outname, F_OK) != -1) {
- printf("E: file '%s' already exists\n", outname);
- rc = 2;
- goto safe_fail;
- }
- inc = fopen(incname, "rb");
- int seekrc = fseek(inc, 0L, SEEK_END);
- if(seekrc != 0){
- printf("E: seek on '%s' failed\n", incname);
- rc = seekrc;
- goto safe_fail;
- }
- long inclen = ftell(inc);
- rewind(inc);
- seekrc = fseek(inc, 44L, SEEK_SET);
- if(seekrc != 0){
- printf("E: seek on '%s' failed\n", incname);
- rc = seekrc;
- goto safe_fail;
- }
- printf("I: len of '%s' is %ldB\n", incname, inclen);
- out = fopen(outname, "wb");
- int count = 0;
- int getrc = 0;
- while(getrc != EOF){
- getrc = fgetc(inc);
- if(count < 45){
- fputc(getrc, out);
- count++;
- continue;
- }
- fputc(getrc - 0, out);
- }
- safe_fail:
- if (inc != NULL) fclose(inc);
- if (out != NULL) fclose(out);
- return rc;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement