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