home *** CD-ROM | disk | FTP | other *** search
/ Groovy Bytes: Behind the Moon / groovybytes.iso / GROOVY / SND_TOOL / FUNK108A.ZIP / DOS32V30.ZIP / PAL / FILEIO / FLENGTH.ASM < prev    next >
Encoding:
Assembly Source File  |  1995-05-20  |  1.4 KB  |  55 lines

  1. ;******************************************************************************
  2. ; Filename: FLENGTH.ASM
  3. ;   Author: Adam Seychell
  4. ;  Version: 0.0
  5. ;  Created: 1994.09.04
  6. ;  Updated: 1995.03.10 PA - Changed to the _fastcall convention
  7. ;           1995.03.12 PA - Changed the name from fsize to filelength
  8. ;******************************************************************************
  9. ; Copyright Adam Seychell, 1994.
  10. ; All rights reserved.
  11. ;******************************************************************************
  12. ; Function: LONG @filelength(LONG handle)
  13. ;  Comment: Returns the length of a file in bytes
  14. ;    Input: Eax, handle - file handle
  15. ;  Returns: file size or -1 if an error occured
  16. ;******************************************************************************
  17.     Include    STDDEF.INC
  18.  
  19.     Codeseg
  20.  
  21. Proc    filelength ,1
  22.         Push    Ebx
  23.         Mov    Ebx,Eax
  24.         Mov     Ax,4200h+SEEK_CUR    ; Get current file position
  25.         Clear    Edx
  26.         Int    21h
  27.         Jc    @@Error
  28.         Push    Eax
  29.         Mov    Ax,4200h+SEEK_END    ; Go to end of file position
  30.         Int    21h
  31.         Pop    Edx
  32.         Push    Eax
  33.         Mov    Ax,4200h+SEEK_SET    ; Return to original position
  34.         Int    21h
  35.         Pop    Eax
  36.                 Pop     Ebx
  37.         Ret
  38.     Align    4
  39. @@Error:    Mov    [Word errno],Ax
  40.     IfDef    DEBUG
  41.         Call    printf,Offset ErrSizeMsg,Bx,Ax
  42.     Endif
  43.             Pop    Ebx
  44.         Mov    Eax,-1
  45.         Ret
  46. Endp
  47.  
  48.     Dataseg
  49.  
  50.     IfDef    DEBUG
  51. ErrSizeMsg    Db    "Error getting file size with handle %h! Error: %h",LF,0
  52.     Endif
  53.  
  54.     End
  55.