mirror of
https://github.com/boostorg/interprocess.git
synced 2026-01-19 04:12:13 +00:00
Fixes #145 ("1.76 now requires unicode paths on windows")
This commit is contained in:
@@ -6664,8 +6664,9 @@ can force this Event Log based timestamp defining BOOST_INTERPROCESS_BOOTSTAMP_I
|
|||||||
|
|
||||||
In any error case (shared documents folder is not defined or bootup time could not be obtained), the library throws an error. You still
|
In any error case (shared documents folder is not defined or bootup time could not be obtained), the library throws an error. You still
|
||||||
can use [*Boost.Interprocess] defining your own directory as the shared directory. When your shared directory is a compile-time constant,
|
can use [*Boost.Interprocess] defining your own directory as the shared directory. When your shared directory is a compile-time constant,
|
||||||
define `BOOST_INTERPROCESS_SHARED_DIR_PATH` when using the library and that path will be used to place shared memory files. When you have
|
define `BOOST_INTERPROCESS_SHARED_DIR_PATH` (and BOOST_INTERPROCESS_SHARED_DIR_WPATH in Windows systems) when using the library and that
|
||||||
to determine the shared directory at runtime, define `BOOST_INTERPROCESS_SHARED_DIR_FUNC` and implement the function
|
path will be used to place shared memory files. When you have to determine the shared directory at runtime,
|
||||||
|
define `BOOST_INTERPROCESS_SHARED_DIR_FUNC` and implement the following functions
|
||||||
|
|
||||||
[c++]
|
[c++]
|
||||||
|
|
||||||
@@ -6673,6 +6674,8 @@ to determine the shared directory at runtime, define `BOOST_INTERPROCESS_SHARED_
|
|||||||
namespace interprocess {
|
namespace interprocess {
|
||||||
namespace ipcdetail {
|
namespace ipcdetail {
|
||||||
void get_shared_dir(std::string &shared_dir);
|
void get_shared_dir(std::string &shared_dir);
|
||||||
|
//wstring overload is only needed for Windows systems
|
||||||
|
void get_shared_dir(std::wstring &shared_dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6792,6 +6795,14 @@ thank them:
|
|||||||
|
|
||||||
[section:release_notes Release Notes]
|
[section:release_notes Release Notes]
|
||||||
|
|
||||||
|
[section:release_notes_boost_1_78_00 Boost 1.78 Release]
|
||||||
|
|
||||||
|
* Fixed bugs:
|
||||||
|
* [@https://github.com/boostorg/interprocess/issues/145 GitHub #145 (['"1.76 now requires unicode paths on windows"])].
|
||||||
|
|
||||||
|
[endsect]
|
||||||
|
|
||||||
|
|
||||||
[section:release_notes_boost_1_77_00 Boost 1.77 Release]
|
[section:release_notes_boost_1_77_00 Boost 1.77 Release]
|
||||||
|
|
||||||
* Interprocess no longer depends on Boost.DateTime. Instead, all timed
|
* Interprocess no longer depends on Boost.DateTime. Instead, all timed
|
||||||
|
|||||||
@@ -104,7 +104,8 @@ template<class CharT>
|
|||||||
inline bool create_directory(const CharT *path)
|
inline bool create_directory(const CharT *path)
|
||||||
{ return winapi::create_directory(path); }
|
{ return winapi::create_directory(path); }
|
||||||
|
|
||||||
inline bool remove_directory(const char *path)
|
template <class CharT>
|
||||||
|
inline bool remove_directory(const CharT *path)
|
||||||
{ return winapi::remove_directory(path); }
|
{ return winapi::remove_directory(path); }
|
||||||
|
|
||||||
inline bool get_temporary_path(char *buffer, std::size_t buf_len, std::size_t &required_len)
|
inline bool get_temporary_path(char *buffer, std::size_t buf_len, std::size_t &required_len)
|
||||||
|
|||||||
@@ -161,18 +161,32 @@ inline void get_shared_dir_root(std::basic_string<CharT> &dir_path)
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
#if defined(BOOST_INTERPROCESS_SHARED_DIR_PATH)
|
||||||
|
|
||||||
|
inline void get_shared_dir(std::string &shared_dir)
|
||||||
|
{
|
||||||
|
shared_dir = BOOST_INTERPROCESS_SHARED_DIR_PATH;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(BOOST_INTERPROCESS_SHARED_DIR_WPATH)
|
||||||
|
|
||||||
|
inline void get_shared_dir(std::wstring &shared_dir)
|
||||||
|
{
|
||||||
|
shared_dir = BOOST_INTERPROCESS_SHARED_DIR_WPATH;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
template<class CharT>
|
template<class CharT>
|
||||||
inline void get_shared_dir(std::basic_string<CharT> &shared_dir)
|
inline void get_shared_dir(std::basic_string<CharT> &shared_dir)
|
||||||
{
|
{
|
||||||
#if defined(BOOST_INTERPROCESS_SHARED_DIR_PATH)
|
|
||||||
shared_dir = BOOST_INTERPROCESS_SHARED_DIR_PATH;
|
|
||||||
#else
|
|
||||||
get_shared_dir_root(shared_dir);
|
get_shared_dir_root(shared_dir);
|
||||||
#if defined(BOOST_INTERPROCESS_HAS_KERNEL_BOOTTIME)
|
#if defined(BOOST_INTERPROCESS_HAS_KERNEL_BOOTTIME)
|
||||||
shared_dir += shared_dir_constants<CharT>::dir_separator();
|
shared_dir += shared_dir_constants<CharT>::dir_separator();
|
||||||
get_bootstamp(shared_dir, true);
|
get_bootstamp(shared_dir, true);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
91
test/windows_shared_dir_path.cpp
Normal file
91
test/windows_shared_dir_path.cpp
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost
|
||||||
|
// Software License, Version 1.0. (See accompanying file
|
||||||
|
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
// See http://www.boost.org/libs/interprocess for documentation.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
|
||||||
|
#ifdef BOOST_WINDOWS
|
||||||
|
|
||||||
|
//Force user-defined get_shared_dir
|
||||||
|
#define BOOST_INTERPROCESS_SHARED_DIR_PATH boost::interprocess::ipcdetail::get_temporary_path()
|
||||||
|
#define BOOST_INTERPROCESS_SHARED_DIR_WPATH boost::interprocess::ipcdetail::get_temporary_wpath()
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "get_process_id_name.hpp"
|
||||||
|
|
||||||
|
#include <boost/interprocess/shared_memory_object.hpp>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
int main ()
|
||||||
|
{
|
||||||
|
using namespace boost::interprocess;
|
||||||
|
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
{
|
||||||
|
std::string pname= boost::interprocess::test::get_process_id_name();
|
||||||
|
const char *const shm_name = pname.c_str();
|
||||||
|
|
||||||
|
shared_memory_object::remove(shm_name);
|
||||||
|
std::string shared_dir;
|
||||||
|
ipcdetail::get_shared_dir(shared_dir);
|
||||||
|
|
||||||
|
std::string shm_path(shared_dir);
|
||||||
|
shm_path += "/";
|
||||||
|
shm_path += shm_name;
|
||||||
|
{
|
||||||
|
shared_memory_object shm(create_only, shm_name, read_write);
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = ipcdetail::invalid_file() == ipcdetail::open_existing_file(shm_path.c_str(), read_only) ?
|
||||||
|
1 : 0;
|
||||||
|
if(ret)
|
||||||
|
{
|
||||||
|
std::cerr << "Error opening user get_shared_dir()/shm file" << std::endl;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
shared_memory_object::remove(shm_name);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::wstring wpname= boost::interprocess::test::get_process_id_wname();
|
||||||
|
const wchar_t *const wshm_name = wpname.c_str();
|
||||||
|
|
||||||
|
shared_memory_object::remove(wshm_name);
|
||||||
|
std::wstring wshared_dir;
|
||||||
|
ipcdetail::get_shared_dir(wshared_dir);
|
||||||
|
|
||||||
|
shared_memory_object::remove(wshm_name);
|
||||||
|
std::wstring wshm_path(wshared_dir);
|
||||||
|
wshm_path += L"/";
|
||||||
|
wshm_path += wshm_name;
|
||||||
|
{
|
||||||
|
shared_memory_object shm(create_only, wshm_name, read_write);
|
||||||
|
}
|
||||||
|
ret = ipcdetail::invalid_file() == ipcdetail::open_existing_file(wshm_path.c_str(), read_only) ?
|
||||||
|
1 : 0;
|
||||||
|
if(ret)
|
||||||
|
{
|
||||||
|
std::cerr << "Error opening user get_shared_dir()/wshm file" << std::endl;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
shared_memory_object::remove(wshm_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //#ifdef BOOST_WINDOWS
|
||||||
Reference in New Issue
Block a user