home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0020 - 0029 / ibm0020-0029 / ibm0028.tar / ibm0028 / GRLF-C-2.ZIP / GFUNC / CRUNFILE.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-05-30  |  1.5 KB  |  68 lines

  1. ;/*
  2. ;** crunfile.asm
  3. ;** contains:    crunfile()
  4. ;*/
  5.  
  6. CREATEUNIQUEFILE    equ    05ah        ;Create unique file function
  7. DOSCALL         equ    021h        ;DOS Software Interrupt
  8.  
  9.         include model.h
  10.         include prologue.h
  11.  
  12.         ReferVar    _gferror,<cWord>
  13.  
  14.         pseg    ccrunfile
  15.  
  16. ;/*
  17. ;**  int
  18. ;** crunfile(unsigned attribute, char *pathname)
  19. ;**
  20. ;** ARGUMENT(s)
  21. ;**  attribute        -
  22. ;**  pathname        -    Pointer to ASCIIZ path ending with a
  23. ;**                backslash (\).
  24. ;**
  25. ;** DESCRIPTION
  26. ;**  This function generates a uniqe name and attempts to create a new file
  27. ;**  in the specified directory.  If the file already exists in the
  28. ;**  directory then another unique name is generated and the process is
  29. ;**  repeated.    Programs that need temporary files should use this
  30. ;**  function call to generate unique filenames.
  31. ;**
  32. ;**
  33. ;** RETURNS
  34. ;**  Either a file handle or -1 in which case the error code can be found
  35. ;**  the global variable _gferror
  36. ;**
  37. ;** AUTHOR
  38. ;**  ""   Fri 11-Nov-1988    14:08:15
  39. ;**   Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
  40. ;**
  41. ;** MODIFICATIONS
  42. ;**
  43. ;*/
  44.         cproc    crunfile
  45.         mov    cx,parm1_
  46.         if    _LDATA
  47.          push    ds
  48.          lds    dx,parm2_        ;DS:DX points to path name
  49.         else
  50.          mov    dx,parm2_        ;DS:DX points to path name
  51.         endif
  52.         mov    ah,CREATEUNIQUEFILE
  53.         int    DOSCALL
  54.         jnc    createexit
  55.         ifdef    DSNOTHING
  56.          mov    bx,seg _gferror
  57.          mov    ds,bx
  58.         endif
  59.         mov    _gferror,ax        ;put error in error variable
  60.         mov    ax,-1            ;and return -1
  61. createexit:
  62.         if    _LDATA
  63.          pop    ds
  64.         endif
  65.         cproce
  66.         endps
  67.         end
  68.