FINDDIR


9.1A

 

The FINDDIR instruction retrieves file and directory names from a starting directory. The instruction uses the following format:

 

 

[label]

FINDDIR

{source}{sep}{dest}{sep}[MODE={mode}][:

 

 

 

ITEMCOUNT={count}][,DELIMITER={delimiter}][:

 

 

 

MAXSIZE={size}][,DMAKEDEST]

 

Where:

label

Optional. A Program Execution Label.

source

Required. A previously defined Character String Variable that specifies the starting directory.

sep

Required. A comma or one of the following prepositions: BY, TO, OF, FROM, USING, WITH, IN, or INTO.

dest

Required. A previously defined Character String Variable, DATALIST, or DIM pointer that receives the selected file and directory names.

mode

Optional. A Decimal Number or a Numeric Variable that specifies a value as described below.

count

Optional. A previously defined Numeric Variable that receives the number of name items that have been stored into the {dest} variable.

delimiter

Optional. A previously defined Character String Variable or literal that contains the user specified delimiter characters used in the {dest} result string. (9.6C)

size

Optional. A previously defined Numeric Variable that returns the minimize DIM variable size required to receive all of the finddir selected file and\or directory name information. (9.6C)

DMAKEDEST
Optional. A keyword without any operand that allows a {dest} DIM pointer to be resized as a DMAKE pointer so all of the finddir data can be stored without being truncated. (9.6C)

Flags Affected: ZERO, EOS, OVER

Note the following:

  1. FINDDIR retrieves file and directory names from a starting directory that can be located local to the runtime or from a directory that exists on a PLBCLIENT workstation or a SUNDM data manager.

  2. The returned set of file and directory names are stored in {dest} separated by a pipe (|) character in string variables or as individual items in a DATALIST.

  3. {source} may contain a directory and file name combination with wild card '*' characters to retrieve specific file/directory names.

  4. If the {source} variable data directory name starts with an exclamation point (!), the file and directory data is retrieved from a PLBCLIENT workstation.

  5. If the {source} variable data directory name has an

    |{ip/hostname}:port

    appended, the file/directory data is retrieved from a SUNDM data manager. 

  6. Each file/directory data item that is stored into the {dest} variable has a format as follows:

    fNAME or dNAME
     

  7. Where:

    f

    The leading character of a 'f' indicates that the 'NAME' is a file.

    d

    The leading character of a 'd' indicates that the 'NAME' is a directory.

     

  8. The {source} name may contain a filter timestamp that is appended to the {source} name before the SUNDM '|' delimiter. (9.3A) The ';' character is used as the delimiter character for the filter timestamp. The format of the filter is:

  9.  

         "name;[op]YYYYMMDDhhmmss"

         Where:

         name

    is the search name used for FINDDIR.

         op

    is optional operation character that can be a '=', '<', or '>'. If the [op] is not specified, the default operation is the same as a greater than or equal action.

         YYYYMMDDhhmmss

    is the last modification timestamp that filters the returned values. The last modification timestamp can be specified from 1 to 14 characters to get the desired filter action.

     

    Examples:

     

         Dest      DIM      400

         .

         . This instruction returns all files and directories that have

         . a YYYY year that is greater than or equal to 2008.

         .

         FINDDIR "c:\temp\*.*;2008", Dest

         .

         . This instruction returns all files and directories that have

         . a YYYYMM year/month that is greater than or equal to 2008.

         .

         FINDDIR "c:\temp\*.*;200810", Dest

         .

         . This instruction returns all files and directories that have

         . a YYYYMM year/month that is equal to the 200812. This

         . instruction is on a Data Manager.

         .

         FINDDIR "c:\temp\*.*;=200812|127.0.0.1", Dest

         .

         . This instruction returns all files and directories that have

         . a YYYYMMDDhhmmss year/month/day/hour/minute/second that is

         . less than 20081215062045.

         .

         FINDDIR "c:\temp\x.*;<20081215062045", Dest

     

  10. The {mode} numeric value has the following bit definitions that control various operations for the FINDDIR instruction:

  11.  

    Value

    Action

    0x1

    Excludes any hidden files.

    0x2

    Excludes any directory names.

    0x4

    Excludes any file names.

    0x8
    0x20
    0x40 

    Include the last write time as a delimited field in the return string. These mode bit mask values are mutually exclusive. See Note (13.). (9.3A)

    0x8 - The last write times are adjusted for the timezone and Daylight Savings Time (DST). On a Windows system, this last write time form is compatible with the Windows Explorer.

    0x20 - The last write times are adjusted for the timezone without being adjusted for the Daylight Savings Time (DST).

    0x40 - The raw last write times are returned. The raw last write time is the OS UTC timestamp which is not adjusted to any timezone or Daylight Savings Time (DST).

    0x10

    Include the file size as a delimited field in the return string. (9.3A)

     

  12. When the file size and last write time data fields are returned, the fields are delimited with a semicolon (;). The size value is returned first followed by the time. (9.3A)

  13. The first and second characters of the {delimiter} keyword are used in place of all ';' delimiter and '|' delimiter characters used in the FINDDIR instruction. This includes delimiter characters used in the {source} for a filter and the {dest}. However, the {delm} does not affect the '|' used to redirect to a SUNDM. (9.6C)

  14. The ZERO flag is set when the FINDDIR instruction completes successfully.

  15. The EOS flag indicates that there are more name items than can fit into the {dest} variable and data has been lost by truncation.

  16. The MODE bit values of 0x8, 0x20, are 0x40 are mutually exclusive. The 0x40 value takes precedence over the 0x20 and 0x8 values. The 0x20 value takes precedence over the 0x8 value. (9.3A)

  17. The OVER flag indicates that the item count is too large to fit into the {count} variable.

  18. The first and second characters of the {delm} keyword are used in place of all ';' delimiter and '|' delimiter characters used in the FINDDIR instruction. This includes delimiter characters used in the {source} for a filter and the {dest}. However, the {delm} does not affect\replace the '|' used to redirect to a SUNDM.

  19. When the 'DMAKEDEST' keyword is being using used, the end user application causes the FINDDIR behavior to be changed for a destination pointer operand. When 'DMAKEDEST' is used, the FINDDIR behavior changes to reallocate a {dest} DIM pointer by creating a DMAKE DIM variable that is big enough to receive all of finddir data. When 'DMAKEDEST' is used, the user should consider the following:

  20. Generate/bullet1.gif    If a {dest} DIM pointer DIM variable size is too small to receive all of the finddir data, the FINDDIR instruction automatically reallocates and changes the {dest} DIM pointer to point to a newly created DMAKE DIM variable. Therefore, a {dest} DIM pointer is automatically changed any time that the pointer DIM variable is too small on input.

    Generate/bullet1.gif    By default, a {dest} pointer MUST contain a valid DIM variable reference before the FINDDIR instruction is executed.

    Generate/bullet1.gif    If the FINDDIR has to reallocate a {des} DIM pointer, the previous DIM pointer is de-referenced and any previous DMAKE pointer buffers are automatically released.

    Generate/bullet1.gif    If the FINDDIR operation encounters a DMAKE failure, a new F13 error occurs. This kind of internal DMAKE failure can only occur if there is insufficient memory for a dynamic DIM variable.

  21. If a DATALIST GUI object is used as the {dest} variable, each finddir data item is inserted into the DATALIST as a single line item entry. The end user application must process each DATALIST line item entry as required by the PLB application.

 

 

See Also: Disk I/O Instructions

 



PL/B Language Reference FILTER FINDFILE