From 0269ffa5ae9c68f7820c99ffddc371c704422e67 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Mon, 7 Nov 2016 11:11:38 -0800 Subject: [PATCH] support for filesystem in simulator --- sim/dalboard.ts | 2 ++ sim/state/filesystem.ts | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 sim/state/filesystem.ts diff --git a/sim/dalboard.ts b/sim/dalboard.ts index 67140948..3bccacf8 100644 --- a/sim/dalboard.ts +++ b/sim/dalboard.ts @@ -15,11 +15,13 @@ namespace pxsim { // TODO: not singletons neopixelState: NeoPixelState; microServoState: MicroServoState; + fileSystem: FileSystemState; constructor() { super() // components + this.fileSystem = new FileSystemState(); this.builtinParts["ledmatrix"] = this.ledMatrixState = new LedMatrixState(runtime); this.builtinParts["buttonpair"] = this.buttonPairState = new ButtonPairState({ ID_BUTTON_A: DAL.MICROBIT_ID_BUTTON_A, diff --git a/sim/state/filesystem.ts b/sim/state/filesystem.ts new file mode 100644 index 00000000..9eed2c31 --- /dev/null +++ b/sim/state/filesystem.ts @@ -0,0 +1,18 @@ +namespace pxsim.files { + export function appendLine(filename: string, text: string) { + const b = board(); + b.fileSystem.append(filename, text + "\r\n"); + } + export function appendString(filename: string, text: string) { + const b = board(); + b.fileSystem.append(filename, text); + } + export function appendNumber(filename: string, value: number) { + const b = board(); + b.fileSystem.append(filename, value.toString()); + } + export function remove(filename: string) { + const b = board(); + b.fileSystem.remove(filename); + } +} \ No newline at end of file