From 0a43046c9dd6ba78aff7014c63482ccf26642d73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Sun, 1 May 2022 00:07:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20perror=20=E8=BE=93?= =?UTF-8?q?=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base16384.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/base16384.c b/base16384.c index e5052a0..d901dd0 100644 --- a/base16384.c +++ b/base16384.c @@ -34,12 +34,12 @@ static int encode_file(const char* input, const char* output) { fp = stdin; } else inputsize = get_file_size(input); if(inputsize < 0) { - perror("Get file size error: "); + perror("Get file size error"); return 1; } fpo = (*(uint16_t*)output == *(uint16_t*)"-")?stdout:fopen(output, "wb"); if(!fpo) { - perror("Fopen output file error: "); + perror("Fopen output file error"); return 2; } if(!inputsize || inputsize > BUFSIZ*1024) { // stdin or big file, use encbuf & fread @@ -49,7 +49,7 @@ static int encode_file(const char* input, const char* output) { #endif if(!fp) fp = fopen(input, "rb"); if(!fp) { - perror("Fopen input file error: "); + perror("Fopen input file error"); return 3; } @@ -60,7 +60,7 @@ static int encode_file(const char* input, const char* output) { while((cnt = fread(encbuf, sizeof(char), inputsize, fp))) { int n = encode(encbuf, cnt, decbuf, outputsize); if(fwrite(decbuf, n, 1, fpo) <= 0) { - perror("Write file error: "); + perror("Write file error"); return 4; } } @@ -72,12 +72,12 @@ static int encode_file(const char* input, const char* output) { } else { // small file, use mmap & fwrite int fd = open(input, O_RDONLY); if(fd <= 0) { - perror("Open input file error: "); + perror("Open input file error"); return 5; } char *input_file = mmap(NULL, (size_t)inputsize, PROT_READ, MAP_PRIVATE, fd, 0); if(input_file == MAP_FAILED) { - perror("Map input file error: "); + perror("Map input file error"); return 6; } int outputsize = encode_len(inputsize)+16; @@ -85,7 +85,7 @@ static int encode_file(const char* input, const char* output) { fputc(0xFF, fpo); int n = encode(input_file, (int)inputsize, decbuf, outputsize); if(fwrite(decbuf, n, 1, fpo) <= 0) { - perror("Write file error: "); + perror("Write file error"); return 7; } munmap(input_file, (size_t)inputsize); @@ -122,12 +122,12 @@ static int decode_file(const char* input, const char* output) { fp = stdin; } else inputsize = get_file_size(input); if(inputsize < 0) { - perror("Get file size error: "); + perror("Get file size error"); return 1; } fpo = (*(uint16_t*)output == *(uint16_t*)"-")?stdout:fopen(output, "wb"); if(!fpo) { - perror("Fopen output file error: "); + perror("Fopen output file error"); return 2; } if(!inputsize || inputsize > BUFSIZ*1024) { // stdin or big file, use decbuf & fread @@ -137,7 +137,7 @@ static int decode_file(const char* input, const char* output) { #endif if(!fp) fp = fopen(input, "rb"); if(!fp) { - perror("Fopen input file error: "); + perror("Fopen input file error"); return 3; } int outputsize = decode_len(inputsize, 0)+16; @@ -150,7 +150,7 @@ static int decode_file(const char* input, const char* output) { decbuf[cnt++] = end; } if(fwrite(encbuf, decode(decbuf, cnt, encbuf, outputsize), 1, fpo) <= 0) { - perror("Write file error: "); + perror("Write file error"); return 4; } } @@ -162,18 +162,18 @@ static int decode_file(const char* input, const char* output) { } else { // small file, use mmap & fwrite int fd = open(input, O_RDONLY); if(fd <= 0) { - perror("Open input file error: "); + perror("Open input file error"); return 5; } char *input_file = mmap(NULL, (size_t)inputsize, PROT_READ, MAP_PRIVATE, fd, 0); if(input_file == MAP_FAILED) { - perror("Map input file error: "); + perror("Map input file error"); return 6; } int outputsize = decode_len(inputsize, 0)+16; int off = skip_offset(input_file); if(fwrite(encbuf, decode(input_file+off, inputsize-off, encbuf, outputsize), 1, fpo) <= 0) { - perror("Write file error: "); + perror("Write file error"); return 7; } munmap(input_file, (size_t)inputsize);