@@ -29,7 +29,14 @@ public struct ZipArchiver: Archiver, Cancellable {
29
29
30
30
/// Absolute path to the Windows tar in the system folder
31
31
#if os(Windows)
32
- private let windowsTar : String
32
+ internal let windowsTar : String
33
+ #else
34
+ internal let unzip = " unzip "
35
+ internal let zip = " zip "
36
+ #endif
37
+
38
+ #if os(FreeBSD)
39
+ internal let tar = " tar "
33
40
#endif
34
41
35
42
/// Creates a `ZipArchiver`.
@@ -74,7 +81,9 @@ public struct ZipArchiver: Archiver, Cancellable {
74
81
// It's part of system32 anyway so use the absolute path.
75
82
let process = AsyncProcess ( arguments: [ windowsTar, " xf " , archivePath. pathString, " -C " , destinationPath. pathString] )
76
83
#else
77
- let process = AsyncProcess ( arguments: [ " unzip " , archivePath. pathString, " -d " , destinationPath. pathString] )
84
+ let process = AsyncProcess ( arguments: [
85
+ self . unzip, archivePath. pathString, " -d " , destinationPath. pathString,
86
+ ] )
78
87
#endif
79
88
guard let registrationKey = self . cancellator. register ( process) else {
80
89
throw CancellationError . failedToRegisterProcess ( process)
@@ -113,7 +122,10 @@ public struct ZipArchiver: Archiver, Cancellable {
113
122
// On FreeBSD, the unzip command is available in base but not the zip command.
114
123
// Therefore; we use libarchive(bsdtar) to produce the ZIP archive instead.
115
124
let process = AsyncProcess (
116
- arguments: [ " tar " , " -c " , " --format " , " zip " , " -f " , destinationPath. pathString, directory. basename] ,
125
+ arguments: [
126
+ self . tar, " -c " , " --format " , " zip " , " -f " , destinationPath. pathString,
127
+ directory. basename,
128
+ ] ,
117
129
workingDirectory: directory. parentDirectory
118
130
)
119
131
#else
@@ -127,7 +139,7 @@ public struct ZipArchiver: Archiver, Cancellable {
127
139
arguments: [
128
140
" /bin/sh " ,
129
141
" -c " ,
130
- " cd \( directory. parentDirectory. underlying. pathString) && zip -ry \( destinationPath. pathString) \( directory. basename) " ,
142
+ " cd \( directory. parentDirectory. underlying. pathString) && \( self . zip) -ry \( destinationPath. pathString) \( directory. basename) "
131
143
]
132
144
)
133
145
#endif
@@ -154,7 +166,7 @@ public struct ZipArchiver: Archiver, Cancellable {
154
166
#if os(Windows)
155
167
let process = AsyncProcess ( arguments: [ windowsTar, " tf " , path. pathString] )
156
168
#else
157
- let process = AsyncProcess ( arguments: [ " unzip " , " -t " , path. pathString] )
169
+ let process = AsyncProcess ( arguments: [ self . unzip, " -t " , path. pathString] )
158
170
#endif
159
171
guard let registrationKey = self . cancellator. register ( process) else {
160
172
throw CancellationError . failedToRegisterProcess ( process)
0 commit comments