파일 이름이 없거나 파일 사이즈가 없는 건 받지 않음

pull/540/head
root 2021-11-26 17:55:20 +00:00
parent 68791fb077
commit 9bc679591e
1 changed files with 14 additions and 1 deletions

View File

@ -35,8 +35,15 @@ int main(int argc, char *argv[])
filename = argv[1];
fd = open(filename, O_RDONLY);
if (fd < 0)
if(filename == NULL)
{
printf("file: "__FILE__", line: %d, " \
"open filename %s fail, " \
"errno: %d, error info: %s\n",\
__LINE__,filename, errno, STRERROR(errno));
return errno != 0 ? errno : EACCES;
}
if (fd < 0) {
printf("file: "__FILE__", line: %d, " \
"open file %s fail, " \
"errno: %d, error info: %s\n", \
@ -66,7 +73,13 @@ int main(int argc, char *argv[])
crc32 = CRC32_XINIT;
result = 0;
if(file_size<0)
{
close(fd);
return errno;
}
remain_bytes = file_size;
while (remain_bytes > 0)
{
if (remain_bytes > sizeof(buff))