Hello David.
I remember of a bug that I experienced on 23 January 2023 totally by chance, and for which I wrote a fix in xsx.x.
The bug concerns XstFileExists, which I use extensively in viXen.
The bug: XstFileExists opens in read mode the file whose physical presence must be verified, but considers that any error indicates that file doesn't actually exist.
In fact, the file might be blocked by a system process, an antivirus program, or something else.
To make it worse, Windows has an optimization option that can play tricks on us: Windows can lock files and never forgets that locking, even after a reboot.
After this bug, I unchecked this optimization to avoid being caught out twice, because this bug persists, even after a million reboots.
I provided this fix to D., but I suppose he hadn't had time to fix it in xsx.x.
Bye! Guy
'
'
' ##############################
' ##### XstFileExists () #####
' ##############################
'
' GL-23jan23-old---
'' Determine if file exists. Returns 0 on success, -1 on failure.
''
'FUNCTION XstFileExists (file$)
'
'
IFZ file$ THEN RETURN (-1)
'
ofile = XxxOpen (file$, $$RD)
'
IF ofile = -1 THEN RETURN (-1)
'
XxxClose (ofile)
'
'END FUNCTION
' GL-23jan23-old===
' GL-23jan23-new+++
' New: RETURNs an error message on an OPEN fail.
'
' Determines if a file exists. Returns 0 on success, -1 on failure.
'
' New error message.
' For example (simplified):
'
errNum = ERROR (0)
' clear last error code
'
bErr = XstFileExists (file$)
'
IF bErr THEN
' file does not exist
'
errNum = ERROR (0)
' get current error, then clear it
'
PRINT ERROR$ (errNum)
'
ENDIF
'
FUNCTION XstFileExists (file$)
EXTERNAL /shr_data/ errno ' run-time error number
XLONG fileNumber ' system file number
'
' To convert
errno into an XBLite error.
'
XLONG error ' for XstSystemErrorToError()
XLONG errLast ' for ERROR()
XLONG bErr ' returned error indicator (-1 for any fail, 0 for file exists)
'
' Start clean.
'
bErr = -1
' Assume fail
errno = 0
' clear any run-time error
SetLastError (0)
' clear any system error
'
' Try to open the passed file.
'
fileNumber = XxxOpen (file$, $$RD)
' Reading only of course!
IF fileNumber < 0 THEN
' Fail to get a system file number!
errno = GetLastError ()
' get system error
XstSystemErrorToError (errno, @error)
' move system error to high word of error value
errLast = ERROR (error)
' set current run-time error, to inform the caller of the exact failure
ELSE
' Success!
bErr = 0 ' (0 indicates that the file exists)
'
' GL-23jan23-fix+++
XxxClose (fileNumber)
' release this good file handle to avoid a permanent lock
' GL-23jan23-fix===
'
fileNumber = 0
' served its purpose
ENDIF
'
' Clean-up.
'
IFF bErr THEN
SetLastError (0)
' clear any system error
errno = 0
' clear run-time error
ENDIF
RETURN bErr
END FUNCTION
' GL-23jan23-new===
'