Skip to content

Commit

Permalink
api: IOProxy const method adjustments (#4415)
Browse files Browse the repository at this point in the history
With 3.0 approaching, it seems like the only time to make these changes
that I made note of a while back:

* It seems to me that `tell()` should be const because it isn't going to
modify or change the state of the IOProxy.

* It seems to me that `flush()` should NOT be const, because it probably
does change internal state.

Signed-off-by: Larry Gritz <lg@larrygritz.com>
  • Loading branch information
lgritz authored Sep 14, 2024
1 parent 37a814f commit ce82f61
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/include/OpenImageIO/filesystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ class OIIO_UTIL_API IOProxy {
virtual const char* proxytype () const = 0;
virtual void close () { }
virtual bool opened () const { return mode() != Closed; }
virtual int64_t tell () { return m_pos; }
virtual int64_t tell() const { return m_pos; }
// Seek to the position, returning true on success, false on failure.
// Note the difference between this and std::fseek() which returns 0 on
// success, and -1 on failure.
Expand Down Expand Up @@ -440,7 +440,7 @@ class OIIO_UTIL_API IOProxy {

// Return the total size of the proxy data, in bytes.
virtual size_t size () const { return 0; }
virtual void flush () const { }
virtual void flush() { }

Mode mode () const { return m_mode; }
const std::string& filename () const { return m_filename; }
Expand Down Expand Up @@ -491,7 +491,7 @@ class OIIO_UTIL_API IOFile : public IOProxy {
size_t pread(void* buf, size_t size, int64_t offset) override;
size_t pwrite(const void* buf, size_t size, int64_t offset) override;
size_t size() const override;
void flush() const override;
void flush() override;

// Access the FILE*
FILE* handle() const { return m_file; }
Expand Down
2 changes: 1 addition & 1 deletion src/libutil/filesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1309,7 +1309,7 @@ Filesystem::IOFile::size() const
}

void
Filesystem::IOFile::flush() const
Filesystem::IOFile::flush()
{
if (m_file)
fflush(m_file);
Expand Down

0 comments on commit ce82f61

Please sign in to comment.