mirror of
https://github.com/matrix-construct/construct
synced 2024-12-26 15:33:54 +01:00
ircd::fs: Use lseek() for size(fd) overload.
This commit is contained in:
parent
79d4c15ff5
commit
e3827124e9
1 changed files with 13 additions and 4 deletions
17
ircd/fs.cc
17
ircd/fs.cc
|
@ -575,10 +575,19 @@ ircd::fs::uuid(const fd &fd,
|
|||
size_t
|
||||
ircd::fs::size(const fd &fd)
|
||||
{
|
||||
struct stat stat;
|
||||
syscall(::fstat, fd, &stat);
|
||||
return stat.st_size;
|
||||
};
|
||||
const off_t cur
|
||||
{
|
||||
syscall(::lseek, fd, 0, SEEK_CUR)
|
||||
};
|
||||
|
||||
const off_t end
|
||||
{
|
||||
syscall(::lseek, fd, 0, SEEK_END)
|
||||
};
|
||||
|
||||
syscall(::lseek, fd, cur, SEEK_SET);
|
||||
return end;
|
||||
}
|
||||
|
||||
uint
|
||||
ircd::fs::posix_flags(const std::ios::open_mode &mode)
|
||||
|
|
Loading…
Reference in a new issue