mirror of
https://github.com/reactos/reactos.git
synced 2025-05-20 09:36:16 +00:00
[CRT]
* Update fgetpos(). CORE-8080 svn path=/trunk/; revision=63410
This commit is contained in:
parent
17be1062a2
commit
e849ca97bc
1 changed files with 2 additions and 27 deletions
|
@ -3416,34 +3416,9 @@ LONG CDECL ftell(FILE* file)
|
||||||
*/
|
*/
|
||||||
int CDECL fgetpos(FILE* file, fpos_t *pos)
|
int CDECL fgetpos(FILE* file, fpos_t *pos)
|
||||||
{
|
{
|
||||||
int off=0;
|
*pos = _ftelli64(file);
|
||||||
|
if(*pos == -1)
|
||||||
_lock_file(file);
|
|
||||||
*pos = _lseeki64(file->_file,0,SEEK_CUR);
|
|
||||||
if(*pos == -1) {
|
|
||||||
_unlock_file(file);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
if(file->_bufsiz) {
|
|
||||||
if( file->_flag & _IOWRT ) {
|
|
||||||
off = file->_ptr - file->_base;
|
|
||||||
} else {
|
|
||||||
off = -file->_cnt;
|
|
||||||
if (get_ioinfo(file->_file)->wxflag & WX_TEXT) {
|
|
||||||
/* Black magic correction for CR removal */
|
|
||||||
int i;
|
|
||||||
for (i=0; i<file->_cnt; i++) {
|
|
||||||
if (file->_ptr[i] == '\n')
|
|
||||||
off--;
|
|
||||||
}
|
|
||||||
/* Black magic when reading CR at buffer boundary*/
|
|
||||||
if(get_ioinfo(file->_file)->wxflag & WX_READCR)
|
|
||||||
off--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*pos += off;
|
|
||||||
_unlock_file(file);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue