Skip to content
Snippets Groups Projects
Commit ee97f3a0 authored by Rye Mutt's avatar Rye Mutt :bread:
Browse files

Clean up llifstream wrapper on windows

parent 83626960
No related branches found
No related tags found
No related merge requests found
...@@ -641,42 +641,6 @@ LLFILE * LLFile::_Fiopen(const std::string& filename, ...@@ -641,42 +641,6 @@ LLFILE * LLFile::_Fiopen(const std::string& filename,
#if LL_WINDOWS #if LL_WINDOWS
/************** input file stream ********************************/
llifstream::llifstream() {}
// explicit
llifstream::llifstream(const std::string& _Filename, ios_base::openmode _Mode):
std::ifstream(ll_convert_string_to_wide( _Filename ).c_str(),
_Mode | ios_base::in)
{
}
void llifstream::open(const std::string& _Filename, ios_base::openmode _Mode)
{
std::ifstream::open(ll_convert_string_to_wide(_Filename).c_str(),
_Mode | ios_base::in);
}
/************** output file stream ********************************/
llofstream::llofstream() {}
// explicit
llofstream::llofstream(const std::string& _Filename, ios_base::openmode _Mode):
std::ofstream(ll_convert_string_to_wide( _Filename ).c_str(),
_Mode | ios_base::out)
{
}
void llofstream::open(const std::string& _Filename, ios_base::openmode _Mode)
{
std::ofstream::open(ll_convert_string_to_wide( _Filename ).c_str(),
_Mode | ios_base::out);
}
/************** helper functions ********************************/ /************** helper functions ********************************/
std::streamsize llifstream_size(llifstream& ifstr) std::streamsize llifstream_size(llifstream& ifstr)
......
...@@ -167,92 +167,37 @@ class LLUniqueFile ...@@ -167,92 +167,37 @@ class LLUniqueFile
#if LL_WINDOWS #if LL_WINDOWS
/** /**
* @brief Controlling input for files. * @brief Wrapper for UTF16 path compatibility on windows operating systems
* */
* This class supports reading from named files, using the inherited template< typename BaseType, std::ios_base::openmode DEFAULT_MODE>
* functions from std::ifstream. The only added value is that our constructor class LL_COMMON_API stream_wrapper : public BaseType {
* Does The Right Thing when passed a non-ASCII pathname. Sadly, that isn't public:
* true of Microsoft's std::ifstream.
*/
class LL_COMMON_API llifstream : public std::ifstream
{
// input stream associated with a C stream
public:
// Constructors:
/**
* @brief Default constructor.
*
* Initializes @c sb using its default constructor, and passes
* @c &sb to the base class initializer. Does not open any files
* (you haven't given it a filename to open).
*/
llifstream();
/**
* @brief Create an input file stream.
* @param Filename String specifying the filename.
* @param Mode Open file in specified mode (see std::ios_base).
*
* @c ios_base::in is automatically included in @a mode.
*/
explicit llifstream(const std::string& _Filename,
ios_base::openmode _Mode = ios_base::in);
/**
* @brief Opens an external file.
* @param Filename The name of the file.
* @param Node The open mode flags.
*
* Calls @c llstdio_filebuf::open(s,mode|in). If that function
* fails, @c failbit is set in the stream's error state.
*/
void open(const std::string& _Filename,
ios_base::openmode _Mode = ios_base::in);
};
stream_wrapper() = default;
/** explicit stream_wrapper(char const* _Filename, std::ios_base::openmode _Mode = DEFAULT_MODE)
* @brief Controlling output for files. : BaseType(ll_convert_string_to_wide(_Filename).c_str(), _Mode)
* {
* This class supports writing to named files, using the inherited functions }
* from std::ofstream. The only added value is that our constructor Does The
* Right Thing when passed a non-ASCII pathname. Sadly, that isn't true of explicit stream_wrapper(const std::string& _Filename, std::ios_base::openmode _Mode = DEFAULT_MODE)
* Microsoft's std::ofstream. : BaseType(ll_convert_string_to_wide(_Filename), _Mode)
*/ {
class LL_COMMON_API llofstream : public std::ofstream }
{
public: void open(char const* _Filename, std::ios_base::openmode _Mode = DEFAULT_MODE) {
// Constructors: BaseType::open(ll_convert_string_to_wide(_Filename).c_str(), _Mode);
/** }
* @brief Default constructor.
* void open(const std::string& _Filename, std::ios_base::openmode _Mode = DEFAULT_MODE) {
* Initializes @c sb using its default constructor, and passes BaseType::open(ll_convert_string_to_wide(_Filename), _Mode);
* @c &sb to the base class initializer. Does not open any files }
* (you haven't given it a filename to open).
*/
llofstream();
/**
* @brief Create an output file stream.
* @param Filename String specifying the filename.
* @param Mode Open file in specified mode (see std::ios_base).
*
* @c ios_base::out is automatically included in @a mode.
*/
explicit llofstream(const std::string& _Filename,
ios_base::openmode _Mode = ios_base::out|ios_base::trunc);
/**
* @brief Opens an external file.
* @param Filename The name of the file.
* @param Node The open mode flags.
*
* @c ios_base::out is automatically included in @a mode.
*/
void open(const std::string& _Filename,
ios_base::openmode _Mode = ios_base::out|ios_base::trunc);
}; };
typedef stream_wrapper<std::fstream, std::ios_base::in | std::ios_base::out > llfstream;
typedef stream_wrapper<std::ifstream, std::ios_base::in > llifstream;
typedef stream_wrapper<std::ofstream, std::ios_base::out | std::ios_base::trunc > llofstream;
/** /**
* @breif filesize helpers. * @breif filesize helpers.
...@@ -267,6 +212,7 @@ std::streamsize LL_COMMON_API llofstream_size(llofstream& fstr); ...@@ -267,6 +212,7 @@ std::streamsize LL_COMMON_API llofstream_size(llofstream& fstr);
#else // ! LL_WINDOWS #else // ! LL_WINDOWS
// on non-windows, llifstream and llofstream are just mapped directly to the std:: equivalents // on non-windows, llifstream and llofstream are just mapped directly to the std:: equivalents
typedef std::fstream llfstream;
typedef std::ifstream llifstream; typedef std::ifstream llifstream;
typedef std::ofstream llofstream; typedef std::ofstream llofstream;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment