home *** CD-ROM | disk | FTP | other *** search
/ Power CD-ROM!! 7 / POWERCD7.ISO / prgmming / clipper / fsize.prg < prev    next >
Text File  |  1993-10-14  |  1KB  |  59 lines

  1. /*
  2.  * File......: FSIZE.PRG
  3.  * Author....: Dave Pearson
  4.  * BBS.......: The Dark Knight Returns
  5.  * Net/Node..: 050/069
  6.  * User Name.: Dave Pearson
  7.  * Date......: 13/04/93
  8.  * Revision..: 1.0
  9.  *
  10.  * This is an original work by Dave Pearson and is placed in the public
  11.  * domain.
  12.  *
  13.  * Modification history:
  14.  * ---------------------
  15.  *
  16.  * $Log$
  17.  *
  18.  */
  19.  
  20. #include "gt_lib.ch"
  21.  
  22. /*  $DOC$
  23.  *  $FUNCNAME$
  24.  *      GT_FSIZE()
  25.  *  $CATEGORY$
  26.  *      File I/O
  27.  *  $ONELINER$
  28.  *      Return the size in bytes of a low level file.
  29.  *  $SYNTAX$
  30.  *      GT_FSize(<nFileHandle>) --> nSizeInBytes
  31.  *  $ARGUMENTS$
  32.  *      <nFileHandle> is the handle of a file that has been opened or
  33.  *      created with one of Clipper's low level file functions.
  34.  *  $RETURNS$
  35.  *      The size of the file in bytes.
  36.  *  $DESCRIPTION$
  37.  *      GT_FSize() can be used for finding the size of a file opened with
  38.  *      Clipper's low level file functions.
  39.  *  $EXAMPLES$
  40.  *      // Print the size of a file.
  41.  *
  42.  *      local nFile := fopen("LIFE.42")
  43.  *      ? GT_FSize(nFile)     // Print the size of the file.
  44.  *      fclose(nFile)
  45.  *  $SEEALSO$
  46.  *      GT_FTELL() GT_FLOCATE()
  47.  *  $END$
  48.  */
  49.  
  50. function GT_FSize(nFileHandle)
  51. local nOldPos := 0,;
  52.       nSize   := -1
  53. if valtype(nFileHandle) == TYPE_NUMERIC
  54.    nOldPos := GT_FTell(nFileHandle)
  55.    nSize   := fseek(nFileHandle,0,FS_END)
  56.    fseek(nFileHandle,nOldPos)
  57. endif
  58. return(nSize)
  59.