1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 08:14:58 +00:00

LibC: Implement __fpurge

This commit is contained in:
Tim Schumacher 2021-05-26 10:06:36 +02:00 committed by Linus Groh
parent cd970928a0
commit ccef5fe234
2 changed files with 13 additions and 0 deletions

View file

@ -40,6 +40,7 @@ public:
void setbuf(u8* data, int mode, size_t size) { m_buffer.setbuf(data, mode, size); }
bool flush();
void purge();
bool close();
int fileno() const { return m_fd; }
@ -192,6 +193,11 @@ bool FILE::flush()
return true;
}
void FILE::purge()
{
m_buffer.drop();
}
ssize_t FILE::do_read(u8* data, size_t size)
{
int nread = ::read(m_fd, data, size);
@ -1323,4 +1329,10 @@ int __fwriting(FILE* stream)
return (stream->flags() & FILE::Flags::LastWrite);
}
void __fpurge(FILE* stream)
{
ScopedFileLock lock(stream);
stream->purge();
}
}

View file

@ -12,5 +12,6 @@ __BEGIN_DECLS
int __freading(FILE*);
int __fwriting(FILE*);
void __fpurge(FILE*);
__END_DECLS