Boost logo

Boost :

Subject: [boost] Using boost::filesystem with TCHAR
From: Rob Caldecott (robert.caldecott_at_[hidden])
Date: 2008-11-25 06:48:52


I wish to use the boost::filesystem library with some Windows apps and want to
define TCHAR-friendly types. I *think* the following code should do the trick,
giving me a boost::filesystem::tpath type, but is there anything I've missed?

tpath.hpp

#include <boost/filesystem.hpp>

namespace boost {
namespace filesystem {

struct tpath_traits;
typedef basic_path<std::basic_string<TCHAR>, tpath_traits> tpath;

struct tpath_traits
{
        typedef std::basic_string<TCHAR> internal_string_type;
        typedef std::basic_string<TCHAR> external_string_type;
        static external_string_type to_external( const tpath &,
                const internal_string_type & src ) { return src; }
        static internal_string_type to_internal(
                const external_string_type & src ) { return src; }
};

} // filesystem
} // boost


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk