Skip to content

file: Enable disk writes when purging a file - #1870

Open
Wiljea wants to merge 1 commit into
c3d:devfrom
Wiljea:fix-purge-write-enable
Open

Wiljea wants to merge 1 commit into
c3d:devfrom
Wiljea:fix-purge-write-enable

Conversation

@Wiljea

@Wiljea Wiljea commented Nov 2, 2026

Copy link
Copy Markdown

Problem

On the calculator, "file" Purge calls f_unlink with disk writes disabled. On my DM32 this raised "Flush while write protect" once and an error in ../dm/qspi_disc.c:149 another time, then froze the calculator until a reset.

file::open calls sys_disk_write_enable(1) for writing; file::unlink did not.

Fix

In file::unlink, src/file.cc, enable disk writes around f_unlink, then disable them again unless a file is currently open for writing.

Tests

On a DM32, with a build that contains this commit (0.10.0-77-6ef8, my test branch), USB cable unplugged:

Input Result
"abc" "/t9.txt" STO done
"/t9.txt" Purge immediate, no error, no freeze
"/t9.txt" RCL "File not found"

Before this fix, on 0.10.0-72-eb92, "/t1.txt" Purge froze the calculator.

The simulator does not use this code, so the test suite cannot show the problem, and I have not added a test. I have not run the suite on this branch for the same reason.

Author & design: Jean Wilson
🤖 Generated with Claude Code

On the calculator, `"file" Purge` called f_unlink with disk writes
disabled, which raises "Flush while write protect" or an error in
qspi_disc.c, then freezes the calculator until a reset.

Enable writes around f_unlink, as file::open does. Leave them enabled if
a file is currently open for writing. The simulator does not use this code.

Author & design: Jean Wilson
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant