mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 19:37:35 +00:00
LibC: implement fgetpos and fsetpos
They're just "front ends" for ftell and fseek, but they do their job. Fixes #913
This commit is contained in:
parent
2cbc3c6ee5
commit
b5c3bc6a71
2 changed files with 21 additions and 1 deletions
|
@ -327,6 +327,26 @@ long ftell(FILE* stream)
|
||||||
return lseek(stream->fd, 0, SEEK_CUR);
|
return lseek(stream->fd, 0, SEEK_CUR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int fgetpos(FILE* stream, fpos_t* pos)
|
||||||
|
{
|
||||||
|
assert(stream);
|
||||||
|
assert(pos);
|
||||||
|
|
||||||
|
long val = ftell(stream);
|
||||||
|
if (val == -1L)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
*pos = val;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int fsetpos(FILE* stream, const fpos_t* pos)
|
||||||
|
{
|
||||||
|
assert(stream);
|
||||||
|
assert(pos);
|
||||||
|
return fseek(stream, (long) *pos, SEEK_SET);
|
||||||
|
}
|
||||||
|
|
||||||
void rewind(FILE* stream)
|
void rewind(FILE* stream)
|
||||||
{
|
{
|
||||||
ASSERT(stream);
|
ASSERT(stream);
|
||||||
|
|
|
@ -45,7 +45,7 @@ extern FILE* stdin;
|
||||||
extern FILE* stdout;
|
extern FILE* stdout;
|
||||||
extern FILE* stderr;
|
extern FILE* stderr;
|
||||||
|
|
||||||
typedef size_t fpos_t;
|
typedef long fpos_t;
|
||||||
|
|
||||||
int fseek(FILE*, long offset, int whence);
|
int fseek(FILE*, long offset, int whence);
|
||||||
int fgetpos(FILE*, fpos_t*);
|
int fgetpos(FILE*, fpos_t*);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue