]> git.saurik.com Git - apple/system_cmds.git/blobdiff - CPPUtil/UtilFileDescriptor.hpp
system_cmds-735.tar.gz
[apple/system_cmds.git] / CPPUtil / UtilFileDescriptor.hpp
diff --git a/CPPUtil/UtilFileDescriptor.hpp b/CPPUtil/UtilFileDescriptor.hpp
deleted file mode 100644 (file)
index be861b0..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-//
-//  UtilFileDescriptor.hpp
-//  CPPUtil
-//
-//  Created by James McIlree on 4/16/13.
-//  Copyright (c) 2013 Apple. All rights reserved.
-//
-
-#ifndef CPPUtil_UtilFileDescriptor_hpp
-#define CPPUtil_UtilFileDescriptor_hpp
-
-class FileDescriptor {
-    protected:
-       int _fd;
-
-       // FD's aren't reference counted, we allow move semantics but
-       // not copy semantics. Disable the copy constructor and copy
-       // assignment.
-       FileDescriptor(const FileDescriptor& that) = delete;
-       FileDescriptor& operator=(const FileDescriptor& other) = delete;
-
-    public:
-
-       FileDescriptor() : _fd(-1)                              {}
-       FileDescriptor(int fd) : _fd(fd)                        {}
-
-       template <typename... Args>
-       FileDescriptor(Args&& ... args) :
-               _fd(open(static_cast<Args &&>(args)...))
-       {
-       }
-
-       FileDescriptor (FileDescriptor&& rhs) noexcept :
-               _fd(rhs._fd)
-       {
-               rhs._fd = -1;
-       }
-
-       ~FileDescriptor()                                       { close(); }
-
-       FileDescriptor& operator=(int fd)                       { close(); _fd = fd; return *this; }
-       FileDescriptor& operator=(FileDescriptor&& rhs)         { std::swap(_fd, rhs._fd); return *this; }
-
-       bool is_open() const                                    { return _fd > -1 ? true : false; }
-       void close()                                            { if (is_open()) { ::close(_fd); _fd = -1; } }
-
-       explicit operator bool() const                          { return is_open(); }
-       operator int() const                                    { return _fd; }
-};
-
-
-#endif