mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:37:35 +00:00
LibC: Partially implement __fpending
This commit is contained in:
parent
304dbb0242
commit
4917a610ab
3 changed files with 18 additions and 0 deletions
|
@ -31,6 +31,7 @@ public:
|
|||
|
||||
bool flush();
|
||||
void purge();
|
||||
size_t pending();
|
||||
bool close();
|
||||
|
||||
void lock();
|
||||
|
|
|
@ -102,6 +102,16 @@ void FILE::purge()
|
|||
m_buffer.drop();
|
||||
}
|
||||
|
||||
size_t FILE::pending()
|
||||
{
|
||||
if (m_mode & O_RDONLY) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// FIXME: Check if our buffer is a write buffer, and only count those bytes.
|
||||
return m_buffer.buffered_size();
|
||||
}
|
||||
|
||||
ssize_t FILE::do_read(u8* data, size_t size)
|
||||
{
|
||||
int nread = ::read(m_fd, data, size);
|
||||
|
@ -1279,6 +1289,12 @@ FILE* tmpfile()
|
|||
return fdopen(fd, "rw");
|
||||
}
|
||||
|
||||
size_t __fpending(FILE* stream)
|
||||
{
|
||||
ScopedFileLock lock(stream);
|
||||
return stream->pending();
|
||||
}
|
||||
|
||||
int __freading(FILE* stream)
|
||||
{
|
||||
ScopedFileLock lock(stream);
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
__BEGIN_DECLS
|
||||
|
||||
size_t __fpending(FILE*);
|
||||
int __freading(FILE*);
|
||||
int __fwriting(FILE*);
|
||||
void __fpurge(FILE*);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue