home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / crt / src / creat.c < prev    next >
C/C++ Source or Header  |  1998-06-17  |  1KB  |  46 lines

  1. /***
  2. *creat.c - create a new file or truncate existing file
  3. *
  4. *       Copyright (c) 1989-1997, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. *       defines _creat() - create new file
  8. *
  9. *******************************************************************************/
  10.  
  11. #include <cruntime.h>
  12. #include <io.h>
  13. #include <fcntl.h>
  14. #include <tchar.h>
  15.  
  16. /***
  17. *int _creat(path, pmode) - create a new file
  18. *
  19. *Purpose:
  20. *       If file specified does not exist, _creat creates a new file
  21. *       with the given permission setting and opens it for writing.
  22. *       If the file already exists and its permission allows writing,
  23. *       _creat truncates it to 0 length and open it for writing.
  24. *       The only Xenix mode bit supprted by DOS is user write (S_IWRITE).
  25. *
  26. *Entry:
  27. *       _TSCHAR *path - filename to create
  28. *       int pmode - permission mode setting for new file
  29. *
  30. *Exit:
  31. *       returns handle for created file
  32. *       returns -1 and sets errno if fails.
  33. *
  34. *Exceptions:
  35. *
  36. *******************************************************************************/
  37.  
  38. int __cdecl _tcreat (
  39.         const _TSCHAR *path,
  40.         int pmode
  41.         )
  42. {
  43.         /* creat is just the same as open... */
  44.         return _topen(path, _O_CREAT + _O_TRUNC + _O_RDWR, pmode);
  45. }
  46.