How to overwrite a file?

Thanks.

  1. I was able to get fs to delete the file created by a previous run of my plugin like this:

let path = app.activeDocument.path
let lastIndexOf = path.lastIndexOf(“\”)
path = path.slice(0, lastIndexOf+1);
path = path.replaceAll(“\”, “/”)
fileName = “test_file_to_delete.tif”
const directFS = require(‘fs’)
fileDeleted = await directFS.unlink(“file:”+path+fileName);

  1. Also, I discovered that if I moved the delete operation for other files ahead of the save operation for the new file, LFS deleted all of the files without throwing the error “FileSystemProvider: You don’t have permission on this file”.

I’m unclear as to the reason the sequence of deleting unrelated files is important.

I’d still like to use fs to save a log file to the same directory as the new TIF.

Based on the examples here:

Fs requires double backlashes instead of single forward slashes on a Mac, like this:
file:c:\path\to\allowed\file.json

Which of these functions will return a string with double slashes on a Mac?
anEntry.nativePath
homedir()
document.path

And will they be the required back slashes, or will the slashes have to be reversed, like on a PC?

Thanks again!