mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
LibC: Partially implement __fpending
This commit is contained in:
parent
304dbb0242
commit
4917a610ab
Notes:
sideshowbarker
2024-07-17 23:07:41 +09:00
Author: https://github.com/timschumi Commit: https://github.com/SerenityOS/serenity/commit/4917a610ab Pull-request: https://github.com/SerenityOS/serenity/pull/13313
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…
Reference in a new issue