How to use the macholib.mach_o.fat_arch.from_fileobj function in macholib

To help you get started, we’ve selected a few macholib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github HenriWahl / Nagstamon / build / helpers / pyinstaller-2.0 / PyInstaller / lib / macholib / util.py View on Github external
"""
    Return True if the file is Mach-O
    """
    if not os.path.exists(path) or os.path.islink(path):
        return False
    # If the header is fat, we need to read into the first arch
    with open(path, 'rb') as fileobj:
        bytes = fileobj.read(MAGIC_LEN)
        if bytes == FAT_MAGIC_BYTES:
            # Read in the fat header
            fileobj.seek(0)
            header = mach_o.fat_header.from_fileobj(fileobj, _endian_='>')
            if header.nfat_arch < 1:
                return False
            # Read in the first fat arch header
            arch = mach_o.fat_arch.from_fileobj(fileobj, _endian_='>')
            fileobj.seek(arch.offset)
            # Read magic off the first header
            bytes = fileobj.read(MAGIC_LEN)
    for magic in MAGIC:
        if bytes == magic:
            return True
    return False
github nortd / driveboardapp / other / pyinstaller / PyInstaller / lib / macholib / util.py View on Github external
"""
    Return True if the file is Mach-O
    """
    if not os.path.exists(path) or os.path.islink(path):
        return False
    # If the header is fat, we need to read into the first arch
    fileobj = open(path, 'rb')
    bytes = fileobj.read(MAGIC_LEN)
    if bytes == FAT_MAGIC_BYTES:
        # Read in the fat header
        fileobj.seek(0)
        header = mach_o.fat_header.from_fileobj(fileobj, _endian_='>')
        if header.nfat_arch < 1:
            return False
        # Read in the first fat arch header
        arch = mach_o.fat_arch.from_fileobj(fileobj, _endian_='>')
        fileobj.seek(arch.offset)
        # Read magic off the first header
        bytes = fileobj.read(MAGIC_LEN)
    fileobj.close()
    for magic in MAGIC:
        if bytes == magic:
            return True
    return False
github pyinstaller / pyinstaller / PyInstaller / lib / macholib / util.py View on Github external
"""
    Return True if the file is Mach-O
    """
    if not os.path.exists(path) or os.path.islink(path):
        return False
    # If the header is fat, we need to read into the first arch
    with open(path, 'rb') as fileobj:
        bytes = fileobj.read(MAGIC_LEN)
        if bytes == FAT_MAGIC_BYTES:
            # Read in the fat header
            fileobj.seek(0)
            header = mach_o.fat_header.from_fileobj(fileobj, _endian_='>')
            if header.nfat_arch < 1:
                return False
            # Read in the first fat arch header
            arch = mach_o.fat_arch.from_fileobj(fileobj, _endian_='>')
            fileobj.seek(arch.offset)
            # Read magic off the first header
            bytes = fileobj.read(MAGIC_LEN)
    for magic in MAGIC:
        if bytes == magic:
            return True
    return False