Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.5 KiB

  1. /***
  2. *creat.c - create a new file or truncate existing file
  3. *
  4. * Copyright (c) 1989-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * defines _creat() - create new file
  8. *
  9. *Revision History:
  10. * 06-08-89 PHG Module created, based on asm version
  11. * 03-12-90 GJF Made calling type _CALLTYPE1, added #include
  12. * <cruntime.h>, fixed compiler warning and fixed the
  13. * copyright. Also, cleaned up the formatting a bit.
  14. * 09-28-90 GJF New-style function declarator.
  15. * 01-16-91 GJF ANSI naming.
  16. * 04-06-93 SKS Replace _CRTAPI* with __cdecl
  17. * 11-01-93 CFW Enable Unicode variant.
  18. *
  19. *******************************************************************************/
  20. #include <cruntime.h>
  21. #include <io.h>
  22. #include <fcntl.h>
  23. #include <tchar.h>
  24. /***
  25. *int _creat(path, pmode) - create a new file
  26. *
  27. *Purpose:
  28. * If file specified does not exist, _creat creates a new file
  29. * with the given permission setting and opens it for writing.
  30. * If the file already exists and its permission allows writing,
  31. * _creat truncates it to 0 length and open it for writing.
  32. * The only Xenix mode bit supprted by DOS is user write (S_IWRITE).
  33. *
  34. *Entry:
  35. * _TSCHAR *path - filename to create
  36. * int pmode - permission mode setting for new file
  37. *
  38. *Exit:
  39. * returns handle for created file
  40. * returns -1 and sets errno if fails.
  41. *
  42. *Exceptions:
  43. *
  44. *******************************************************************************/
  45. int __cdecl _tcreat (
  46. const _TSCHAR *path,
  47. int pmode
  48. )
  49. {
  50. /* creat is just the same as open... */
  51. return _topen(path, _O_CREAT + _O_TRUNC + _O_RDWR, pmode);
  52. }