| 94 | } |
| 95 | |
| 96 | void TFileTransport::resetOutputFile(int fd, string filename, off_t offset) { |
| 97 | filename_ = filename; |
| 98 | offset_ = offset; |
| 99 | |
| 100 | // check if current file is still open |
| 101 | if (fd_ > 0) { |
| 102 | // flush any events in the queue |
| 103 | flush(); |
| 104 | TOutput::instance().printf("error, current file (%s) not closed", filename_.c_str()); |
| 105 | if (-1 == ::THRIFT_CLOSE(fd_)) { |
| 106 | int errno_copy = THRIFT_ERRNO; |
| 107 | TOutput::instance().perror("TFileTransport: resetOutputFile() ::close() ", errno_copy); |
| 108 | throw TTransportException(TTransportException::UNKNOWN, |
| 109 | "TFileTransport: error in file close", |
| 110 | errno_copy); |
| 111 | } else { |
| 112 | // successfully closed fd |
| 113 | fd_ = 0; |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | if (fd) { |
| 118 | fd_ = fd; |
| 119 | } else { |
| 120 | // open file if the input fd is 0 |
| 121 | openLogFile(); |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | TFileTransport::~TFileTransport() { |
| 126 | // flush the buffer if a writer thread is active |
nothing calls this directly
no test coverage detected