Applies To: |
|
Summary: |
A file handle leak in CitectSCADA cicode
can be easily caused by incorrectly using FileFind() with wildcard
characters to find a list of files. |
Solution: |
The CitectSCADA help for FileFind() gives
the following explanation of how to find a list of files: "To find a list of files, you must first call this function with the required path and mode (to find the first file), then call the function again with an empty path and a mode of 0 (to find the remaining files). After the last file is found, an empty string is returned." It also gives the following example to demonstrate this: ! Search for all dBase files in the run directory and make a backup sPath = FileFind("[run]:\*.dbf", 0); WHILE StrLength(sPath) > 0 DO FileSplitPath(sPath, sDrive, sDir, sFile, sExt); sBak = FileMakePath(sDrive, sDir, sFile, "BAK"); FileCopy(sPath, sBak, 0); ! Find the next file sPath = FileFind("", 0); END
! Search for all dBase files in the run directory and make a backup sPath = FileFind("[run]:\*.dbf", 0); WHILE StrLength(sPath) > 0 DO FileSplitPath(sPath, sDrive, sDir, sFile, sExt); sBak = FileMakePath(sDrive, sDir, sFile, "BAK"); FileCopy(sPath, sBak, 0); ! Find the next file sPath = FileFind("[run]:\*.dbf", 0); // Handle leak! END
|
Keywords: |
FileFind, FileFind(), file handle
leak |
Related Links
Attachments