AuroraRuntime/Source/IO/UNIX/UnixIO.cpp

66 lines
1.3 KiB
C++
Raw Normal View History

2022-04-13 11:00:35 +00:00
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: UnixIO.cpp
Date: 2022-4-12
Author: Reece
***/
#include <Source/RuntimeInternal.hpp>
#include "UnixIO.hpp"
#include "FDIpcServer.hpp"
2022-04-13 11:00:35 +00:00
namespace Aurora::IO::UNIX
{
AUKN_SYM AuString ShareFileDescriptor(int fd)
{
IPC::IPCHandle handle;
2022-04-13 11:00:35 +00:00
if (!FDServe(false, false, false, false, fd, handle))
{
return {};
}
2022-04-13 11:00:35 +00:00
return handle.ToString();
}
2022-04-13 11:00:35 +00:00
AUKN_SYM void ShareFileDescriptorStop(const AuString &handle)
{
IPC::IPCHandle handle2;
if (!handle2.FromString(handle))
{
SysPushErrorIO("Invalid handle string");
return;
}
2022-04-13 11:00:35 +00:00
FDServeEnd(handle2);
}
2022-04-13 11:00:35 +00:00
AUKN_SYM int ShareFileDescriptorAccept(const AuString &handle)
{
IPC::IPCHandle handle2;
if (!handle2.FromString(handle))
{
SysPushErrorIO("Invalid handle string");
return -1;
}
int fd {-1};
if (!FDAccept(handle2, fd))
{
SysPushErrorNested();
return -1;
}
return fd;
}
void InitUnixIO()
{
InitIPCBackend();
}
void DeinitUnixIO()
2022-04-13 11:00:35 +00:00
{
DeinitIPCBackend();
2022-04-13 11:00:35 +00:00
}
}