INNER CODE UNIT · Python

is_elf_file

alper-han/CrossMacro · scripts/ci/verify-glibc-baseline.py:32

def is_elf_file(path: Path) -> bool:
    try:
        with path.open("rb") as stream:
            return stream.read(len(ELF_MAGIC)) == ELF_MAGIC
    except OSError:
        return False


def discover_elf_files(paths: list[Path]) -> list[Path]:
    candidates: list[Path] = []
    for path in paths:
        if path.is_dir():
            candidates.extend(candidate for candidate in path.rglob("*") if candidate.is_file())
        elif path.is_file():
            candidates.append(path)

    return sorted({candidate for candidate in candidates if is_elf_file(candidate)})

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…