@@ -362,6 +362,9 @@ private:
362
362
bool __read_mode ();
363
363
void __write_mode ();
364
364
365
+ static int __fseek (FILE* __file, pos_type __offset, int __whence);
366
+ static pos_type __ftell (FILE* __file);
367
+
365
368
_LIBCPP_EXPORTED_FROM_ABI friend FILE* __get_ostream_file (ostream&);
366
369
367
370
// There are multiple (__)open function, they use different C-API open
@@ -936,38 +939,44 @@ basic_filebuf<_CharT, _Traits>::seekoff(off_type __off, ios_base::seekdir __way,
936
939
default :
937
940
return pos_type (off_type (-1 ));
938
941
}
939
- # if defined(_LIBCPP_MSVCRT_LIKE)
940
- if (_fseeki64 (__file_, __width > 0 ? __width * __off : 0 , __whence))
942
+ if (__fseek (__file_, __width > 0 ? __width * __off : 0 , __whence))
941
943
return pos_type (off_type (-1 ));
942
- pos_type __r = _ftelli64 (__file_);
944
+ pos_type __r = __ftell (__file_);
945
+ __r.state (__st_);
946
+ return __r;
947
+ }
948
+
949
+ template <class _CharT , class _Traits >
950
+ int
951
+ basic_filebuf<_CharT, _Traits>::__fseek (FILE* __file, pos_type __offset, int __whence) {
952
+ # if defined(_LIBCPP_MSVCRT_LIKE)
953
+ return _fseeki64 (__file, __offset, __whence);
943
954
# elif !_LIBCPP_HAS_OFF_T_FUNCTIONS
944
- if (fseek (__file_, __width > 0 ? __width * __off : 0 , __whence))
945
- return pos_type (off_type (-1 ));
946
- pos_type __r = ftell (__file_);
955
+ return fseek (__file, __offset, __whence);
947
956
# else
948
- if (::fseeko (__file_, __width > 0 ? __width * __off : 0 , __whence))
949
- return pos_type (off_type (-1 ));
950
- pos_type __r = ftello (__file_);
957
+ return ::fseeko (__file, __offset, __whence);
951
958
# endif
952
- __r.state (__st_);
953
- return __r;
954
959
}
955
960
956
961
template <class _CharT , class _Traits >
957
962
typename basic_filebuf<_CharT, _Traits>::pos_type
958
- basic_filebuf<_CharT, _Traits>::seekpos (pos_type __sp, ios_base::openmode) {
959
- if (__file_ == nullptr || sync ())
960
- return pos_type (off_type (-1 ));
963
+ basic_filebuf<_CharT, _Traits>::__ftell (FILE* __file) {
961
964
# if defined(_LIBCPP_MSVCRT_LIKE)
962
- if (_fseeki64 (__file_, __sp, SEEK_SET))
963
- return pos_type (off_type (-1 ));
965
+ return _ftelli64 (__file);
964
966
# elif !_LIBCPP_HAS_OFF_T_FUNCTIONS
965
- if (fseek (__file_, __sp, SEEK_SET))
966
- return pos_type (off_type (-1 ));
967
+ return ftell (__file);
967
968
# else
968
- if (::fseeko (__file_, __sp, SEEK_SET))
969
- return pos_type (off_type (-1 ));
969
+ return ftello (__file);
970
970
# endif
971
+ }
972
+
973
+ template <class _CharT , class _Traits >
974
+ typename basic_filebuf<_CharT, _Traits>::pos_type
975
+ basic_filebuf<_CharT, _Traits>::seekpos (pos_type __sp, ios_base::openmode) {
976
+ if (__file_ == nullptr || sync ())
977
+ return pos_type (off_type (-1 ));
978
+ if (__fseek (__file_, __sp, SEEK_SET))
979
+ return pos_type (off_type (-1 ));
971
980
__st_ = __sp.state ();
972
981
return __sp;
973
982
}
@@ -1014,13 +1023,8 @@ int basic_filebuf<_CharT, _Traits>::sync() {
1014
1023
}
1015
1024
}
1016
1025
}
1017
- # if !_LIBCPP_HAS_OFF_T_FUNCTIONS
1018
- if (fseek (__file_, -__c, SEEK_CUR))
1026
+ if (__fseek (__file_, -__c, SEEK_CUR))
1019
1027
return -1 ;
1020
- # else
1021
- if (::fseeko (__file_, -__c, SEEK_CUR))
1022
- return -1 ;
1023
- # endif
1024
1028
if (__update_st)
1025
1029
__st_ = __state;
1026
1030
__extbufnext_ = __extbufend_ = __extbuf_;
0 commit comments