home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / progmisc / nfsrc21.zip / WHEREIS.PRG < prev    next >
Text File  |  1991-08-16  |  4KB  |  128 lines

  1. /* File......: WHEREIS.PRG
  2.  * Author....: Steve Larsen
  3.  * CIS ID....: 76370,1532
  4.  * Date......: $Date:   15 Aug 1991 23:06:38  $
  5.  * Revision..: $Revision:   1.0  $
  6.  * Log file..: $Logfile:   E:/nanfor/src/whereis.prv  $
  7.  *
  8.  * This is an original work by K. Stephan Larsen and is placed in
  9.  * the public domain.
  10.  *
  11.  * Modification history:
  12.  * ---------------------
  13.  *
  14.  * $Log:   E:/nanfor/src/whereis.prv  $
  15.  * 
  16.  *    Rev 1.0   15 Aug 1991 23:06:38   GLENN
  17.  * Forest Belt proofread/edited/cleaned up doc
  18.  *
  19.  *     Rev 1.0   07 Jun 1991 21:56:10   GLENN
  20.  *  Initial revision.
  21.  *
  22.  */
  23.  
  24. /* $DOC$
  25.  * $FUNCNAME$
  26.  *    FT_WHEREIS()
  27.  * $CATEGORY$
  28.  *    Environment
  29.  * $ONELINER$
  30.  *    Locate all occurrences of a filespec on a drive
  31.  * $SYNTAX$
  32.  *    FT_WHEREIS( [ <cDrive:> ][ <cFilespec> ] ) -> aFiles
  33.  * $ARGUMENTS$
  34.  *    <cDrive:> is an optional drive to search.  If omitted, FT_WHEREIS()
  35.  *    defaults to the current drive.
  36.  *
  37.  *    <cFilespec> is a DOS legal filespec containing the pattern that
  38.  *    you want found.  The wildcard characters "*" and "?" are supported.
  39.  *    If no <cFilespec> is specified, FT_WHEREIS() defaults to all files.
  40.  * $RETURNS$
  41.  *    An array of filenames that match <cFilespec>.
  42.  * $DESCRIPTION$
  43.  *    Use FT_WHEREIS() to obtain an array with the full path/filenames of all
  44.  *    files on the specified or current drive that match a DOS legal filespec.
  45.  *
  46.  *    You may optionally specify a drive to search, other than the current
  47.  *    drive.  Please note that FT_WHEREIS() will not cause a runtime error if
  48.  *    you specify an invalid or inoperable drive; it instead returns an
  49.  *    empty array.
  50.  * $EXAMPLES$
  51.  *    /* Example 1 */
  52.  *    aComSpec := FT_WHEREIS( "command.com" ) // aComSpec now contains an
  53.  *                                            // entry for every "Command.com"
  54.  *                                            // on the current drive
  55.  *    /* Example 2 */
  56.  *    aBat := FT_WHEREIS( "a:*.bat" )
  57.  *
  58.  *    IF Empty( aBat )
  59.  *       ?"Please make sure the proper diskette is in drive A:, and that"
  60.  *       ?"the drive door is closed."
  61.  *    ELSE
  62.  *       ? "You have " + Len( aBat ) " batch files on drive A:"
  63.  *    ENDIF
  64.  * $INCLUDE$
  65.  * $SEEALSO$
  66.  *    FT_TREE() FT_ORIGIN()
  67.  * $END$
  68.  */
  69.  
  70. FUNCTION FT_WHEREIS( cFilespec )
  71.  
  72. LOCAL nFilecount, aFiles := {}
  73.  
  74. IF ( nFilecount := __ft_where( cFilespec ) ) > 0
  75.    __ft_where( cFilespec, aFiles := Array( nFilecount ) )
  76. ENDIF
  77.  
  78. RETURN aFiles
  79.  
  80.  
  81. /* $DOC$
  82.  * $FUNCNAME$
  83.  *    FT_TREE()
  84.  * $CATEGORY$
  85.  *    Environment
  86.  * $ONELINER$
  87.  *    Locate all directories and subdirectories on a drive
  88.  * $SYNTAX$
  89.  *    FT_TREE( [ <cDrive:> ] ) -> aDirectories
  90.  * $ARGUMENTS$
  91.  *    <cDrive:> is an optional drive to search.  If omitted, FT_TREE()
  92.  *    defaults to the current drive.
  93.  * $RETURNS$
  94.  *    An array containing the name of each directory found on the specified
  95.  *    drive.
  96.  * $DESCRIPTION$
  97.  *    Use FT_TREE() to obtain an array of the directory structure of a
  98.  *    specified drive.
  99.  *
  100.  *    You may optionally specify a drive to search, other than the current
  101.  *    drive.  Please note that FT_TREE() will not cause a runtime error if
  102.  *    you specify an invalid or inoperable drive, instead returns an
  103.  *    empty array.
  104.  *
  105.  *    The directory structure returned is not ordered in any way other than
  106.  *    the order that the directories are contained in DOS.  To put the
  107.  *    directories in alphabetical order, use ASORT().
  108.  * $EXAMPLES$
  109.  *    // list all directories on the current drive
  110.  *    aTree := FT_TREE()
  111.  *    Aeval( aTree, {|e| Qout(e) } )
  112.  * $INCLUDE$
  113.  * $SEEALSO$
  114.  *    FT_WHEREIS() FT_ORIGIN()
  115.  * $END$
  116.  */
  117.  
  118. FUNCTION FT_TREE( cDrive )
  119.  
  120. LOCAL nDircount, aDirs := {}
  121.  
  122. IF ( nDircount := __ft_tree( cDrive ) ) > 0
  123.    __ft_tree( cDrive, aDirs := Array( nDircount ) )
  124. ENDIF
  125.  
  126. RETURN aDirs
  127.  
  128.