스트리밍 텍스트를 압축한 다음 압축을 풀려고 합니다. 최소한의 예는 다음과 같습니다:
echo "Hey, could you zip this for me?" | zip hello.zip - ; unzip -p hello.zip
이 작업은 다음 출력과 함께 실패합니다.
warning [hello.zip]: 76 extra bytes at beginning or within zipfile
(attempting to process anyway)
error [hello.zip]: reported length of central directory is
-76 bytes too long (Atari STZip zipfile? J.H.Holm ZIPSPLIT 1.1
zipfile?). Compensating...
skipping: - need PK compat. v4.5 (can do v2.1)
note: didn't find end-of-central-dir signature at end of central dir.
(please check that you have transferred or created the zipfile in the
appropriate BINARY mode and that you have compiled UnZip properly)
나는 이것이 바이너리 모드에 대한 설명과 관련이 있다고 추측하지만 무엇인지 알 수 없으며 관련 매뉴얼 페이지/Google/StackExchange에서 어떤 도움도 찾을 수 없습니다. 나는 이 질문이 "파일 압축을 풀 때 추가 바이트 오류가 발생했습니다."오류 메시지는 동일하지만 질문은 기존 타사 파일 아카이브를 복구하는 것에 관한 반면, 이것은 방금 생성한 아카이브를 사용하는 것에 관한 것입니다.
버전 세부정보:
- OSX 10.10.4
- Info-ZIP의 Zip 3.0(2008년 7월 5일)
- UnZip 5.52, 2005년 2월 28일, Info-ZIP 제작
답변1
댓글을 토대로 이 답변 하단에서 이를 확인했습니다.
문제는 스트리밍 zip이 기본적으로 Zip64 형식으로 설정되지만 Zip64를 읽으려면 Decompression 6 이상이 필요하다는 것입니다. 매뉴얼에는 -fz-
입력이 4GB보다 작은 것으로 알려진 경우 Zip64 사용을 방지하는 데 사용할 수 있다고 명시되어 있지만 매뉴얼의 다른 곳에서는 명시적으로 문서화되어 있지 않습니다.
zip 매뉴얼에 명시되어 있고 압축 풀기 경고의 "(다음을 확인하십시오..." 섹션에 암시된 대로 <4GB zip 바이너리 형식을 강제하는 것은 기본적으로 zip 단계의 추가 출력에 적용됩니다. :
Daniels-Mini:~ dlamblin$ echo "Hey, could you zip this for me?" | zip -fz- hello.zip - ; unzip -p hello.zip
updating: - (stored 0%)
Hey, could you zip this for me?
흥미롭게도 zip은 필터처럼 파이프될 수 있지만 echo a|zip|cat
unzip은 표준 입력에서 작동하지 않으므로 이미 불일치가 있습니다. 이상하게도 echo a|zip a.zip -
같은 echo a|zip>b.zip
크기의 다른 파일이 생성됩니다. 이것은 나를 혼란스럽게 한다.
스트림을 필터로 압축 해제하기 위해 funzip
.
Daniels-Mini:~ dlamblin$ echo "Hey, could you zip this for me?" | zip |funzip
adding: - (deflated -5%)
Hey, could you zip this for me?
funzip error: invalid compressed data--length error
Daniels-Mini:~ dlamblin$ echo "Hey, could you zip this for me?" | zip -fz-|funzip
adding: - (deflated -5%)
Hey, could you zip this for me?
문제는 다음과 같이 확인됩니다.
Last login: Mon Aug 3 22:54:02 on ttys010
Daniels-Mini:~ dlamblin$ echo "Hey, could you zip this for me?" | zip hello.zip - ; unzip -p hello.zip
adding: - (stored 0%)
warning [hello.zip]: 76 extra bytes at beginning or within zipfile
(attempting to process anyway)
error [hello.zip]: reported length of central directory is
-76 bytes too long (Atari STZip zipfile? J.H.Holm ZIPSPLIT 1.1
zipfile?). Compensating...
note: didn't find end-of-central-dir signature at end of central dir.
(please check that you have transferred or created the zipfile in the
appropriate BINARY mode and that you have compiled UnZip properly)
Daniels-Mini:~ dlamblin$ zip --version
Copyright (c) 1990-2008 Info-ZIP - Type 'zip "-L"' for software license.
This is Zip 3.0 (July 5th 2008), by Info-ZIP.
Currently maintained by E. Gordon. Please send bug reports to
the authors using the web page at www.info-zip.org; see README for details.
Latest sources and executables are at ftp://ftp.info-zip.org/pub/infozip,
as of above date; see http://www.info-zip.org/ for other sites.
Compiled with gcc 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39) for Unix (Mac OS X) on Apr 30 2015.
Zip special compilation options:
USE_EF_UT_TIME (store Universal Time)
SYMLINK_SUPPORT (symbolic links supported)
LARGE_FILE_SUPPORT (can read and write large files on file system)
ZIP64_SUPPORT (use Zip64 to store large files in archives)
STORE_UNIX_UIDs_GIDs (store UID/GID sizes/values using new extra field)
UIDGID_16BIT (old Unix 16-bit UID/GID extra field also used)
[encryption, version 2.91 of 05 Jan 2007] (modified for Zip 3)
Encryption notice:
The encryption code of this program is not copyrighted and is
put in the public domain. It was originally written in Europe
and, to the best of our knowledge, can be freely distributed
in both source and object forms from any country, including
the USA under License Exception TSU of the U.S. Export
Administration Regulations (section 740.13(e)) of 6 June 2002.
Zip environment options:
ZIP: [none]
ZIPOPT: [none]
Daniels-Mini:~ dlamblin$ unzip --version
caution: both -n and -o specified; ignoring -o
UnZip 5.52 of 28 February 2005, by Info-ZIP. Maintained by C. Spieler. Send
bug reports using http://www.info-zip.org/zip-bug.html; see README for details.
Usage: unzip [-Z] [-opts[modifiers]] file[.zip] [list] [-x xlist] [-d exdir]
Default action is to extract files in list, except those in xlist, to exdir;
file[.zip] may be a wildcard. -Z => ZipInfo mode ("unzip -Z" for usage).
-p extract files to pipe, no messages -l list files (short format)
-f freshen existing files, create none -t test compressed archive data
-u update files, create if necessary -z display archive comment
-x exclude files that follow (in xlist) -d extract files into exdir
modifiers: -q quiet mode (-qq => quieter)
-n never overwrite existing files -a auto-convert any text files
-o overwrite files WITHOUT prompting -aa treat ALL files as text
-j junk paths (do not make directories) -v be verbose/print version info
-C match filenames case-insensitively -L make (some) names lowercase
-X restore UID/GID info -V retain VMS version numbers
-K keep setuid/setgid/tacky permissions -M pipe through "more" pager
Examples (see unzip.txt for more info):
unzip data1 -x joe => extract all files except joe from zipfile data1.zip
unzip -p foo | more => send contents of foo.zip via pipe into program more
unzip -fo foo ReadMe => quietly replace existing ReadMe if archive file newer