4 Replies Latest reply: May 19, 2014 10:41 AM by Magnus Berg RSS

    Request for change in vL.FileExist function.

    Vadim Tsushko

      Hi all.

       

      I've recently found that vL.FileExist function is unsufficiently robust in QDF.

      Consider that snippet from QVD-Generator-Example of 1.Example container (QDF version 1.4.0).

       

      // Folder for output QVDs use
      // Use QlikView Deployment Framework Variable $(vG.QVDPath)
      LET vL.QVDPath = '$(vG.QVDPath)';
      
      // Check if folder exists by using function call vL.FileExist
      call vL.FileExist ('$(vL.QVDPath)*')
      if vL.FileExist = 'false' then; trace '### DF Did not find $(vL.QVDPath), exit script'; sleep 5000 ;exit script; endif;
      
      
      
      
      
      

       

      Apparently we should be calm about QVD folder existence after that check. But if I deliberately remove 2.QVD folder from 1.Example container script still moves futher.

       

      Some debugging shows that if I physically remove 2.QVD directory, vG.QVDPath variable becomes empty and effectively we call vL.FileExist function with parameter '*' - and that always return true. That is not good, because function would return same falsely positive result if I for example misspell path variable:

       

      call vL.FileExist ('$(vG.QvdPath)');
      
      
      
      

      or even

      call vL.FileExist ('$(vG.ABRACADABRA));
      
      
      
      

      would return true.

      On the other hand we cannot simply omit trailing star when check for QDF paths, because they all have a trailing '\' and vL.FileExist always return false on directory path with trailing '\'.

       

      So my proposal is twofold:

      1. Change vL.FileExist so that it remove trailing '\' from parameter if it present.

      2. Change examples and docs to discurage using * in vL.FileExist paramteter.

       

      Proposed variant of function with added  lines 2-4

       

      
      sub vL.FileExist (vL.Root)
        if Right('$(vL.Root)',1) = '\' then
          LET vL.Root = Left(vL.Root,Len(vL.Root)-1);
        endif
        if IsNull(filesize('$(vL.Root)')) = -1  then
        SET vL.FileExist='false';
          else
        SET vL.FileExist='true';
        endif
        set vL.Root=;
      end sub;
      
      
      
      
      
      
      

       

       

       

      vG.QVDPathvG.QVDPath