directory_management.hpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * Copyright 2010 Vicente J. Botet Escriba
  3. * Copyright 2015 Andrey Semashev
  4. *
  5. * Distributed under the Boost Software License, Version 1.0.
  6. * See http://www.boost.org/LICENSE_1_0.txt
  7. */
  8. #ifndef BOOST_WINAPI_DIRECTORY_MANAGEMENT_HPP_INCLUDED_
  9. #define BOOST_WINAPI_DIRECTORY_MANAGEMENT_HPP_INCLUDED_
  10. #include <boost/winapi/basic_types.hpp>
  11. #include <boost/winapi/get_system_directory.hpp>
  12. #include <boost/winapi/detail/header.hpp>
  13. #ifdef BOOST_HAS_PRAGMA_ONCE
  14. #pragma once
  15. #endif
  16. #if !defined( BOOST_USE_WINDOWS_H )
  17. extern "C" {
  18. #if !defined( BOOST_NO_ANSI_APIS )
  19. BOOST_WINAPI_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
  20. CreateDirectoryA(boost::winapi::LPCSTR_, ::_SECURITY_ATTRIBUTES*);
  21. #if BOOST_WINAPI_PARTITION_APP_SYSTEM
  22. BOOST_WINAPI_IMPORT boost::winapi::DWORD_ BOOST_WINAPI_WINAPI_CC
  23. GetTempPathA(boost::winapi::DWORD_ length, boost::winapi::LPSTR_ buffer);
  24. #endif
  25. BOOST_WINAPI_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
  26. RemoveDirectoryA(boost::winapi::LPCSTR_);
  27. #endif
  28. BOOST_WINAPI_IMPORT_EXCEPT_WM boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
  29. CreateDirectoryW(boost::winapi::LPCWSTR_, ::_SECURITY_ATTRIBUTES*);
  30. #if BOOST_WINAPI_PARTITION_APP_SYSTEM
  31. BOOST_WINAPI_IMPORT_EXCEPT_WM boost::winapi::DWORD_ BOOST_WINAPI_WINAPI_CC
  32. GetTempPathW(boost::winapi::DWORD_ length, boost::winapi::LPWSTR_ buffer);
  33. #endif
  34. BOOST_WINAPI_IMPORT_EXCEPT_WM boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
  35. RemoveDirectoryW(boost::winapi::LPCWSTR_);
  36. } // extern "C"
  37. #endif
  38. namespace boost {
  39. namespace winapi {
  40. #if !defined( BOOST_NO_ANSI_APIS )
  41. #if BOOST_WINAPI_PARTITION_APP_SYSTEM
  42. using ::GetTempPathA;
  43. #endif
  44. using ::RemoveDirectoryA;
  45. #endif
  46. #if BOOST_WINAPI_PARTITION_APP_SYSTEM
  47. using ::GetTempPathW;
  48. #endif
  49. using ::RemoveDirectoryW;
  50. #if !defined( BOOST_NO_ANSI_APIS )
  51. BOOST_FORCEINLINE BOOL_ CreateDirectoryA(LPCSTR_ pPathName, PSECURITY_ATTRIBUTES_ pSecurityAttributes)
  52. {
  53. return ::CreateDirectoryA(pPathName, reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(pSecurityAttributes));
  54. }
  55. #endif
  56. BOOST_FORCEINLINE BOOL_ CreateDirectoryW(LPCWSTR_ pPathName, PSECURITY_ATTRIBUTES_ pSecurityAttributes)
  57. {
  58. return ::CreateDirectoryW(pPathName, reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(pSecurityAttributes));
  59. }
  60. #if !defined( BOOST_NO_ANSI_APIS )
  61. BOOST_FORCEINLINE BOOL_ create_directory(LPCSTR_ pPathName, PSECURITY_ATTRIBUTES_ pSecurityAttributes)
  62. {
  63. return ::CreateDirectoryA(pPathName, reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(pSecurityAttributes));
  64. }
  65. #if BOOST_WINAPI_PARTITION_APP_SYSTEM
  66. BOOST_FORCEINLINE DWORD_ get_temp_path(DWORD_ length, LPSTR_ buffer)
  67. {
  68. return ::GetTempPathA(length, buffer);
  69. }
  70. #endif
  71. BOOST_FORCEINLINE BOOL_ remove_directory(LPCSTR_ pPathName)
  72. {
  73. return ::RemoveDirectoryA(pPathName);
  74. }
  75. #endif
  76. BOOST_FORCEINLINE BOOL_ create_directory(LPCWSTR_ pPathName, PSECURITY_ATTRIBUTES_ pSecurityAttributes)
  77. {
  78. return ::CreateDirectoryW(pPathName, reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(pSecurityAttributes));
  79. }
  80. #if BOOST_WINAPI_PARTITION_APP_SYSTEM
  81. BOOST_FORCEINLINE DWORD_ get_temp_path(DWORD_ length, LPWSTR_ buffer)
  82. {
  83. return ::GetTempPathW(length, buffer);
  84. }
  85. #endif
  86. BOOST_FORCEINLINE BOOL_ remove_directory(LPCWSTR_ pPathName)
  87. {
  88. return ::RemoveDirectoryW(pPathName);
  89. }
  90. } // namespace winapi
  91. } // namespace boost
  92. #include <boost/winapi/detail/footer.hpp>
  93. #endif // BOOST_WINAPI_DIRECTORY_MANAGEMENT_HPP_INCLUDED_