【源码】仅根据后缀名 武断的地判断

[root@a tmp]# rm -f ./*
[root@a tmp]# echo 123 > t.bz2
[root@a tmp]# ll -as
total 12
4 drwxr-xr-x 2 root root 4096 Jan 11 14:59 .
4 drwxr-xr-x 17 root root 4096 Jan 10 16:51 ..
4 -rw-r--r-- 1 root root 4 Jan 11 14:59 t.bz2
[root@a tmp]# bzip2 -9 t.bz2
bzip2: Input file t.bz2 already has .bz2 suffix.
[root@a tmp]#

 

https://github.com/kjn/lbzip2/blob/8702655221f8e9cd488beb9572294baa734d2d09/src/main.c#L611

 

for (i = 0; i < BZ_N_SUFFIX_PAIRS; i++) {
if (hasSuffix(inName, zSuffix[i])) {
if (noisy)
fprintf ( stderr,
"%s: Input file %s already has %s suffix.\n",
progName, inName, zSuffix[i] );
setExit(1);
return;
}
}

 

posted @ 2019-01-11 14:39  papering  阅读(201)  评论(0编辑  收藏  举报