inline void create_shared_dir_and_clean_old(std::string &shared_dir) { #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; get_shared_dir_root(root_shared_dir); //If fails, check that it's because already exists if(!create_directory(root_shared_dir.c_str())){ error_info info(system_error_code()); if(info.get_error_code() != already_exists_error){ throw interprocess_exception(info); } } #if defined(BOOST_INTERPROCESS_HAS_KERNEL_BOOTTIME) get_shared_dir(shared_dir); //If fails, check that it's because already exists if(!create_directory(shared_dir.c_str())){ error_info info(system_error_code()); if(info.get_error_code() != already_exists_error){ throw interprocess_exception(info); } } //Now erase all old directories created in the previous boot sessions std::string subdir = shared_dir; subdir.erase(0, root_shared_dir.size()+1); delete_subdirectories(root_shared_dir, subdir.c_str()); #else shared_dir = root_shared_dir; #endif #endif }
inline void shared_filepath(const char *filename, std::string &filepath) { get_shared_dir(filepath); filepath += "/"; filepath += filename; }
inline void robust_lock_path(std::string &s) { get_shared_dir(s); s += "/"; s += robust_lock_subdir_path(); }