or run

tessl search
Log in

Version

Files

tile.json

task.mdevals/scenario-7/

File Patch System

Build a file patching utility that can apply binary patches to files at specific offsets.

Capabilities

Apply binary patch at offset

  • Given a file containing "Hello World", calling applyPatch with offset 6 and data "PATCH" results in the file containing "Hello PATCH" @test
  • Given an empty file, calling applyPatch with offset 0 and data "START" results in the file containing "START" @test

Handle multiple sequential patches

  • Given a file containing "AAABBBCCC", calling applyPatch three times (offset 0 with "111", offset 3 with "222", offset 6 with "333") results in the file containing "111222333" @test

Implementation

@generates

API

/**
 * Applies a binary patch to a file at the specified byte offset.
 *
 * @param {string} filePath - Path to the file to patch
 * @param {number} offset - Byte offset where the patch should be written
 * @param {Buffer|string} data - The patch data to write
 * @returns {Promise<void>} Resolves when the patch is successfully applied
 */
async function applyPatch(filePath, offset, data) {
  // IMPLEMENTATION HERE
}

module.exports = {
  applyPatch
};

Dependencies { .dependencies }

metro-memory-fs { .dependency }

Provides in-memory filesystem operations with stream support.

@satisfied-by