]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/interprocess/test/windows_shared_dir_func.cpp
1 //////////////////////////////////////////////////////////////////////////////
3 // (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost
4 // Software License, Version 1.0. (See accompanying file
5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 // See http://www.boost.org/libs/interprocess for documentation.
9 //////////////////////////////////////////////////////////////////////////////
11 #include <boost/config.hpp>
15 //Force user-defined get_shared_dir
16 #define BOOST_INTERPROCESS_SHARED_DIR_FUNC
17 #include <boost/interprocess/detail/shared_dir_helpers.hpp>
20 #include "get_process_id_name.hpp"
23 namespace interprocess
{
26 static bool dir_created
= false;
28 inline void get_shared_dir(std::string
&shared_dir
)
30 shared_dir
= boost::interprocess::ipcdetail::get_temporary_path();
31 shared_dir
+= "/boostipctest_";
32 shared_dir
+= boost::interprocess::test::get_process_id_name();
34 ipcdetail::create_directory(shared_dir
.c_str());
38 }}} //namespace boost::interprocess::ipcdetail
40 #include <boost/interprocess/shared_memory_object.hpp>
45 using namespace boost::interprocess
;
46 const char *const shm_name
= "test_shm";
47 std::string shared_dir
;
48 ipcdetail::get_shared_dir(shared_dir
);
50 std::string
shm_path(shared_dir
);
55 shared_memory_object::remove(shm_name
);
58 shared_memory_object
shm(create_only
, shm_name
, read_write
);
61 ret
= ipcdetail::invalid_file() == ipcdetail::open_existing_file(shm_path
.c_str(), read_only
) ?
65 std::cerr
<< "Error opening user get_shared_dir()/shm file" << std::endl
;
68 shared_memory_object::remove(shm_name
);
69 ipcdetail::remove_directory(shared_dir
.c_str());
81 #endif //#ifdef BOOST_WINDOWS