1 // Copyright Daniel Wallin 2006. Use, modification and distribution is
2 // subject to the Boost Software License, Version 1.0. (See accompanying
3 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5 #include <boost/python.hpp>
6 #include <boost/filesystem/path.hpp>
8 using namespace boost::python
;
12 static PyObject
* convert(boost::filesystem::path
const& p
)
14 return incref(object(p
.string()).ptr());
18 struct path_from_python
22 converter::registry::push_back(
23 &convertible
, &construct
, type_id
<boost::filesystem::path
>()
27 static void* convertible(PyObject
* x
)
29 return PyString_Check(x
) ? x
: 0;
32 static void construct(PyObject
* x
, converter::rvalue_from_python_stage1_data
* data
)
34 void* storage
= ((converter::rvalue_from_python_storage
<
35 boost::filesystem::path
36 >*)data
)->storage
.bytes
;
37 new (storage
) boost::filesystem::path(PyString_AsString(x
));
38 data
->convertible
= storage
;
42 void bind_filesystem()
44 to_python_converter
<boost::filesystem::path
, path_to_python
>();
47 using namespace boost::filesystem
;
48 if (path::default_name_check_writable())
49 path::default_name_check(no_check
);