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 
9 #ifndef BOOST_WINAPI_DIRECTORY_MANAGEMENT_HPP_INCLUDED_
10 #define BOOST_WINAPI_DIRECTORY_MANAGEMENT_HPP_INCLUDED_
11 
12 #include <boost/winapi/basic_types.hpp>
13 #include <boost/winapi/get_system_directory.hpp>
14 
15 #ifdef BOOST_HAS_PRAGMA_ONCE
16 #pragma once
17 #endif
18 
19 #if !defined( BOOST_USE_WINDOWS_H )
20 extern "C" {
21 #if !defined( BOOST_NO_ANSI_APIS )
22 BOOST_SYMBOL_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
23     CreateDirectoryA(boost::winapi::LPCSTR_, ::_SECURITY_ATTRIBUTES*);
24 #if BOOST_WINAPI_PARTITION_APP_SYSTEM
25 BOOST_SYMBOL_IMPORT boost::winapi::DWORD_ BOOST_WINAPI_WINAPI_CC
26     GetTempPathA(boost::winapi::DWORD_ length, boost::winapi::LPSTR_ buffer);
27 #endif
28 BOOST_SYMBOL_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
29     RemoveDirectoryA(boost::winapi::LPCSTR_);
30 #endif
31 BOOST_SYMBOL_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
32     CreateDirectoryW(boost::winapi::LPCWSTR_, ::_SECURITY_ATTRIBUTES*);
33 #if BOOST_WINAPI_PARTITION_APP_SYSTEM
34 BOOST_SYMBOL_IMPORT boost::winapi::DWORD_ BOOST_WINAPI_WINAPI_CC
35     GetTempPathW(boost::winapi::DWORD_ length, boost::winapi::LPWSTR_ buffer);
36 #endif
37 BOOST_SYMBOL_IMPORT boost::winapi::BOOL_ BOOST_WINAPI_WINAPI_CC
38     RemoveDirectoryW(boost::winapi::LPCWSTR_);
39 } // extern "C"
40 #endif
41 
42 namespace boost {
43 namespace winapi {
44 
45 #if !defined( BOOST_NO_ANSI_APIS )
46 #if BOOST_WINAPI_PARTITION_APP_SYSTEM
47 using ::GetTempPathA;
48 #endif
49 using ::RemoveDirectoryA;
50 #endif
51 #if BOOST_WINAPI_PARTITION_APP_SYSTEM
52 using ::GetTempPathW;
53 #endif
54 using ::RemoveDirectoryW;
55 
56 #if !defined( BOOST_NO_ANSI_APIS )
CreateDirectoryA(LPCSTR_ pPathName,PSECURITY_ATTRIBUTES_ pSecurityAttributes)57 BOOST_FORCEINLINE BOOL_ CreateDirectoryA(LPCSTR_ pPathName, PSECURITY_ATTRIBUTES_ pSecurityAttributes)
58 {
59     return ::CreateDirectoryA(pPathName, reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(pSecurityAttributes));
60 }
61 #endif
62 
CreateDirectoryW(LPCWSTR_ pPathName,PSECURITY_ATTRIBUTES_ pSecurityAttributes)63 BOOST_FORCEINLINE BOOL_ CreateDirectoryW(LPCWSTR_ pPathName, PSECURITY_ATTRIBUTES_ pSecurityAttributes)
64 {
65     return ::CreateDirectoryW(pPathName, reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(pSecurityAttributes));
66 }
67 
68 #if !defined( BOOST_NO_ANSI_APIS )
create_directory(LPCSTR_ pPathName,PSECURITY_ATTRIBUTES_ pSecurityAttributes)69 BOOST_FORCEINLINE BOOL_ create_directory(LPCSTR_ pPathName, PSECURITY_ATTRIBUTES_ pSecurityAttributes)
70 {
71     return ::CreateDirectoryA(pPathName, reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(pSecurityAttributes));
72 }
73 #if BOOST_WINAPI_PARTITION_APP_SYSTEM
get_temp_path(DWORD_ length,LPSTR_ buffer)74 BOOST_FORCEINLINE DWORD_ get_temp_path(DWORD_ length, LPSTR_ buffer)
75 {
76     return ::GetTempPathA(length, buffer);
77 }
78 #endif
remove_directory(LPCSTR_ pPathName)79 BOOST_FORCEINLINE BOOL_ remove_directory(LPCSTR_ pPathName)
80 {
81     return ::RemoveDirectoryA(pPathName);
82 }
83 #endif
84 
create_directory(LPCWSTR_ pPathName,PSECURITY_ATTRIBUTES_ pSecurityAttributes)85 BOOST_FORCEINLINE BOOL_ create_directory(LPCWSTR_ pPathName, PSECURITY_ATTRIBUTES_ pSecurityAttributes)
86 {
87     return ::CreateDirectoryW(pPathName, reinterpret_cast< ::_SECURITY_ATTRIBUTES* >(pSecurityAttributes));
88 }
89 #if BOOST_WINAPI_PARTITION_APP_SYSTEM
get_temp_path(DWORD_ length,LPWSTR_ buffer)90 BOOST_FORCEINLINE DWORD_ get_temp_path(DWORD_ length, LPWSTR_ buffer)
91 {
92     return ::GetTempPathW(length, buffer);
93 }
94 #endif
remove_directory(LPCWSTR_ pPathName)95 BOOST_FORCEINLINE BOOL_ remove_directory(LPCWSTR_ pPathName)
96 {
97     return ::RemoveDirectoryW(pPathName);
98 }
99 
100 } // namespace winapi
101 } // namespace boost
102 
103 #endif // BOOST_WINAPI_DIRECTORY_MANAGEMENT_HPP_INCLUDED_
104