Skip to content

Commit

Permalink
Merge pull request #156 from EOSIO/cfile_datastream_tellp
Browse files Browse the repository at this point in the history
add tellp() member function to cfile_datastream
  • Loading branch information
huangminghuang authored Apr 10, 2020
2 parents dae9acc + 75e16d6 commit 412ef3d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions include/fc/io/cfile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,12 @@ class cfile {
_open = true;
}

long tellp() const {
return ftell( _file.get() );
size_t tellp() const {
long result = ftell( _file.get() );
if (result == -1)
throw std::ios_base::failure("cfile: " + get_file_path().generic_string() +
" unable to get the current position of the file, error: " + std::to_string( errno ));
return static_cast<size_t>(result);
}

void seek( long loc ) {
Expand Down Expand Up @@ -145,7 +149,9 @@ class cfile_datastream {

bool get( char& c ) { return read(&c, 1); }

private:
size_t tellp() const { return cf.tellp(); }

private:
cfile& cf;
};

Expand Down

0 comments on commit 412ef3d

Please sign in to comment.