10-16-2019 03:41 PM - edited 10-16-2019 04:32 PM
Hello,
I have code deployed on multiple machine. Recently one of machine started giving problem while writing to ini file.
Upon investigation error code returned by WriteIni is -5003.
Error explanation "-5003: Could not generate an unused temporary file name in the in the same directory as the output file."
Can somebody explain what -5003 means? And why this would happen to particular machine?
The func that reports the error is below
Appreciate response.
Regards
Girish
void IniWriteRecord (double CurTemp)
{
int status;
char TimeDate[50];
IniText RecordIni;
RecordIni = Ini_New (0);
status = Ini_ReadFromFile (RecordIni, szInirecordpath);
if (status < 0)
printf("IniWriteRecord: Error writing to Reading from record file\n");
sprintf (TimeDate, "%s %s", GetDateStr (),GetTimeStr ());
status = Ini_PutRawString (RecordIni, "RecorderAddOn", "Version", PROGVERSION);
status = Ini_PutRawString (RecordIni, "RecorderAddOn", "LastUpdate", TimeDate);
status = Ini_PutDouble (RecordIni, "RecorderColumns", "temperature", CurTemp);
status = Ini_PutInt (RecordIni, "RecorderColumns", "tstable", StableFlag);
//status = Ini_PutInt (RecordIni, "RecorderColumns", "tstable", 1);
status = Ini_PutInt (RecordIni, "RecorderColumns", "tcycle_stopped", AbortSlope);
status = Ini_PutInt (RecordIni, "STATUS", "CHAMBER_ON", gStatusChamberOn);
status = Ini_PutInt (RecordIni, "STATUS", "CYCLE_RUNNING", gStatusCycleRunning);
status = Ini_PutInt (RecordIni, "STATUS", "MAINTENANCE", gStatusMaintenace);
status = Ini_PutRawString (RecordIni, "STATUS", "TESTRUN_NUMBER", gStatusTestrunNumber);
status = Ini_WriteToFile (RecordIni, szInirecordpath);
if (status < 0)
printf("IniWriteRecord: Error writing to Record File Error Code: %d\n", status);
if (strlen (szInirecordpath2) > 3)
{
status = Ini_WriteToFile (RecordIni, szInirecordpath2);
}
Ini_Dispose (RecordIni);
return;
}
Solved! Go to Solution.
10-16-2019 06:15 PM - edited 10-16-2019 06:16 PM
The source code for the IniFile instrument is available in <cvifolder>\toolslib\toolbox; as you can see there, Ini_WriteToFile creates a temporary filename in the same folder as the output file, writes to that file and if write is successful renames the temp file as the regular file. This is to prevent damaging the original file and guarantees that you always have a correct copy of the .ini file even in case of errors. This procedure is explained in the help for CreteAndOpenTemporaryFile that I suggest you to read.
In your situation, you may have some reason for the program not being able to delete the temporary file once created: the function can create up to 1000 files and then reports error -5003. I suggest you look into the target folder, where you should find several files named "ini$$xxx.cvi" with xxx from 0 to 999.
10-16-2019 07:39 PM
Roberto:
Thanks for the reply. I did check the target folder for temp files but couldn't find any.
I did get suggestion to delete windows temp files so ran disk clean-up which resolved the issue.
Girish
10-17-2019 06:45 AM
Ok good to know.
I'm happy you solved your problem even if it's not clear to me how Windows temporary files can affect the creation of a regular file in a folder, but anyway... I'm taking note of it in case I have the same problems.