home *** CD-ROM | disk | FTP | other *** search
/ Hall of Fame / HallofFameCDROM.cdr / proglc / tnylib.lzh / CREAT.ASM < prev    next >
Encoding:
Assembly Source File  |  1986-08-30  |  958 b   |  42 lines

  1. include compiler.inc
  2. ttl    CREAT, 1.03, 08/03/86, clr
  3. ;
  4. ;
  5. ;  NAME:          creat - create a new file
  6. ;
  7. ;  Synopsis:      int creat(fname)
  8. ;                 char *fname;            ; file name to create
  9. ;
  10. ;  Description:   creat() creates a file and opens it for write-only access.
  11. ;                 If the file already exists, it is truncated so that nothing
  12. ;                 is in it.  creat() returns as its value a file handle, which
  13. ;                 is used by other standard i/o functions.  This handle is
  14. ;                 unique for each file opened or created.  If creat() fails,
  15. ;                 it returns a -1, and sets the global error value.
  16. ;
  17. ;
  18. ;
  19. dseg
  20.     exterr
  21. cseg
  22.  
  23.     procdef creat,<<fname,ptr>>
  24.  
  25.     ldptr dx,fname,ds        ;name pointer
  26.     xor    ax,ax
  27.     moverr    ax
  28.     xor    cx,cx            ;no attributes
  29.     mov    ax,3C00h        ;on new file
  30.     int    21h
  31.     jnb    ex2            ;created OK
  32.  
  33. err:
  34.     moverr ax        ;error
  35.     mov    ax,-1
  36.  
  37. ex2:
  38.     pret
  39.     pend    creat
  40.  
  41.     finish
  42.