$id frontmatter=

| Filesystem Library Version 3

Filesystem Home Releases Reference Tutorial FAQ Portability V3 Intro V3 Design Deprecated

# Reference Documentation

$endid $id wording_prefix=

## Introduction

This reference documentation describes components that C++ programs may use to perform operations involving file systems, including paths, regular files, and directories.

$endid $id wording_suffix=

### File streams - <boost/filesystem/fstream.hpp>

Replacements are provided for the file stream classes from the C++ standard library's `<fstream>` header. These replacement classes publicly inherit from the standard library classes. In the Boost.Filesystem version, constructors and open functions take `const path&` arguments instead of `const char*` arguments. There are no other differences in syntax or semantics.

    $NAMESPACE_BEGIN;
        template < class charT, class traits = std::char_traits<charT> >
        class basic_filebuf : public std::basic_filebuf<charT,traits>
        {
        public:
          basic_filebuf<charT,traits>*
            open(const path& p, std::ios_base::openmode mode);
        };

        template < class charT, class traits = std::char_traits<charT> >
        class basic_ifstream : public std::basic_ifstream<charT,traits>
        {
        public:
          explicit basic_ifstream(const path& p, std::ios_base::openmode mode=std::ios_base::in)
          void open(const path& p, std::ios_base::openmode mode=std::ios_base::in);
        };

        template < class charT, class traits = std::char_traits<charT> >
        class basic_ofstream : public std::basic_ofstream<charT,traits>
        {
        public:
          explicit basic_ofstream(const path& p, std::ios_base::openmode mode=std::ios_base::out);
          void open(const path& p, std::ios_base::openmode mode=std::ios_base::out);
        };

        template < class charT, class traits = std::char_traits<charT> >
        class basic_fstream : public std::basic_fstream<charT,traits>
        {
        public:
          explicit basic_fstream(const path& p,
            std::ios_base::openmode mode=std::ios_base::in | std::ios_base::out);
          void open(const path& p,
            std::ios_base::openmode mode=std::ios_base::in | std::ios_base::out);
        };

        typedef basic_filebuf<char> filebuf;
        typedef basic_ifstream<char> ifstream;
        typedef basic_ofstream<char> ofstream;
        typedef basic_fstream<char> fstream;

        typedef basic_filebuf<wchar_t> wfilebuf;
        typedef basic_ifstream<wchar_t> wifstream;
        typedef basic_fstream<wchar_t> wfstream;
        typedef basic_ofstream<wchar_t> wofstream;

    $NAMESPACE_END;

$endid $id backmatter=>

© Copyright Beman Dawes, 2002, 2006, 2007, 2009, 2010, 2011

Distributed under the Boost Software License, Version 1.0. See www.boost.org/LICENSE_1_0.txt

Revised 13 January 2012

$endid