Skip to content

Commit cc15a6b

Browse files
authored
Merge pull request #230 from p-x9/feature/dyld-cache-full
Add a convenience property to get full dyld cache from dyld cache
2 parents 6ce89c3 + 3d87870 commit cc15a6b

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

Sources/MachOKit/DyldCache.swift

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,26 @@ public class DyldCache: DyldCacheRepresentable, _DyldCacheFileRepresentable {
115115
}
116116
}
117117

118+
extension DyldCache {
119+
public var mainCache: DyldCache? {
120+
if url.lastPathComponent.contains(".") {
121+
let url = url
122+
.deletingPathExtension()
123+
.deletingPathExtension()
124+
return try? .init(url: url)
125+
} else {
126+
return self
127+
}
128+
}
129+
130+
public var fullCache: FullDyldCache? {
131+
let url = url
132+
.deletingPathExtension()
133+
.deletingPathExtension()
134+
return try? .init(url: url)
135+
}
136+
}
137+
118138
extension DyldCache {
119139
/// Sequence of mapping infos
120140
public var mappingInfos: DataSequence<DyldCacheMappingInfo>? {
@@ -220,17 +240,6 @@ extension DyldCache {
220240
}
221241

222242
extension DyldCache {
223-
public var mainCache: DyldCache? {
224-
if url.lastPathComponent.contains(".") {
225-
let url = url
226-
.deletingPathExtension()
227-
.deletingPathExtension()
228-
return try? .init(url: url)
229-
} else {
230-
return self
231-
}
232-
}
233-
234243
/// Sequence of MachO information contained in this cache
235244
public func machOFiles() -> AnySequence<MachOFile> {
236245
_machOFiles(mainCache: mainCache)

0 commit comments

Comments
 (0)