On Windows, rename() fails if the new filename already exists. Use the Windows specific function MoveFileExA with the MOVEFILE_REPLACE_EXISTING flag set instead to do renames.
Implement the PSA ITS API over stdio files.