@@ -66,7 +66,7 @@ public class Zip {
66
66
}
67
67
68
68
#if os(Windows)
69
- var fileNames = Set < String > ( )
69
+ var fileNames = Set < String > ( )
70
70
#endif
71
71
72
72
var buffer = [ CUnsignedChar] ( repeating: 0 , count: 4096 )
@@ -101,23 +101,23 @@ public class Zip {
101
101
var pathString = String ( cString: fileName)
102
102
103
103
#if os(Windows)
104
- // Windows Reserved Characters
105
- let reservedCharacters : CharacterSet = [ " < " , " > " , " : " , " \" " , " | " , " ? " , " * " ]
106
-
107
- if pathString. rangeOfCharacter ( from: reservedCharacters) != nil {
108
- pathString = pathString. components ( separatedBy: reservedCharacters) . joined ( separator: " _ " )
109
-
110
- let pathExtension = ( pathString as NSString ) . pathExtension
111
- let pathWithoutExtension = ( pathString as NSString ) . deletingPathExtension
112
- var counter = 1
113
- while fileNames. contains ( pathString) {
114
- let newFileName = " \( pathWithoutExtension) ( \( counter) ) "
115
- pathString = pathExtension. isEmpty ? newFileName : newFileName. appendingPathExtension ( pathExtension) ?? newFileName
116
- counter += 1
117
- }
104
+ // Windows Reserved Characters
105
+ let reservedCharacters : CharacterSet = [ " < " , " > " , " : " , " \" " , " | " , " ? " , " * " ]
106
+
107
+ if pathString. rangeOfCharacter ( from: reservedCharacters) != nil {
108
+ pathString = pathString. components ( separatedBy: reservedCharacters) . joined ( separator: " _ " )
109
+
110
+ let pathExtension = ( pathString as NSString ) . pathExtension
111
+ let pathWithoutExtension = ( pathString as NSString ) . deletingPathExtension
112
+ var counter = 1
113
+ while fileNames. contains ( pathString) {
114
+ let newFileName = " \( pathWithoutExtension) ( \( counter) ) "
115
+ pathString = pathExtension. isEmpty ? newFileName : newFileName. appendingPathExtension ( pathExtension) ?? newFileName
116
+ counter += 1
118
117
}
118
+ }
119
119
120
- fileNames. insert ( pathString)
120
+ fileNames. insert ( pathString)
121
121
#endif
122
122
123
123
guard !pathString. isEmpty else {
@@ -136,16 +136,11 @@ public class Zip {
136
136
throw ZipError . unzipFail
137
137
}
138
138
139
- let directoryAttributes : [ FileAttributeKey : Any ] ?
140
- #if (os(Linux) || os(Windows)) && compiler(<6.0)
141
- directoryAttributes = nil
142
- #else
143
- let creationDate = Date ( )
144
- directoryAttributes = [
145
- . creationDate: creationDate,
146
- . modificationDate: creationDate,
147
- ]
148
- #endif
139
+ let creationDate = Date ( )
140
+ let directoryAttributes : [ FileAttributeKey : Any ] ? = [
141
+ . creationDate: creationDate,
142
+ . modificationDate: creationDate,
143
+ ]
149
144
150
145
let isDirectory =
151
146
fileName [ Int ( fileInfo. size_filename - 1 ) ] == " / " . cString ( using: String . Encoding. utf8) ? . first
0 commit comments