Namespaces
Variants
Views
Actions

std::basic_filebuf::seekpos

From cppreference.com
< cpp‎ | io‎ | basic filebuf
Revision as of 22:56, 31 May 2013 by P12bot (Talk | contribs)

protected:

virtual pos_type seekpos( pos_type sp,

                          std::ios_base::openmode which = std::ios_base::in | std::ios_base::out );

Repositions the file pointer, if possible, to the position indicated by sp.

If the associated file is not open (is_open()==false), fails immediately.

If the file is open for writing, first writes the put area and any unshift sequences required by the currently imbued locale, using Template:rlpf

Then repositions the file pointer, as by calling std::fseek

If the file is open for reading, updates the get area if necessary.

If sp was not obtained by calling Template:rlpf or Template:rlpf on the same file, the behavior is undefined.

Contents

Parameters

sp - file position obtained by Template:rlpf or Template:rlpf called earlier on the same file
which - defines which of the input and/or output sequences to affect. It can be one or a combination of the following constants:
Constant Explanation
in affect the input sequence
out affect the output sequence

Return value

sp on success or pos_type(off_type(-1)) on failure.

Notes

seekpos() is called by std::basic_streambuf::pubseekpos, which is called by the single-argument versions of std::basic_istream::seekg and std::basic_ostream::seekp

Example

See also

invokes seekpos()
(public member function of std::basic_streambuf) [edit]
[virtual]
repositions the file position, using relative addressing
(virtual protected member function) [edit]
moves the file position indicator to a specific location in a file
(function) [edit]