blob: ca5922da22b314f046c041d267d0968a6e2e2f68 [file] [log] [blame]
Peter Kasting73ee7ef2021-07-20 19:47:56 +00001// Copyright 2021 The Chromium Authors. All rights reserved.
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
9namespace base {
10
11FileDescriptor::FileDescriptor() = default;
12
13FileDescriptor::FileDescriptor(int ifd, bool iauto_close)
14 : fd(ifd), auto_close(iauto_close) {}
15
16FileDescriptor::FileDescriptor(File file)
17 : fd(file.TakePlatformFile()), auto_close(true) {}
18
19FileDescriptor::FileDescriptor(ScopedFD fd)
20 : fd(fd.release()), auto_close(true) {}
21
22bool FileDescriptor::operator==(const FileDescriptor& other) const {
23 return fd == other.fd && auto_close == other.auto_close;
24}
25
26bool FileDescriptor::operator!=(const FileDescriptor& other) const {
27 return !operator==(other);
28}
29
30bool FileDescriptor::operator<(const FileDescriptor& other) const {
31 return other.fd < fd;
32}
33
34} // namespace base