salvadegianluca - 2024-09-17

Good morning; I'm facing an issue that seems being caused by the library itself.
I'm trying to create the list of all the files that are stored inside a psecific directory.

Unluckily the first file is allways hidden.

VAR CONSTANT
arysEmptyArray:ARRAY[iArrayMinDimension..iArrayMAXDimension] OF STRING := [(iArrayMAXDimension - iArrayMinDimension)('')];
iArrayMinDimension:INT := 1;
iArrayMAXDimension:INT := 99;
END_VAR
VAR_INPUT
sDirectoryToInspect:STRING;
sSearchFilter:STRING;
END_VAR
VAR_IN_OUT
xCheckFileInsideDirectory:BOOL;
END_VAR
VAR
arysListOfFoundFiles:ARRAY[iArrayMinDimension..iArrayMAXDimension] OF STRING;
sNullString:STRING;
iNullIndex:INT := 0;
libInfoAboutThePath:DirInfo;
libResultOfThePathMonitoring:CmpErrors.RTS_IEC_RESULT;
libInstanceToMonitorThePath:CmpErrors.RTS_IEC_HANDLE;
sEntityToSearch:STRING;
dMaxEntityDimension:DINT := SIZEOF(sEntityToSearch);
libFileInfo:DirInfo;
sFilteredFileName:STRING;
iIndexToScrollArrays:INT;
END_VAR

IF xCheckFileInsideDirectory THEN

arysListOfFoundFiles:=arysEmptyArray; 
iIndexToScrollArrays:=iArrayMinDimension;

libInstanceToMonitorThePath:= SysDirOpen(szDir:= sDirectoryToInspect,szDirEntry:=sNullString,diMaxDirEntry:= iNullIndex,pDirInfo:= ADR(libInfoAboutThePath),pResult:= ADR(libResultOfThePathMonitoring));

WHILE libResultOfThePathMonitoring = Errors.ERR_OK AND iIndexToScrollArrays <= iArrayMAXDimension DO

    sEntityToSearch:= ''; 
  libResultOfThePathMonitoring:=SysDirRead(hDir:=libInstanceToMonitorThePath,szDirEntry:=sEntityToSearch,diMaxDirEntry:=dMaxEntityDimension,pDirInfo:=ADR(libFileInfo));

    sFilteredFileName:= FUN_06_00_FindItemInString_0(sFilter:=sSearchFilter,sSource:=sEntityToSearch);

    IF sFilteredFileName <> '' THEN
        arysListOfFoundFiles[iIndexToScrollArrays]:=sFilteredFileName;
        iIndexToScrollArrays:=iIndexToScrollArrays + 1; 
    END_IF

    IF libResultOfThePathMonitoring <> Errors.ERR_OK    THEN

        libResultOfThePathMonitoring:= Errors.ERR_OK;

    END_IF
END_WHILE

libResultOfThePathMonitoring:=SysDirClose(hDir:= libInstanceToMonitorThePath);

xCheckFileInsideDirectory:=FALSE;

END_IF

How is possible to solve this issue? Any known work around?