Blender V5.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
8
9#include "BLI_fileops.hh"
10
11#ifdef WIN32
12# include "utfconv.hh"
13#endif
14
15namespace blender {
16
17fstream::fstream(const char *filepath, std::ios_base::openmode mode)
18{
19 this->open(filepath, mode);
20}
21
22fstream::fstream(const std::string &filepath, std::ios_base::openmode mode)
23{
24 this->open(filepath, mode);
25}
26
27void fstream::open(StringRefNull filepath, ios_base::openmode mode)
28{
29#ifdef WIN32
30 const char *filepath_cstr = filepath.c_str();
31 UTF16_ENCODE(filepath_cstr);
32 std::wstring filepath_wstr(filepath_cstr_16);
33 std::fstream::open(filepath_wstr.c_str(), mode);
34 UTF16_UN_ENCODE(filepath_cstr);
35#else
36 std::fstream::open(filepath, mode);
37#endif
38}
39
40} // 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:27
fstream()=default
BMesh Iterators.
#define UTF16_ENCODE(in8str)
Definition utfconv.hh:80
#define UTF16_UN_ENCODE(in8str)
Definition utfconv.hh:84