Index: util/file/file_writer_posix.cc |
diff --git a/util/file/file_writer.cc b/util/file/file_writer_posix.cc |
similarity index 79% |
copy from util/file/file_writer.cc |
copy to util/file/file_writer_posix.cc |
index 4f833051122ecc6fc88ff9fc48473b8626e6158f..533f787b996a910ddaab165377cf93ab819bacb4 100644 |
--- a/util/file/file_writer.cc |
+++ b/util/file/file_writer_posix.cc |
@@ -20,7 +20,6 @@ |
#include "base/logging.h" |
#include "base/posix/eintr_wrapper.h" |
-#include "util/file/file_io.h" |
namespace crashpad { |
@@ -31,19 +30,13 @@ static_assert(offsetof(WritableIoVec, iov_base) == offsetof(iovec, iov_base), |
static_assert(offsetof(WritableIoVec, iov_len) == offsetof(iovec, iov_len), |
"WritableIoVec len offset"); |
-FileWriter::FileWriter() : fd_() { |
-} |
- |
-FileWriter::~FileWriter() { |
-} |
- |
-bool FileWriter::Open(const base::FilePath& path, int oflag, mode_t mode) { |
- CHECK(!fd_.is_valid()); |
+bool FileWriter::Open(const base::FilePath& path, int oflag, uint32_t mode) { |
+ CHECK(!file.is_valid()); |
DCHECK((oflag & O_WRONLY) || (oflag & O_RDWR)); |
- fd_.reset(HANDLE_EINTR(open(path.value().c_str(), oflag, mode))); |
- if (!fd_.is_valid()) { |
+ file.reset(HANDLE_EINTR(open(path.value().c_str(), oflag, mode))); |
+ if (!file.is_valid()) { |
PLOG(ERROR) << "open " << path.value(); |
return false; |
} |
@@ -51,28 +44,6 @@ bool FileWriter::Open(const base::FilePath& path, int oflag, mode_t mode) { |
return true; |
} |
-void FileWriter::Close() { |
- CHECK(fd_.is_valid()); |
- |
- fd_.reset(); |
-} |
- |
-bool FileWriter::Write(const void* data, size_t size) { |
- DCHECK(fd_.is_valid()); |
- |
- // TODO(mark): Write no more than SSIZE_MAX bytes in a single call. |
- ssize_t written = WriteFile(fd_.get(), data, size); |
- if (written < 0) { |
- PLOG(ERROR) << "write"; |
- return false; |
- } else if (written == 0) { |
- LOG(ERROR) << "write: returned 0"; |
- return false; |
- } |
- |
- return true; |
-} |
- |
bool FileWriter::WriteIoVec(std::vector<WritableIoVec>* iovecs) { |
DCHECK(fd_.is_valid()); |
@@ -137,10 +108,10 @@ bool FileWriter::WriteIoVec(std::vector<WritableIoVec>* iovecs) { |
return true; |
} |
-off_t FileWriter::Seek(off_t offset, int whence) { |
- DCHECK(fd_.is_valid()); |
+FileOffset FileWriter::Seek(FileOffset offset, int whence) { |
+ DCHECK(file_.is_valid()); |
- off_t rv = lseek(fd_.get(), offset, whence); |
+ off_t rv = lseek(file_.get(), offset, whence); |
if (rv < 0) { |
PLOG(ERROR) << "lseek"; |
} |