我正在使用归档器压缩两个文件夹x
和y
:
const out = ... // file write stream
...
const zip = archiver('zip', {});
zip.on('error', (err: Error) => { throw err; });
zip.pipe(out);
zip.directory('x', 'x');
zip.directory('y', 'y');
zip.finalize();
zip 文件还可以,但unzip -l
显示x
和y
交错。
(看起来像archiver
遍历x
和y
BFS 顺序)。
x/x1
x/x2
y/y1
y/y2
x/x1/x11.txt
x/x2/x21.txt
y/y1/y11.txt
我想压缩x
并y
以 DFS 顺序unzip -l
显示:
x/x1
x/x1/x11.txt
x/x2
x/x2/x21.txt
y/y1
y/y1/y11.txt
y/y2
如何控制压缩目录和文件的顺序?