Blender  V3.3
fileops.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
7 #include "BLI_fileops.hh"
8 
9 #ifdef WIN32
10 # include "utfconv.h"
11 #endif
12 
13 namespace blender {
14 fstream::fstream(const char *filepath, std::ios_base::openmode mode)
15 {
16  this->open(filepath, mode);
17 }
18 
19 fstream::fstream(const std::string &filepath, std::ios_base::openmode mode)
20 {
21  this->open(filepath, mode);
22 }
23 
24 void fstream::open(StringRefNull filepath, ios_base::openmode mode)
25 {
26 #ifdef WIN32
27  const char *filepath_cstr = filepath.c_str();
28  UTF16_ENCODE(filepath_cstr);
29  std::wstring filepath_wstr(filepath_cstr_16);
30  std::fstream::open(filepath_wstr.c_str(), mode);
31  UTF16_UN_ENCODE(filepath_cstr);
32 #else
33  std::fstream::open(filepath, mode);
34 #endif
35 }
36 
37 } // namespace blender
File and directory operations.
constexpr const char * c_str() const
void open(StringRefNull filepath, ios_base::openmode mode=ios_base::in|ios_base::out)
Definition: fileops.cc:24
fstream()=default
#define UTF16_ENCODE(in8str)
Definition: utfconv.h:83
#define UTF16_UN_ENCODE(in8str)
Definition: utfconv.h:87