Files
lowbit--ps5-doom/tools/embed-file.py
T
rijads 93814c3e95 Send games from a PC or phone browser, with a QR code on screen
Add games gets a first row, Send from PC or phone. Its screen runs a small HTTP server for as long
as it is open (port 9666, or the next one the sandbox allows) and shows the address as text and as
a QR code. The page it serves takes dropped files and whole folders, uploads them one at a time with
progress, and lists what the console did with each. Game WADs are moved into place, archives go
through the importer and are deleted afterwards, add-ons and other files are refused with a reason.

qrcodegen 1.8.0 joins the pinned third-party fetch, renamed to fetch-third-party.sh; the page is
embedded at build time by tools/embed-file.py. tools/send.py does what the page does, for console
tests with test/console-send.cfg.
2026-10-04 15:25:39 +02:00

13 lines
529 B
Python

#!/usr/bin/env python3
"""Writes a C header that holds a file's bytes as a static array: embed-file.py <file> <name> <header>."""
import sys
source, name, header = sys.argv[1:]
data = open(source, "rb").read()
with open(header, "w", newline="\n") as out:
out.write(f"/* Generated from {source} by tools/embed-file.py. */\n")
out.write(f"static const unsigned char {name}[] = {{\n")
for i in range(0, len(data), 20):
out.write(" " + ", ".join(str(b) for b in data[i:i + 20]) + ",\n")
out.write("};\n")