Applies To:
  • CitectSCADA 5.20

Summary:
FileFind fails to close opened file handles when finding just one file, or if a recursive call fails to finish finding all specified files. The only time FileFind() ever releases file handles is when it is called to find a series of files, eg. "*.txt" or "abc.???", and then is called continually until there are no more files to find.

Example 1.

If the Data directory under Citect contains the files: 1.txt, 2.txt and 3.txt, and the following CiCode is executed:

sPath = FileFind("[data]:\1.txt", 0); /* sPath = "c:\citect\data\1.txt" */

... This will consume a file handle and not release it, since only one file is to be found.

Example 2.

If the Data directory under Citect contains the files: 1.txt, 2.txt and 3.txt, and the following CiCode is executed:

sPath = FileFind("[data]:\*.txt", 0); /* sPath = "c:\citect\data\1.txt" */
sPath = FileFind("", 0); /* sPath = "c:\citect\data\2.txt" */

... This will consume a file handle and not release it, since all the txt files were not found.

 

Solution:
CIT has confirmed that the call of FileFind() to find just one file as a problem in Citect for Windows versions 5.20 and 5.21. This problem has been fixed in version 5.21 Service Pack B.

CIT has also confirmed that a recursive call of FileFind() failing to finish finding all files is a problem in Citect for Windows versions 5.20 and 5.21. The solution to this problem is to use the function "FileFindClose" whenever the user knows that the recursive call will not finish finding all files.

Example.

If the Data directory under Citect contains the files: 1.txt, 2.txt and 3.txt, and the following CiCode is executed:

sPath = FileFind("[data]:\*.txt", 0); /* sPath = "c:\citect\data\1.txt" */
sPath = FileFind("", 0); /* sPath = "c:\citect\data\2.txt" */
FileFindClose(); /* This command will now close the file handle which was consumed by the previous calls */

This problem has been fixed in version 5.21 Service Pack B.

 

Keywords:
 

Attachments