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.

72 lines
2.1 KiB

  1. /***
  2. *mkdir.c - make directory
  3. *
  4. * Copyright (c) 1989-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * Defines function _mkdir() - make a directory
  8. *
  9. *Revision History:
  10. * 06-06-89 PHG Module created, based on asm version
  11. * 03-07-90 GJF Made calling type _CALLTYPE2 (for now), added #include
  12. * <cruntime.h>, fixed compiler warnings and fixed the
  13. * copyright. Also, cleaned up the formatting a bit.
  14. * 03-30-90 GJF Now _CALLTYPE1.
  15. * 07-24-90 SBM Removed '32' from API names
  16. * 09-27-90 GJF New-style function declarator.
  17. * 12-04-90 SRW Changed to include <oscalls.h> instead of <doscalls.h>
  18. * 12-06-90 SRW Added _CRUISER_ and _WIN32 conditionals.
  19. * 01-16-91 GJF ANSI naming.
  20. * 04-06-93 SKS Replace _CRTAPI* with __cdecl
  21. * 11-01-93 CFW Enable Unicode variant, rip out Cruiser.
  22. * 02-08-95 JWM Spliced _WIN32 & Mac versions.
  23. * 07-01-96 GJF Replaced defined(_WIN32) with !defined(_MAC). Also,
  24. * detab-ed and cleaned up the format a bit.
  25. * 05-17-99 PML Remove all Macintosh support.
  26. *
  27. *******************************************************************************/
  28. #include <cruntime.h>
  29. #include <oscalls.h>
  30. #include <internal.h>
  31. #include <direct.h>
  32. #include <tchar.h>
  33. /***
  34. *int _mkdir(path) - make a directory
  35. *
  36. *Purpose:
  37. * creates a new directory with the specified name
  38. *
  39. *Entry:
  40. * _TSCHAR *path - name of new directory
  41. *
  42. *Exit:
  43. * returns 0 if successful
  44. * returns -1 and sets errno if unsuccessful
  45. *
  46. *Exceptions:
  47. *
  48. *******************************************************************************/
  49. int __cdecl _tmkdir (
  50. const _TSCHAR *path
  51. )
  52. {
  53. ULONG dosretval;
  54. /* ask OS to create directory */
  55. if (!CreateDirectory((LPTSTR)path, (LPSECURITY_ATTRIBUTES)NULL))
  56. dosretval = GetLastError();
  57. else
  58. dosretval = 0;
  59. if (dosretval) {
  60. /* error occured -- map error code and return */
  61. _dosmaperr(dosretval);
  62. return -1;
  63. }
  64. return 0;
  65. }