Skip to content

Commit 74e1ce2

Browse files
committed
feat: import zip type
Signed-off-by: Lessica <82flex@gmail.com>
1 parent 113e329 commit 74e1ce2

File tree

5 files changed

+25
-25
lines changed

5 files changed

+25
-25
lines changed

TrollFools/AppListView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ struct AppListView: View {
103103
.onOpenURL { url in
104104
let ext = url.pathExtension.lowercased()
105105
guard url.isFileURL,
106-
ext == "dylib" || ext == "deb"
106+
(ext == "dylib" || ext == "deb" || ext == "zip")
107107
else {
108108
return
109109
}

TrollFools/Info.plist

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@
1818
<string>com.apple.mach-o-binary</string>
1919
</array>
2020
</dict>
21+
<dict>
22+
<key>CFBundleTypeName</key>
23+
<string>ZIP Archive</string>
24+
<key>LSHandlerRank</key>
25+
<string>Default</string>
26+
<key>CFBundleTypeRole</key>
27+
<string>Viewer</string>
28+
<key>LSItemContentTypes</key>
29+
<array>
30+
<string>public.zip-archive</string>
31+
</array>
32+
</dict>
2133
<dict>
2234
<key>CFBundleTypeName</key>
2335
<string>Sileo Deb Package</string>
@@ -41,8 +53,6 @@
4153
</array>
4254
<key>UTTypeIdentifier</key>
4355
<string>org.debian.deb-archive</string>
44-
<key>UTTypeIconFiles</key>
45-
<array/>
4656
<key>UTTypeTagSpecification</key>
4757
<dict>
4858
<key>public.filename-extension</key>

TrollFools/InjectorV3+Preprocess.swift

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,13 @@ fileprivate extension InjectorV3 {
143143
var tarReader = TarReader(fileHandle: tarHandle)
144144
var processedBundles = Set<String>()
145145
var bundleContents: [String: [(info: TarEntryInfo, data: Data?)]] = [:]
146+
146147
while let entry = try tarReader.read() {
147148
if entry.info.type == .regular && entry.info.name.hasSuffix(".dylib") {
148149
guard let entryData = entry.data else {
149150
continue
150151
}
152+
151153
let dylibName = URL(fileURLWithPath: entry.info.name, relativeTo: targetURL).lastPathComponent
152154
guard !dylibName.hasPrefix(".") else {
153155
continue
@@ -159,20 +161,16 @@ fileprivate extension InjectorV3 {
159161
try entryData.write(to: entryURL)
160162
hasAnyDylib = true
161163
} else if entry.info.type == .directory && entry.info.name.hasSuffix(".bundle") {
162-
// Extract bundle name
163164
let bundleName = URL(fileURLWithPath: entry.info.name).lastPathComponent
164-
// Avoid processing duplicate or nested bundles
165165
guard !processedBundles.contains(bundleName) else {
166166
continue
167167
}
168-
// Track that we're processing this bundle
168+
169169
processedBundles.insert(bundleName)
170-
// Store bundle entries for later processing
171170
bundleContents[entry.info.name] = []
172171

173172
DDLogWarn("Found bundle \(entry.info.name) name \(bundleName)", ddlog: logger)
174173
} else {
175-
// Collect contents for all bundles
176174
for (bundlePath, _) in bundleContents {
177175
if entry.info.name.starts(with: bundlePath + "/") {
178176
bundleContents[bundlePath]?.append((entry.info, entry.data))
@@ -184,36 +182,28 @@ fileprivate extension InjectorV3 {
184182
if !hasAnyDylib {
185183
throw Error.generic(NSLocalizedString("No dylib found in the Debian package.", comment: ""))
186184
}
185+
187186
let fileManager = FileManager.default
188-
// Process collected bundle contents
189187
for (bundlePath, contents) in bundleContents {
190188
let bundleName = URL(fileURLWithPath: bundlePath).lastPathComponent
191-
192189
DDLogInfo("Preparing to copy bundle \(bundlePath)", ddlog: logger)
193-
194-
// Destination for the bundle
190+
195191
let destinationBundleURL = targetURL.appendingPathComponent(bundleName)
196-
// Remove existing bundle if it exists
197192
if fileManager.fileExists(atPath: destinationBundleURL.path) {
198193
try fileManager.removeItem(at: destinationBundleURL)
199194
}
200-
// Create destination directory for the bundle
195+
201196
try fileManager.createDirectory(at: destinationBundleURL, withIntermediateDirectories: true)
202-
203-
// Copy bundle contents
197+
204198
for entry in contents {
205-
// Get relative path within the bundle
206199
let relativePath = String(entry.info.name.dropFirst(bundlePath.count + 1))
207200
let destinationPath = destinationBundleURL.appendingPathComponent(relativePath)
208-
// Handle different entry types
201+
209202
switch entry.info.type {
210203
case .directory:
211-
// Create subdirectories
212204
try fileManager.createDirectory(at: destinationPath, withIntermediateDirectories: true)
213205
case .regular:
214-
// Ensure destination directory exists
215206
try fileManager.createDirectory(at: destinationPath.deletingLastPathComponent(), withIntermediateDirectories: true)
216-
// Write file contents
217207
guard let fileData = entry.data else {
218208
DDLogWarn("Unable to read data for \(entry.info.name)", ddlog: logger)
219209
continue
@@ -223,7 +213,7 @@ fileprivate extension InjectorV3 {
223213
continue
224214
}
225215
}
226-
216+
227217
DDLogInfo("Successfully copied bundle \(bundleName)", ddlog: logger)
228218
}
229219
}

TrollFools/Version.xcconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
// Configuration settings file format documentation can be found at:
99
// https://help.apple.com/xcode/#/dev745c5c974
1010

11-
VERSION = 3.6
12-
BUILD_NUMBER = 39
11+
VERSION = 3.7
12+
BUILD_NUMBER = 41

control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: wiki.qaq.trollfools
22
Name: TrollFools
3-
Version: 3.6-39
3+
Version: 3.7-41
44
Section: Applications
55
Depends: firmware (>= 14.0)
66
Architecture: iphoneos-arm

0 commit comments

Comments
 (0)