浏览代码

LibIPC: Add `File(Core::Stream::File& file, ...)`

Lucas CHOLLET 2 年之前
父节点
当前提交
fe2ab2bd8c
共有 1 个文件被更改,包括 7 次插入0 次删除
  1. 7 0
      Userland/Libraries/LibIPC/File.h

+ 7 - 0
Userland/Libraries/LibIPC/File.h

@@ -9,6 +9,7 @@
 
 #include <AK/Noncopyable.h>
 #include <AK/StdLibExtras.h>
+#include <LibCore/Stream.h>
 #include <unistd.h>
 
 namespace IPC {
@@ -39,6 +40,12 @@ public:
     {
     }
 
+    template<typename... Args>
+    File(Core::Stream::File& file, Args... args)
+        : File(file.leak_fd(Badge<File> {}), args...)
+    {
+    }
+
     File(File&& other)
         : m_fd(exchange(other.m_fd, -1))
         , m_close_on_destruction(exchange(other.m_close_on_destruction, false))