Login Page - Create Account

Support Board


Date/Time: Sat, 27 Apr 2024 21:18:47 +0000



Post From: How to retrieve error code for File Open Error in ACSIL

[2018-10-08 11:53:28]
User787032 - Posts: 37
In one of my studies, I get an occasional error when opening a file at the end. This is part of a routine that is executed at regular intervals to check for a change in the timestamp of the last record in the file, which is being delivered by an external file synchronization program. Once the check has been done, the file is closed. Most of the time, the file opens OK and I can read the last record without a problem, but at times, the open fails.
          
mySourceFile.open(SFname, ios::in | ios::binary | ios::ate); // open source file at end
          if(mySourceFile.fail())
          {
            sc.AddMessageToLog("Failed to open source file ",1);
            sc.AddMessageToLog(strerror(errno),1);

            return;
          }
I tried using strerror(errno) but that just returns a message "No error" as errno is zero. I seem to recall that GetLastError can be used but I can't find a reference to it in the documentation. Is there a way to capture the file open error in ACSIL?