Skip to content

Commit 8a2902b

Browse files
committed
remove exclude list for unzip
1 parent 0b8f319 commit 8a2902b

1 file changed

Lines changed: 4 additions & 23 deletions

File tree

src/Compress.ts

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export type SevenZipUnzipExcludeList = { name: string, recurse?: boolean }[];
4040
export class SevenZipper {
4141

4242
static readonly MaxStep = 18;
43+
static readonly ExcludeCmdSep = platform.osType() == 'win32' ? '!' : '\\!';
4344

4445
private _7za: File;
4546
private _event: events.EventEmitter;
@@ -59,7 +60,7 @@ export class SevenZipper {
5960
}
6061
}
6162

62-
Unzip(zipFile: File, outDir?: File, excList?: SevenZipUnzipExcludeList): Promise<Error | null> {
63+
Unzip(zipFile: File, outDir?: File): Promise<Error | null> {
6364

6465
if (!zipFile.IsFile()) {
6566
throw new Error('\'' + zipFile.path + '\' is not exist');
@@ -74,16 +75,6 @@ export class SevenZipper {
7475
paramList.push('-aoa');
7576
paramList.push(zipFile.path);
7677

77-
if (excList) {
78-
for (const exclude of excList) {
79-
if (exclude.recurse) {
80-
paramList.push(`-xr!${exclude.name.trim()}`);
81-
} else {
82-
paramList.push(`-x!${exclude.name.trim()}`);
83-
}
84-
}
85-
}
86-
8778
const outPath = (outDir ? outDir.path : zipFile.dir);
8879
paramList.push('-o' + outPath);
8980

@@ -121,7 +112,7 @@ export class SevenZipper {
121112
});
122113
}
123114

124-
UnzipSync(zipFile: File, outDir?: File, excList?: SevenZipUnzipExcludeList): string {
115+
UnzipSync(zipFile: File, outDir?: File): string {
125116

126117
if (!zipFile.IsFile()) {
127118
throw new Error('\'' + zipFile.path + '\' is not exist');
@@ -134,16 +125,6 @@ export class SevenZipper {
134125
paramList.push('-aoa');
135126
paramList.push(zipFile.path);
136127

137-
if (excList) {
138-
for (const exclude of excList) {
139-
if (exclude.recurse) {
140-
paramList.push(`-xr!${exclude.name.trim()}`);
141-
} else {
142-
paramList.push(`-x!${exclude.name.trim()}`);
143-
}
144-
}
145-
}
146-
147128
const outPath = (outDir ? outDir.path : zipFile.dir);
148129
paramList.push('-o' + outPath);
149130

@@ -174,7 +155,7 @@ export class SevenZipper {
174155

175156
if (option.excludeList) {
176157
for (let excludeReg of option.excludeList) {
177-
paramList.push('-xr!' + excludeReg.trim());
158+
paramList.push('-xr' + SevenZipper.ExcludeCmdSep + excludeReg.trim());
178159
}
179160
}
180161

0 commit comments

Comments
 (0)