mirror of
https://github.com/godotengine/godot.git
synced 2025-10-31 21:51:22 +00:00
Implement get_length() for pipes.
This commit is contained in:
parent
f60f69aa57
commit
e6e108d091
6 changed files with 21 additions and 4 deletions
|
|
@ -37,6 +37,7 @@
|
|||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
|
@ -132,6 +133,14 @@ String FileAccessUnixPipe::get_path_absolute() const {
|
|||
return path_src;
|
||||
}
|
||||
|
||||
uint64_t FileAccessUnixPipe::get_length() const {
|
||||
ERR_FAIL_COND_V_MSG(fd[0] < 0, 0, "Pipe must be opened before use.");
|
||||
|
||||
int buf_rem = 0;
|
||||
ERR_FAIL_COND_V(ioctl(fd[0], FIONREAD, &buf_rem) != 0, 0);
|
||||
return buf_rem;
|
||||
}
|
||||
|
||||
uint64_t FileAccessUnixPipe::get_buffer(uint8_t *p_dst, uint64_t p_length) const {
|
||||
ERR_FAIL_COND_V_MSG(fd[0] < 0, -1, "Pipe must be opened before use.");
|
||||
ERR_FAIL_COND_V(!p_dst && p_length > 0, -1);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue