我有一个文件夹,我使用共享链接(不是公共链接)和卷曲从Dropbox下载.它作为压缩文件夹下载.我需要在bash shell脚本中使用unzip解压缩此文件夹.每当文件夹解压缩时,我都会收到以下错误:
warning: stripped absolute path spec from /
mapname: conversion of failed
Run Code Online (Sandbox Code Playgroud)
为了确保卷曲不是一个奇怪的问题,我直接从Dropbox下载了文件夹并再次尝试.我得到了同样的错误.显示所有文件和子目录,并且它们的完整性似乎没有任何问题.使用GUI解压缩任一文件夹不会导致错误消息.
我运行unzip -l并注意到一个奇怪的第一个条目:
Length Method Size Ratio Date Time CRC-32 Name
-------- ------ ------- ----- ---- ---- ------ ----
0 Defl:N 2 0% 01-23-14 19:38 00000000 /
Run Code Online (Sandbox Code Playgroud)
我相信这是一个导致问题的空目录.我的问题是,有没有办法忽略这个空目录或抑制错误消息(我试过-qq没有运气)?或者,有什么东西我做错了/缺少?
我已经测试了这个Mac OSX 10.9.1并且Ubuntu Linux (Version Unknown)得到了相同的结果.
编辑:我也测试了它,jar xf它工作正常,没有任何错误.跑步jar xvf表明它created: /.我仍然认为这是一个空的,未命名的目录导致问题,但我似乎无法正确使用我的语法,因此解压缩将忽略它.我只想使用jar,但我需要能够指定输出目录.
我有兴趣了解是否有任何方法可以使用 PHP 和/或 Java 中的标准例程来控制 zip 文件中文件的排序顺序。
我主要对使用 zip/unzip usingshell_exec()或类似方法不感兴趣,但如果它提供了一个易于阅读的解决方案,它可能会引起人们的兴趣。
使用排序顺序,如果 zip 文件中没有可用的排序顺序,则可以安全地假设它表示日期/时间。我没有阅读规格,所以我不知道。
文件
foo.txt
bar.txt
test.txt
newfile.txt
假设每个文件都包含文件名 (foo.txt => foo.txt)
问题
我想为文件附加一个排序顺序,以便在使用unzip文件解压缩时以正确的顺序结束。这很重要,为什么?因为我使用unzip -p管道传输 zip 文件的内容。
将文件添加到存档的顺序应该无关紧要。
结果
预期结果(为了这个例子(使用 unzip -p))
test.txt
foo.txt
newfile.txt
bar.txt
我正在编写一个ant build.xml文件,它执行以下操作:
build.xml中的代码摘录:
<!-- Unzip SDK to a temporary directory -->
<unzip src="${zipFile}" dest="tmp"/>
<!-- pull in the files from another directory -->
<copy todir="tmp/someDirectory" >
<fileset dir="${addedFiles}" />
</copy>
<!-- Zip up modified SDK -->
<zip destfile="${destDir}" basedir="tmp"/>
Run Code Online (Sandbox Code Playgroud)
除了在运行ant构建之前为压缩文件设置的权限在ant构建创建的zip文件中丢失之外,这一切都很有效.例如,以前可执行的文件不再是.
所以我的问题是:是否可以使用ant将文件添加到zip存档而不破坏已存在文件的权限?
我正在使用Ant 1.7.1
我想在我的程序中做这样的事情:
File zipFile = .....;
File destDir = ....;
ImaginaryZipUtility.unzipAllTo(zipFile, destdir);
Run Code Online (Sandbox Code Playgroud)
我不可能是第一个从程序中做到这一点的人.我在哪里找到像上面这样的实用方法?我试着看看apache commons-io,但没有.那么,我应该在哪里看?
我有一个简单的代码来提取zip文件,它正常工作正常,但在我的测试期间我尝试了我的代码与一些zip文件(我从互联网上下载的字体,图标和模板)只是为了确保它应该提取任何zip文件提供,但它不使用一些zip文件,这里是重新生成此问题的最小化代码:
package com.test.mytest;
import java.io.FileInputStream;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipInputStream;
public class ZipExtractTest {
public static final String ZIP_FILE = "/Users/XXXXX/Downloads/janne.zip";
public static void main(String[]args) {
unzipFile(ZIP_FILE);
unzipStream(ZIP_FILE);
}
public static void unzipFile(String zipName) {
try {
ZipFile zf = new ZipFile(zipName);
Enumeration ent = zf.entries();
while(ent.hasMoreElements()) {
System.out.println(ent.nextElement());
}
} catch(Exception e) {
System.out.println(e);
}
}
public static void unzipStream(String zipName) {
try {
ZipInputStream zis = new ZipInputStream(new FileInputStream(zipName));
ZipEntry ze = zis.getNextEntry();
if(ze == …Run Code Online (Sandbox Code Playgroud) 我在路径"C:\ ptc\Windchill_10.1\Windchill"中有一个zip文件.请任何人都可以告诉我如何使用maven解压缩此文件
我使用以下开源解压缩文件及其工作正如预期的拉链大小2-5 MB,但当我把zip放在10多MB上我有错误,有更稳定的开源我可以用于大型zip文件?我需要它在MIT许可下.这就是我用过的 https://github.com/EvanOxfeld/node-unzip
var extractor = unzip.Extract({ path: "../"});
extractor.on("close", function() {
console.log("Success unzip");
});
extractor.on("close", function(err) {
console.log(err);
});
req.pipe(extractor);
Run Code Online (Sandbox Code Playgroud) 我有一个zip文件,其中包含三个zip文件,如下所示:
zipfile.zip\
dirA.zip\
a
dirB.zip\
b
dirC.zip\
c
Run Code Online (Sandbox Code Playgroud)
我想在具有这些名称(dirA,dirB,dirC)的目录中提取zip文件中的所有内部zip文件.
基本上,我想最终得到以下架构:
output\
dirA\
a
dirB\
b
dirC\
c
Run Code Online (Sandbox Code Playgroud)
我尝试过以下方法:
import os, re
from zipfile import ZipFile
os.makedirs(directory) # where directory is "\output"
with ZipFile(self.archive_name, "r") as archive:
for id, files in data.items():
if files:
print("Creating", id)
dirpath = os.path.join(directory, id)
os.mkdir(dirpath)
for file in files:
match = pattern.match(filename)
new = match.group(2)
new_filename = os.path.join(dirpath, new)
content = archive.open(file).read()
with open(new_filename, "wb") as outfile:
outfile.write(content)
Run Code Online (Sandbox Code Playgroud)
但它只提取zip文件,我最终得到:
output\
dirA\
dirA.zip
dirB\
dirB.zip
dirC\ …Run Code Online (Sandbox Code Playgroud) 如何在Goolge Cloud Storage Bucket中解压缩.zip文件?(如果我们有一些其他工具,比如AWS的'CloudBerry Explorer',那就太好了.)
大部分信息在网上查到说,这可能是与完成unzip(1),但遗憾的是它不一样了,.ipa文件格式已经改变,unzip -v xyz.ipa:
Length Method Size Cmpr Date Time CRC-32 Name
-------- ------ ------- ---- ---------- ----- -------- ----
0 Stored 0 0% 09-18-2018 15:38 00000000 META-INF/
379 Unk:099 367 3% 09-19-2018 08:44 bf0c5de5 META-INF/com.apple.ZipMetadata.plist
23 Stored 23 0% 09-19-2018 08:44 132aa79c META-INF/com.apple.FixedZipMetadata.bin
0 Stored 0 0% 09-18-2018 15:36 00000000 Payload/
0 Stored 0 0% 09-19-2018 23:44 00000000 Payload/xyz.app/
0 Stored 0 0% 09-18-2018 15:36 00000000 Payload/xyz.app/_CodeSignature/
358128 Unk:099 84505 76% 09-19-2018 23:44 7f51c7bf Payload/xyz.app/_CodeSignature/CodeResources
10131 …Run Code Online (Sandbox Code Playgroud)