From eeb63b8901a9c049f1bb594abb9ce9b4a9c47620 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 11 Jan 2021 16:39:43 +0000 Subject: zlib -> libdeflate (#5085) + Use libdeflate + Use std::byte * Fix passing temporary to string_view + Emulate make_unique_for_overwrite --- src/OSSupport/File.h | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'src/OSSupport/File.h') diff --git a/src/OSSupport/File.h b/src/OSSupport/File.h index 59f3a5558..7a3333483 100644 --- a/src/OSSupport/File.h +++ b/src/OSSupport/File.h @@ -75,7 +75,7 @@ public: int Read(void * a_Buffer, size_t a_NumBytes); /** Reads up to a_NumBytes bytes, returns the bytes actually read, or empty string on failure; asserts if not open */ - AString Read(size_t a_NumBytes); + std::basic_string Read(size_t a_NumBytes); /** Writes up to a_NumBytes bytes from a_Buffer, returns the number of bytes actually written, or -1 on failure; asserts if not open */ int Write(const void * a_Buffer, size_t a_NumBytes); @@ -192,17 +192,8 @@ class FileStream final : public StreamType { public: - FileStream(const std::string & Path) - { - // Except on failbit, which is what open sets on failure: - FileStream::exceptions(FileStream::failbit | FileStream::badbit); - - // Open the file: - FileStream::open(Path); - - // Only subsequently except on serious errors, and not on conditions like EOF or malformed input: - FileStream::exceptions(FileStream::badbit); - } + FileStream(const std::string & Path); + FileStream(const std::string & Path, const typename FileStream::openmode Mode); }; @@ -211,3 +202,15 @@ public: using InputFileStream = FileStream; using OutputFileStream = FileStream; + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wweak-template-vtables" // http://bugs.llvm.org/show_bug.cgi?id=18733 +#endif + +extern template class FileStream; +extern template class FileStream; + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif -- cgit v1.2.3