1 // Copyright 2021 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "base/file_descriptor_posix.h" 6 7 #include "base/files/file.h" 8 9 namespace base { 10 11 FileDescriptor::FileDescriptor() = default; 12 FileDescriptor(int ifd,bool iauto_close)13FileDescriptor::FileDescriptor(int ifd, bool iauto_close) 14 : fd(ifd), auto_close(iauto_close) {} 15 FileDescriptor(File file)16FileDescriptor::FileDescriptor(File file) 17 : fd(file.TakePlatformFile()), auto_close(true) {} 18 FileDescriptor(ScopedFD fd)19FileDescriptor::FileDescriptor(ScopedFD fd) 20 : fd(fd.release()), auto_close(true) {} 21 operator ==(const FileDescriptor & other) const22bool FileDescriptor::operator==(const FileDescriptor& other) const { 23 return fd == other.fd && auto_close == other.auto_close; 24 } 25 operator !=(const FileDescriptor & other) const26bool FileDescriptor::operator!=(const FileDescriptor& other) const { 27 return !operator==(other); 28 } 29 operator <(const FileDescriptor & other) const30bool FileDescriptor::operator<(const FileDescriptor& other) const { 31 return other.fd < fd; 32 } 33 34 } // namespace base