Leaked source code of windows server 2003
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.

74 lines
2.3 KiB

  1. /***
  2. *rmdir.c - remove directory
  3. *
  4. * Copyright (c) 1989-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * defines _rmdir() - remove 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 _rmdir(path) - remove a directory
  35. *
  36. *Purpose:
  37. * deletes the directory speicifed by path. The directory must
  38. * be empty, and it must not be the current working directory or
  39. * the root directory.
  40. *
  41. *Entry:
  42. * _TSCHAR *path - directory to remove
  43. *
  44. *Exit:
  45. * returns 0 if successful
  46. * returns -1 and sets errno if unsuccessful
  47. *
  48. *Exceptions:
  49. *
  50. *******************************************************************************/
  51. int __cdecl _trmdir (
  52. const _TSCHAR *path
  53. )
  54. {
  55. ULONG dosretval;
  56. /* ask OS to remove directory */
  57. if (!RemoveDirectory((LPTSTR)path))
  58. dosretval = GetLastError();
  59. else
  60. dosretval = 0;
  61. if (dosretval) {
  62. /* error occured -- map error code and return */
  63. _dosmaperr(dosretval);
  64. return -1;
  65. }
  66. return 0;
  67. }