set target_file to (path to temporary items folder as string) & "qb.dat"
my writeFile("Hello World", target_file, false)
set qbAuthFile to (path to temporary items folder as text) & "qb.dat"
set theXmlContents to (read file qbAuthFile)
This worked fine when the same script wrote to the temp folder. But when I tried to read a file that was created by a different script (or maybe the same script in a previous run), then it gave the permission error in the temporary folder. If the first script wrote the file to the desktop, all was fine.
I think I may have figured it out though, at least partially. I had not given my script, or for that matter Script Debugger, “full Disk Access” in the dreaded Catalina ‘Security & Privacy’ System Preferences. I know my main script had asked for access to the desktop folder at one point, but I guess it doesn’t ask for permission to the temp folder? Either way, when I gave Script debugger full disk access, it read the file fine with the code above.
On a side note, in this I also discovered that a trick I used to use a lot to see if a file existed will have to change. I often used:
set theVariable to (path to desktop folder as text) & "myfile.txt"
theVariable as alias
-- it's not there
If the file wasn’t there the error would say ‘Macintosh HD:Users:sdye:Desktop:myfile.txt’ wasn’t found but in Catalina it gives the error Can’t make ‘Macintosh HD:Users:sdye:Desktop:myfile.txt’ into type alias
While that essentially is saying the same thing, it’s damn annoying since I expected the other verbiage and looked for it in my scripts at times. Somewhere in-between these two issues seems to be where the bug in my larger code lies…