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.
5 #include "base/file_descriptor_posix.h"
7 #include "base/files/file.h"
11 FileDescriptor::FileDescriptor() = default;
13 FileDescriptor::FileDescriptor(int ifd, bool iauto_close)
14 : fd(ifd), auto_close(iauto_close) {}
16 FileDescriptor::FileDescriptor(File file)
17 : fd(file.TakePlatformFile()), auto_close(true) {}
19 FileDescriptor::FileDescriptor(ScopedFD fd)
20 : fd(fd.release()), auto_close(true) {}
22 bool FileDescriptor::operator==(const FileDescriptor& other) const {
23 return fd == other.fd && auto_close == other.auto_close;
26 bool FileDescriptor::operator!=(const FileDescriptor& other) const {
27 return !operator==(other);
30 bool FileDescriptor::operator<(const FileDescriptor& other) const {