|
Boost : |
Subject: [boost] windows_shared_memory - does memory block exists?
From: piotr.ns (piotr.ns2012_at_[hidden])
Date: 2013-07-21 15:47:59
Hi,
Why native windows shared memory does not include any means to check
for existance of memory block without throwing exceptions?
A small function would be enough:
// boost::interprocess::windows_shared_memory
static bool exists(const std::string &a_path)
{
using namespace boost::interprocess;
try {
unsigned long file_map_access = winapi::page_readonly;
unsigned long map_access = winapi::file_map_read;
void *test_handle = winapi::open_file_mapping(map_access, a_path.c_str());
bool res = (test_handle != NULL);
if(res)
winapi::close_handle(test_handle);
return res;
}
catch(...) {
return false;
}
}
Without this I have to use Boost internals (winapi::*) in my
application.
Would somebody consider including this code or something similar?
Regards,
Piotr
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk