feat: updated engine version to 4.4-rc1
This commit is contained in:
parent
ee00efde1f
commit
21ba8e33af
5459 changed files with 1128836 additions and 198305 deletions
|
|
@ -37,11 +37,12 @@
|
|||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
Error FileAccessUnixPipe::open_existing(int p_rfd, int p_wfd) {
|
||||
Error FileAccessUnixPipe::open_existing(int p_rfd, int p_wfd, bool p_blocking) {
|
||||
// Open pipe using handles created by pipe(fd) call in the OS.execute_with_pipe.
|
||||
_close();
|
||||
|
||||
|
|
@ -51,6 +52,11 @@ Error FileAccessUnixPipe::open_existing(int p_rfd, int p_wfd) {
|
|||
fd[0] = p_rfd;
|
||||
fd[1] = p_wfd;
|
||||
|
||||
if (!p_blocking) {
|
||||
fcntl(fd[0], F_SETFL, fcntl(fd[0], F_GETFL) | O_NONBLOCK);
|
||||
fcntl(fd[1], F_SETFL, fcntl(fd[1], F_GETFL) | O_NONBLOCK);
|
||||
}
|
||||
|
||||
last_error = OK;
|
||||
return OK;
|
||||
}
|
||||
|
|
@ -62,10 +68,12 @@ Error FileAccessUnixPipe::open_internal(const String &p_path, int p_mode_flags)
|
|||
ERR_FAIL_COND_V_MSG(fd[0] >= 0 || fd[1] >= 0, ERR_ALREADY_IN_USE, "Pipe is already in use.");
|
||||
|
||||
path = String("/tmp/") + p_path.replace("pipe://", "").replace("/", "_");
|
||||
const CharString path_utf8 = path.utf8();
|
||||
|
||||
struct stat st = {};
|
||||
int err = stat(path.utf8().get_data(), &st);
|
||||
int err = stat(path_utf8.get_data(), &st);
|
||||
if (err) {
|
||||
if (mkfifo(path.utf8().get_data(), 0666) != 0) {
|
||||
if (mkfifo(path_utf8.get_data(), 0600) != 0) {
|
||||
last_error = ERR_FILE_CANT_OPEN;
|
||||
return last_error;
|
||||
}
|
||||
|
|
@ -74,7 +82,7 @@ Error FileAccessUnixPipe::open_internal(const String &p_path, int p_mode_flags)
|
|||
ERR_FAIL_COND_V_MSG(!S_ISFIFO(st.st_mode), ERR_ALREADY_IN_USE, "Pipe name is already used by file.");
|
||||
}
|
||||
|
||||
int f = ::open(path.utf8().get_data(), O_RDWR | O_CLOEXEC);
|
||||
int f = ::open(path_utf8.get_data(), O_RDWR | O_CLOEXEC | O_NONBLOCK);
|
||||
if (f < 0) {
|
||||
switch (errno) {
|
||||
case ENOENT: {
|
||||
|
|
@ -125,25 +133,23 @@ String FileAccessUnixPipe::get_path_absolute() const {
|
|||
return path_src;
|
||||
}
|
||||
|
||||
uint8_t FileAccessUnixPipe::get_8() const {
|
||||
uint64_t FileAccessUnixPipe::get_length() const {
|
||||
ERR_FAIL_COND_V_MSG(fd[0] < 0, 0, "Pipe must be opened before use.");
|
||||
|
||||
uint8_t b;
|
||||
if (::read(fd[0], &b, 1) == 0) {
|
||||
last_error = ERR_FILE_CANT_READ;
|
||||
b = '\0';
|
||||
} else {
|
||||
last_error = OK;
|
||||
}
|
||||
return b;
|
||||
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(!p_dst && p_length > 0, -1);
|
||||
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);
|
||||
|
||||
uint64_t read = ::read(fd[0], p_dst, p_length);
|
||||
if (read == p_length) {
|
||||
ssize_t read = ::read(fd[0], p_dst, p_length);
|
||||
if (read == -1) {
|
||||
last_error = ERR_FILE_CANT_READ;
|
||||
read = 0;
|
||||
} else if (read != (ssize_t)p_length) {
|
||||
last_error = ERR_FILE_CANT_READ;
|
||||
} else {
|
||||
last_error = OK;
|
||||
|
|
@ -155,22 +161,16 @@ Error FileAccessUnixPipe::get_error() const {
|
|||
return last_error;
|
||||
}
|
||||
|
||||
void FileAccessUnixPipe::store_8(uint8_t p_src) {
|
||||
ERR_FAIL_COND_MSG(fd[1] < 0, "Pipe must be opened before use.");
|
||||
if (::write(fd[1], &p_src, 1) != 1) {
|
||||
last_error = ERR_FILE_CANT_WRITE;
|
||||
} else {
|
||||
last_error = OK;
|
||||
}
|
||||
}
|
||||
bool FileAccessUnixPipe::store_buffer(const uint8_t *p_src, uint64_t p_length) {
|
||||
ERR_FAIL_COND_V_MSG(fd[1] < 0, false, "Pipe must be opened before use.");
|
||||
ERR_FAIL_COND_V(!p_src && p_length > 0, false);
|
||||
|
||||
void FileAccessUnixPipe::store_buffer(const uint8_t *p_src, uint64_t p_length) {
|
||||
ERR_FAIL_COND_MSG(fd[1] < 0, "Pipe must be opened before use.");
|
||||
ERR_FAIL_COND(!p_src && p_length > 0);
|
||||
if (::write(fd[1], p_src, p_length) != (ssize_t)p_length) {
|
||||
last_error = ERR_FILE_CANT_WRITE;
|
||||
return false;
|
||||
} else {
|
||||
last_error = OK;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue