Close

Minor release 1.7.0

A project log for zeptoforth

A full-featured Forth-based RTOS for ARM Cortex-M

travis-bemannTravis Bemann 07/27/2024 at 22:440 Comments

This minor release adds explicit closing of files and directories to zeptoforth. Previously one could simply forget about files and directories after being done with them, but at the same time one had to be careful about removing files and directories and truncating files while they were still in use. Now one must close files and directories once one is done with them. This is done with fat32::close-file and fat32::close-dir respectively.

Note that previous code that used oo::destroy to destroy file and directory objects (as it should have, and in many places did not) strictly speaking does not need changing, as oo::destroy has been implemented to call these words for open files and directories. However, it is recommended to add calls to fat32::close-file and fat32::close-dir prior to calling oo::destroy to make this explicit.

One key warning is that simply disposing of a file or directory without closing or destroying it and then reusing its space will now result in undefined behavior, because open files and directories are now maintained as doubly-linked lists and reusing their space without closing or destroying them first will corrupt these lists.

Discussions