mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-22 01:57:12 -05:00
feat: Add zipRoot()
Get root directory path inside ZIP file
This commit is contained in:
parent
debbdc7276
commit
f9dc0a7fb6
@ -140,6 +140,36 @@ archAffix(){
|
||||
return 0
|
||||
}
|
||||
|
||||
zipRoot() {
|
||||
unzip -lqq "$1" | awk -e '
|
||||
NR == 1 {
|
||||
prefix = $4;
|
||||
}
|
||||
NR != 1 {
|
||||
prefix_len = length(prefix);
|
||||
cur_len = length($4);
|
||||
|
||||
for (len = prefix_len < cur_len ? prefix_len : cur_len; len >= 1; len -= 1) {
|
||||
sub_prefix = substr(prefix, 1, len);
|
||||
sub_cur = substr($4, 1, len);
|
||||
|
||||
if (sub_prefix == sub_cur) {
|
||||
prefix = sub_prefix;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (len == 0) {
|
||||
prefix = "";
|
||||
nextfile;
|
||||
}
|
||||
}
|
||||
END {
|
||||
print prefix;
|
||||
}
|
||||
'
|
||||
}
|
||||
|
||||
downloadV2Ray(){
|
||||
rm -rf /tmp/v2ray
|
||||
mkdir -p /tmp/v2ray
|
||||
|
Loading…
Reference in New Issue
Block a user