Path: blob/main/contrib/llvm-project/libcxx/src/ostream.cpp
35154 views
//===----------------------------------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include <__config>9#ifndef _LIBCPP_HAS_NO_FILESYSTEM10# include <fstream>11#endif12#include <ostream>1314#include "std_stream.h"1516_LIBCPP_BEGIN_NAMESPACE_STD1718_LIBCPP_EXPORTED_FROM_ABI FILE* __get_ostream_file(ostream& __os) {19// dynamic_cast requires RTTI, this only affects users whose vendor builds20// the dylib with RTTI disabled. It does not affect users who build with RTTI21// disabled but use a dylib where the RTTI is enabled.22//23// Returning a nullptr means the stream is not considered a terminal and the24// special terminal handling is not done. The terminal handling is mainly of25// importance on Windows.26#ifndef _LIBCPP_HAS_NO_RTTI27auto* __rdbuf = __os.rdbuf();28# ifndef _LIBCPP_HAS_NO_FILESYSTEM29if (auto* __buffer = dynamic_cast<filebuf*>(__rdbuf))30return __buffer->__file_;31# endif3233if (auto* __buffer = dynamic_cast<__stdoutbuf<char>*>(__rdbuf))34return __buffer->__file_;35#endif // _LIBCPP_HAS_NO_RTTI3637return nullptr;38}3940_LIBCPP_END_NAMESPACE_STD414243