| // Copyright 2010 Google Inc. All Rights Reserved. |
| LinuxFile::~LinuxFile() { |
| // Close the file if necessary (unless it's a standard stream). |
| if (auto_close_ && fd_ > STDERR_FILENO) { |
| void LinuxFile::Close() { |
| PLOG(WARNING) << "Problem closing " << name(); |
| bool LinuxFile::IsClosed() { |
| int64_t LinuxFile::Read(void* buffer, int64_t num_bytes) { |
| return read(fd_, buffer, num_bytes); |
| int64_t LinuxFile::Write(const void* buffer, int64_t num_bytes) { |
| return write(fd_, buffer, num_bytes); |
| off_t LinuxFile::Position() { |
| return lseek(fd_, 0, SEEK_CUR); |
| off_t LinuxFile::Length() { |
| off_t position = lseek(fd_, 0, SEEK_CUR); |
| // The file is not capable of seeking. Return an error. |
| off_t result = lseek(fd_, 0, SEEK_END); |
| lseek(fd_, position, SEEK_SET); |