Skip to content

Commit 8cce2f7

Browse files
committed
feat: Setting extracted files as executable.
1 parent 7977d9a commit 8cce2f7

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

dyld-cache-dump/Extractor.swift

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,37 @@ public class Extractor
7575
{
7676
progress?( $0 + 1, $1 )
7777
}
78+
79+
self.setFilesAsExecutable( in: destination )
80+
}
81+
82+
private func setFilesAsExecutable( in directory: URL )
83+
{
84+
guard let enumerator = FileManager.default.enumerator( at: directory, includingPropertiesForKeys: nil )
85+
else
86+
{
87+
return
88+
}
89+
90+
enumerator.forEach
91+
{
92+
guard let file = $0 as? URL
93+
else
94+
{
95+
return
96+
}
97+
98+
var isDir: ObjCBool = false
99+
100+
if FileManager.default.fileExists( atPath: file.path( percentEncoded: false ), isDirectory: &isDir ), isDir.boolValue == false
101+
{
102+
let attributes: [ FileAttributeKey: Any ] = [
103+
.posixPermissions: 0o755
104+
]
105+
106+
try? FileManager.default.setAttributes( attributes, ofItemAtPath: file.path( percentEncoded: false ) )
107+
}
108+
}
78109
}
79110

80111
private func recylce( url: URL ) throws

0 commit comments

Comments
 (0)