![]() | Fun 0.41.5 The programming language that makes You have fun |
Implements the OP_WRITE_FILE opcode for writing to a file in the VM. More...

Go to the source code of this file.
Functions | |
| if (path.type !=VAL_STRING||data.type !=VAL_STRING) | |
| if (f) | |
| free_value (path) | |
| free_value (data) | |
| push_value (vm, make_int(ok ? 1 :0)) | |
Variables | |
| case | OP_WRITE_FILE |
| Value | path = pop_value(vm) |
| const char * | p = path.s ? path.s : "" |
| FILE * | f = fopen(p, "wb") |
| int | ok = 0 |
| break | |
Implements the OP_WRITE_FILE opcode for writing to a file in the VM.
This file handles the OP_WRITE_FILE instruction, which writes data to a file. The file path and data are popped from the stack, and a success/failure flag is pushed back.
Behavior:
Error Handling:
Example: // Bytecode: OP_WRITE_FILE // Stack before: ["file.txt", "data"] // Stack after: [1]
Definition in file write_file.c.
| free_value | ( | data | ) |
| free_value | ( | path | ) |
| if | ( | f | ) |
| if | ( | path.type ! | = VAL_STRING || data.type != VAL_STRING | ) |
Definition at line 34 of file write_file.c.
| break |
Definition at line 49 of file write_file.c.
| FILE* f = fopen(p, "wb") |
Definition at line 39 of file write_file.c.
| int ok = 0 |
Definition at line 40 of file write_file.c.
| case OP_WRITE_FILE |
Definition at line 31 of file write_file.c.
Definition at line 38 of file write_file.c.
| Value path = pop_value(vm) |
Definition at line 33 of file write_file.c.