Deprecated File::Eof.

Change-Id: I0cca5e175babcdeeb982f981f97f8dd1b0ae9649
This commit is contained in:
Thomas Inskip 2015-03-20 15:32:59 -07:00
parent 5ce7afeda4
commit 0ff596e75b
8 changed files with 4 additions and 27 deletions

View File

@ -66,9 +66,6 @@ class File {
/// @return true on success, false otherwise. /// @return true on success, false otherwise.
virtual bool Flush() = 0; virtual bool Flush() = 0;
/// @return true if the file reaches eof, false otherwise.
virtual bool Eof() = 0;
/// @return The file name. /// @return The file name.
const std::string& file_name() const { return file_name_; } const std::string& file_name() const { return file_name_; }

View File

@ -80,16 +80,16 @@ TEST_F(LocalFileTest, Read_And_Eof) {
File* file = File::Open(local_file_name_.c_str(), "r"); File* file = File::Open(local_file_name_.c_str(), "r");
ASSERT_TRUE(file != NULL); ASSERT_TRUE(file != NULL);
// Read half of the file and verify that Eof is not true. // Read half of the file.
const int kFirstReadBytes = kDataSize / 2; const int kFirstReadBytes = kDataSize / 2;
std::string read_data(kFirstReadBytes + kDataSize, 0); std::string read_data(kFirstReadBytes + kDataSize, 0);
EXPECT_EQ(kFirstReadBytes, file->Read(&read_data[0], kFirstReadBytes)); EXPECT_EQ(kFirstReadBytes, file->Read(&read_data[0], kFirstReadBytes));
EXPECT_FALSE(file->Eof());
// Read the remaining half of the file and verify Eof is true. // Read the remaining half of the file and verify EOF.
EXPECT_EQ(kDataSize - kFirstReadBytes, EXPECT_EQ(kDataSize - kFirstReadBytes,
file->Read(&read_data[kFirstReadBytes], kDataSize)); file->Read(&read_data[kFirstReadBytes], kDataSize));
EXPECT_TRUE(file->Eof()); uint8_t single_byte;
EXPECT_EQ(0, file->Read(&single_byte, sizeof(single_byte)));
EXPECT_TRUE(file->Close()); EXPECT_TRUE(file->Close());
// Compare data written and read. // Compare data written and read.

View File

@ -59,11 +59,6 @@ bool LocalFile::Flush() {
return ((fflush(internal_file_) == 0) && !ferror(internal_file_)); return ((fflush(internal_file_) == 0) && !ferror(internal_file_));
} }
bool LocalFile::Eof() {
DCHECK(internal_file_ != NULL);
return static_cast<bool>(feof(internal_file_));
}
LocalFile::~LocalFile() {} LocalFile::~LocalFile() {}
bool LocalFile::Open() { bool LocalFile::Open() {

View File

@ -32,7 +32,6 @@ class LocalFile : public File {
virtual int64_t Write(const void* buffer, uint64_t length) OVERRIDE; virtual int64_t Write(const void* buffer, uint64_t length) OVERRIDE;
virtual int64_t Size() OVERRIDE; virtual int64_t Size() OVERRIDE;
virtual bool Flush() OVERRIDE; virtual bool Flush() OVERRIDE;
virtual bool Eof() OVERRIDE;
/// @} /// @}
/// Delete a local file. /// Delete a local file.

View File

@ -109,14 +109,6 @@ bool ThreadedIoFile::Flush() {
return internal_file_->Flush(); return internal_file_->Flush();
} }
bool ThreadedIoFile::Eof() {
DCHECK(internal_file_);
DCHECK(thread_);
DCHECK_EQ(kInputMode, mode_);
return eof_ && !cache_.BytesCached();
}
void ThreadedIoFile::RunInInputMode() { void ThreadedIoFile::RunInInputMode() {
DCHECK(internal_file_); DCHECK(internal_file_);
DCHECK(thread_); DCHECK(thread_);

View File

@ -38,7 +38,6 @@ class ThreadedIoFile : public File {
virtual int64_t Write(const void* buffer, uint64_t length) OVERRIDE; virtual int64_t Write(const void* buffer, uint64_t length) OVERRIDE;
virtual int64_t Size() OVERRIDE; virtual int64_t Size() OVERRIDE;
virtual bool Flush() OVERRIDE; virtual bool Flush() OVERRIDE;
virtual bool Eof() OVERRIDE;
/// @} /// @}
protected: protected:

View File

@ -129,10 +129,6 @@ bool UdpFile::Flush() {
return false; return false;
} }
bool UdpFile::Eof() {
return socket_ == kInvalidSocket;
}
class ScopedSocket { class ScopedSocket {
public: public:
explicit ScopedSocket(int sock_fd) explicit ScopedSocket(int sock_fd)

View File

@ -31,7 +31,6 @@ class UdpFile : public File {
virtual int64_t Write(const void* buffer, uint64_t length) OVERRIDE; virtual int64_t Write(const void* buffer, uint64_t length) OVERRIDE;
virtual int64_t Size() OVERRIDE; virtual int64_t Size() OVERRIDE;
virtual bool Flush() OVERRIDE; virtual bool Flush() OVERRIDE;
virtual bool Eof() OVERRIDE;
/// @} /// @}
protected: protected: