[#BloombergLP-bdls-FdStreamBuf_FileHandler-seek] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdls.adoc[bdls]::xref:BloombergLP/bdls/FdStreamBuf_FileHandler.adoc[FdStreamBuf_FileHandler]::seek :relfileprefix: ../../../ :mrdocs: Set the file position associated with this object according to the specified `offset` and `dir` behavior. == Synopsis Declared in `<bdls_fdstreambuf.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- std::streampos seek( std::streamoff offset, xref:BloombergLP/bdls/FilesystemUtil/Whence.adoc[FilesystemUtil::Whence] dir); ---- == Description * If 'dir' is 'FilesystemUtil::e_SEEK_FROM_BEGINNING', set the position to 'offset' bytes from the beginning of the file. * If 'dir' is 'FilesystemUtil::e_SEEK_FROM_CURRENT', advance the position by 'offset' bytes * If 'dir' is 'FilesystemUtil::e_SEEK_FROM_END', set the position to 'offset' bytes beyond the end of the file. Return the new location of the file position, in bytes from the beginning of the file on success; and `FilesystemUtil::k_INVALID_FD` otherwise. The effect on the file position is undefined unless the file descriptor represents a device capable of seeking. Note that `seek` does not change the size of the file if the position advances beyond the end of the file; instead, the next write at the pointer will increase the file size. Also note that on Windows in text mode, `offset` will be the number of bytes on disk passed over, including `r`s in `\r ` sequences. [.small]#Created with https://www.mrdocs.com[MrDocs]#