mirror of
https://github.com/matrix-construct/construct
synced 2024-12-28 00:14:07 +01:00
ircd::fs: Add size(fd) from sys stat().
This commit is contained in:
parent
955d8921b9
commit
a9e73d898c
2 changed files with 10 additions and 0 deletions
|
@ -14,6 +14,8 @@
|
||||||
namespace ircd::fs
|
namespace ircd::fs
|
||||||
{
|
{
|
||||||
struct fd;
|
struct fd;
|
||||||
|
|
||||||
|
size_t size(const fd &);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Object for maintaining state to an open file or directory. Instances can
|
/// Object for maintaining state to an open file or directory. Instances can
|
||||||
|
|
|
@ -274,6 +274,14 @@ namespace ircd::fs
|
||||||
static uint posix_flags(const std::ios::open_mode &mode);
|
static uint posix_flags(const std::ios::open_mode &mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t
|
||||||
|
ircd::fs::size(const fd &fd)
|
||||||
|
{
|
||||||
|
struct stat stat;
|
||||||
|
syscall(::fstat, fd, &stat);
|
||||||
|
return stat.st_size;
|
||||||
|
};
|
||||||
|
|
||||||
uint
|
uint
|
||||||
ircd::fs::posix_flags(const std::ios::open_mode &mode)
|
ircd::fs::posix_flags(const std::ios::open_mode &mode)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue