mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-11 11:34:02 +00:00
Detect write failures on raw_fd_ostream.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75758 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ab52ae8388
commit
579fb87ce7
@ -18,6 +18,7 @@
|
|||||||
#include "llvm/ADT/SmallVector.h"
|
#include "llvm/ADT/SmallVector.h"
|
||||||
#include "llvm/Config/config.h"
|
#include "llvm/Config/config.h"
|
||||||
#include "llvm/Support/Compiler.h"
|
#include "llvm/Support/Compiler.h"
|
||||||
|
#include "llvm/Support/ErrorHandling.h"
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
|
||||||
#if defined(HAVE_UNISTD_H)
|
#if defined(HAVE_UNISTD_H)
|
||||||
@ -285,7 +286,8 @@ raw_fd_ostream::~raw_fd_ostream() {
|
|||||||
void raw_fd_ostream::write_impl(const char *Ptr, unsigned Size) {
|
void raw_fd_ostream::write_impl(const char *Ptr, unsigned Size) {
|
||||||
assert (FD >= 0 && "File already closed.");
|
assert (FD >= 0 && "File already closed.");
|
||||||
pos += Size;
|
pos += Size;
|
||||||
::write(FD, Ptr, Size);
|
if (::write(FD, Ptr, Size) != (ssize_t) Size)
|
||||||
|
llvm_report_error("IO failure writing to output stream.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void raw_fd_ostream::close() {
|
void raw_fd_ostream::close() {
|
||||||
@ -298,7 +300,7 @@ void raw_fd_ostream::close() {
|
|||||||
|
|
||||||
uint64_t raw_fd_ostream::seek(uint64_t off) {
|
uint64_t raw_fd_ostream::seek(uint64_t off) {
|
||||||
flush();
|
flush();
|
||||||
pos = lseek(FD, off, SEEK_SET);
|
pos = ::lseek(FD, off, SEEK_SET);
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user