Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenlib/intern/fileops.cc
- This file was added.
| /* | |||||
| * This program is free software; you can redistribute it and/or | |||||
| * modify it under the terms of the GNU General Public License | |||||
| * as published by the Free Software Foundation; either version 2 | |||||
| * of the License, or (at your option) any later version. | |||||
| * | |||||
| * This program is distributed in the hope that it will be useful, | |||||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | |||||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||||
| * GNU General Public License for more details. | |||||
| * | |||||
| * You should have received a copy of the GNU General Public License | |||||
| * along with this program; if not, write to the Free Software Foundation, | |||||
| * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||||
| */ | |||||
| /** \file | |||||
| * \ingroup bli | |||||
| */ | |||||
| #include "BLI_fileops.hh" | |||||
| #ifdef WIN32 | |||||
| # include "utfconv.h" | |||||
| #endif | |||||
| namespace blender { | |||||
| fstream::fstream(const char *filepath, std::ios_base::openmode mode) | |||||
| { | |||||
JacquesLucke: Use `= default;`. Clang tidy might warn here, haven't tried. | |||||
| this->open(filepath, mode); | |||||
| } | |||||
| fstream::fstream(const std::string &filepath, std::ios_base::openmode mode) | |||||
Done Inline ActionsClang tidy might warn here as well. JacquesLucke: Clang tidy might warn here as well.
It's not necessary to call the constructor of the base… | |||||
| { | |||||
| this->open(filepath, mode); | |||||
| } | |||||
| void fstream::open(StringRefNull filepath, ios_base::openmode mode) | |||||
| { | |||||
| #ifdef WIN32 | |||||
| const char *filepath_cstr = filepath.c_str(); | |||||
| UTF16_ENCODE(filepath_cstr); | |||||
| std::wstring filepath_wstr(filepath_cstr_16); | |||||
| std::fstream::open(filepath_wstr.c_str(), mode); | |||||
| UTF16_UN_ENCODE(filepath_cstr); | |||||
| #else | |||||
| std::fstream::open(filepath, mode); | |||||
| #endif | |||||
Done Inline ActionsI'm surprised that std::fstream::open seems to just do nothing in case of an error (would have expected it to throw an exception). JacquesLucke: I'm surprised that `std::fstream::open` seems to just do nothing in case of an error (would… | |||||
Done Inline ActionsIt doesn't raise an exception, which is why T93960 silently fails. sybren: It doesn't raise an exception, which is why T93960 silently fails. | |||||
| } | |||||
| } // namespace blender | |||||
Use = default;. Clang tidy might warn here, haven't tried.