Write file contents at specified offset.
(
self, flash_data: bytearray, file_path: Optional[Path], offset: int
)
| 187 | return True |
| 188 | |
| 189 | def _write_at_offset( |
| 190 | self, flash_data: bytearray, file_path: Optional[Path], offset: int |
| 191 | ) -> None: |
| 192 | """Write file contents at specified offset.""" |
| 193 | if not file_path or not file_path.exists(): |
| 194 | return |
| 195 | |
| 196 | file_data = file_path.read_bytes() |
| 197 | if offset + len(file_data) > len(flash_data): |
| 198 | raise ValueError( |
| 199 | f"File {file_path.name} at offset 0x{offset:x} exceeds flash size" |
| 200 | ) |
| 201 | |
| 202 | flash_data[offset : offset + len(file_data)] = file_data |
| 203 | |
| 204 | |
| 205 | class ESP32ArtifactCopier: |