mirror of
https://github.com/Karmaz95/Snake_Apple.git
synced 2026-03-30 14:00:16 +02:00
Add Lock to synchronize print statements and prevent stdout corruption when multiple threads write simultaneously. Example corruption before:
``` DYLIB:/Applications/NordVPN.app/Contents/Frameworks/norddropFFI.framework/Versions/A/norddropFFI /* No comment provided by engineer. */ "Update Error!" = "Virhe p�ivEXECUTE:/Applications/KnockKnock.app/Contents/MacOS/KnockKnock ```
This commit is contained in:
@@ -4,6 +4,7 @@ import sys
|
||||
import argparse
|
||||
import struct
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from threading import Lock
|
||||
import stat
|
||||
|
||||
class MachOFileFinder:
|
||||
@@ -37,6 +38,7 @@ class MachOFileFinder:
|
||||
self.directory_path = directory_path
|
||||
self.recursive = recursive
|
||||
self.only_arm64 = only_arm64
|
||||
self.print_lock = Lock()
|
||||
|
||||
def isRegularFile(self, file_path):
|
||||
"""Check if the specified file is a regular file."""
|
||||
@@ -178,7 +180,8 @@ class MachOFileFinder:
|
||||
# Check if the file is a Mach-O binary or FAT binary
|
||||
file_type = self.getMachoInfo(file_path)
|
||||
if file_type:
|
||||
print(f"{file_type}:{file_path}")
|
||||
with self.print_lock:
|
||||
print(f"{file_type}:{file_path}")
|
||||
|
||||
def processFiles(self):
|
||||
"""Walk through the directory and process files using threading for faster execution."""
|
||||
@@ -202,4 +205,4 @@ if __name__ == "__main__":
|
||||
sys.exit(1)
|
||||
|
||||
finder = MachOFileFinder(directory_path, recursive=args.recursive, only_arm64=args.only_arm64)
|
||||
finder.processFiles()
|
||||
finder.processFiles()
|
||||
Reference in New Issue
Block a user