diff options
Diffstat (limited to 'boost/interprocess/detail/shared_dir_helpers.hpp')
-rwxr-xr-x[-rw-r--r--] | boost/interprocess/detail/shared_dir_helpers.hpp | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/boost/interprocess/detail/shared_dir_helpers.hpp b/boost/interprocess/detail/shared_dir_helpers.hpp index a0ac766f4c..5d4d1b3842 100644..100755 --- a/boost/interprocess/detail/shared_dir_helpers.hpp +++ b/boost/interprocess/detail/shared_dir_helpers.hpp @@ -106,9 +106,10 @@ inline void get_shared_dir_root(std::string &dir_path) { #if defined (BOOST_INTERPROCESS_WINDOWS) winapi::get_shared_documents_folder(dir_path); - #else + #else dir_path = "/tmp"; #endif + //We always need this path, so throw on error if(dir_path.empty()){ error_info err = system_error_code(); @@ -118,11 +119,26 @@ inline void get_shared_dir_root(std::string &dir_path) dir_path += "/boost_interprocess"; } +#if defined(BOOST_INTERPROCESS_SHARED_DIR_FUNC) && defined(BOOST_INTERPROCESS_SHARED_DIR_PATH) +#error "Error: Both BOOST_INTERPROCESS_SHARED_DIR_FUNC and BOOST_INTERPROCESS_SHARED_DIR_PATH defined!" +#endif + +#ifdef BOOST_INTERPROCESS_SHARED_DIR_FUNC +namespace boost { + namespace interprocess { + namespace ipcdetail { + // When BOOST_INTERPROCESS_SHARED_DIR_FUNC is defined, users have to implement + // get_shared_dir + void get_shared_dir(std::string &shared_dir); + } + } +} +#else inline void get_shared_dir(std::string &shared_dir) { #if defined(BOOST_INTERPROCESS_SHARED_DIR_PATH) shared_dir = BOOST_INTERPROCESS_SHARED_DIR_PATH; - #else + #else get_shared_dir_root(shared_dir); #if defined(BOOST_INTERPROCESS_HAS_KERNEL_BOOTTIME) shared_dir += "/"; @@ -130,6 +146,7 @@ inline void get_shared_dir(std::string &shared_dir) #endif #endif } +#endif inline void shared_filepath(const char *filename, std::string &filepath) { @@ -140,8 +157,8 @@ inline void shared_filepath(const char *filename, std::string &filepath) inline void create_shared_dir_and_clean_old(std::string &shared_dir) { - #if defined(BOOST_INTERPROCESS_SHARED_DIR_PATH) - shared_dir = BOOST_INTERPROCESS_SHARED_DIR_PATH; + #if defined(BOOST_INTERPROCESS_SHARED_DIR_PATH) || defined(BOOST_INTERPROCESS_SHARED_DIR_FUNC) + get_shared_dir(shared_dir); #else //First get the temp directory std::string root_shared_dir; |