@@ -216,12 +216,6 @@ typedef basic_fstream<wchar_t> wfstream;
216
216
_LIBCPP_PUSH_MACROS
217
217
# include < __undef_macros>
218
218
219
- # if !defined(_LIBCPP_MSVCRT) && !defined(_NEWLIB_VERSION)
220
- # define _LIBCPP_HAS_OFF_T_FUNCTIONS 1
221
- # else
222
- # define _LIBCPP_HAS_OFF_T_FUNCTIONS 0
223
- # endif
224
-
225
219
# if _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION
226
220
227
221
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -362,6 +356,9 @@ private:
362
356
bool __read_mode ();
363
357
void __write_mode ();
364
358
359
+ _LIBCPP_HIDE_FROM_ABI static int __fseek (FILE* __file, pos_type __offset, int __whence);
360
+ _LIBCPP_HIDE_FROM_ABI static pos_type __ftell (FILE* __file);
361
+
365
362
_LIBCPP_EXPORTED_FROM_ABI friend FILE* __get_ostream_file (ostream&);
366
363
367
364
// There are multiple (__)open function, they use different C-API open
@@ -936,31 +933,42 @@ basic_filebuf<_CharT, _Traits>::seekoff(off_type __off, ios_base::seekdir __way,
936
933
default :
937
934
return pos_type (off_type (-1 ));
938
935
}
939
- # if !_LIBCPP_HAS_OFF_T_FUNCTIONS
940
- if (fseek (__file_, __width > 0 ? __width * __off : 0 , __whence))
936
+ if (__fseek (__file_, __width > 0 ? __width * __off : 0 , __whence))
941
937
return pos_type (off_type (-1 ));
942
- pos_type __r = ftell (__file_);
943
- # else
944
- if (::fseeko (__file_, __width > 0 ? __width * __off : 0 , __whence))
945
- return pos_type (off_type (-1 ));
946
- pos_type __r = ftello (__file_);
947
- # endif
938
+ pos_type __r = __ftell (__file_);
948
939
__r.state (__st_);
949
940
return __r;
950
941
}
951
942
943
+ template <class _CharT , class _Traits >
944
+ int basic_filebuf<_CharT, _Traits>::__fseek (FILE* __file, pos_type __offset, int __whence) {
945
+ # if defined(_LIBCPP_MSVCRT_LIKE)
946
+ return _fseeki64 (__file, __offset, __whence);
947
+ # elif defined(_NEWLIB_VERSION)
948
+ return fseek (__file, __offset, __whence);
949
+ # else
950
+ return ::fseeko (__file, __offset, __whence);
951
+ # endif
952
+ }
953
+
954
+ template <class _CharT , class _Traits >
955
+ typename basic_filebuf<_CharT, _Traits>::pos_type basic_filebuf<_CharT, _Traits>::__ftell (FILE* __file) {
956
+ # if defined(_LIBCPP_MSVCRT_LIKE)
957
+ return _ftelli64 (__file);
958
+ # elif defined(_NEWLIB_VERSION)
959
+ return ftell (__file);
960
+ # else
961
+ return ftello (__file);
962
+ # endif
963
+ }
964
+
952
965
template <class _CharT , class _Traits >
953
966
typename basic_filebuf<_CharT, _Traits>::pos_type
954
967
basic_filebuf<_CharT, _Traits>::seekpos (pos_type __sp, ios_base::openmode) {
955
968
if (__file_ == nullptr || sync ())
956
969
return pos_type (off_type (-1 ));
957
- # if !_LIBCPP_HAS_OFF_T_FUNCTIONS
958
- if (fseek (__file_, __sp, SEEK_SET))
970
+ if (__fseek (__file_, __sp, SEEK_SET))
959
971
return pos_type (off_type (-1 ));
960
- # else
961
- if (::fseeko (__file_, __sp, SEEK_SET))
962
- return pos_type (off_type (-1 ));
963
- # endif
964
972
__st_ = __sp.state ();
965
973
return __sp;
966
974
}
@@ -1007,13 +1015,8 @@ int basic_filebuf<_CharT, _Traits>::sync() {
1007
1015
}
1008
1016
}
1009
1017
}
1010
- # if !_LIBCPP_HAS_OFF_T_FUNCTIONS
1011
- if (fseek (__file_, -__c, SEEK_CUR))
1018
+ if (__fseek (__file_, -__c, SEEK_CUR))
1012
1019
return -1 ;
1013
- # else
1014
- if (::fseeko (__file_, -__c, SEEK_CUR))
1015
- return -1 ;
1016
- # endif
1017
1020
if (__update_st)
1018
1021
__st_ = __state;
1019
1022
__extbufnext_ = __extbufend_ = __extbuf_;
0 commit comments