| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include "webrtc/base/file.h" | 11 #include "webrtc/base/file.h" |
| 12 | 12 |
| 13 namespace rtc { | 13 namespace rtc { |
| 14 | 14 |
| 15 File::File(PlatformFile file) : file_(file) {} | 15 File::File(PlatformFile file) : file_(file) {} |
| 16 | 16 |
| 17 File::File() : file_(kInvalidPlatformFileValue) {} |
| 18 |
| 17 File::~File() { | 19 File::~File() { |
| 18 Close(); | 20 Close(); |
| 19 } | 21 } |
| 20 | 22 |
| 21 File File::Open(const std::string& path) { | 23 File File::Open(const std::string& path) { |
| 22 return File(OpenPlatformFile(path)); | 24 return File(OpenPlatformFile(path)); |
| 23 } | 25 } |
| 24 | 26 |
| 25 File File::Create(const std::string& path) { | 27 File File::Create(const std::string& path) { |
| 26 return File(CreatePlatformFile(path)); | 28 return File(CreatePlatformFile(path)); |
| 27 } | 29 } |
| 28 | 30 |
| 29 File::File(File&& other) : file_(other.file_) { | 31 File::File(File&& other) : file_(other.file_) { |
| 30 other.file_ = kInvalidPlatformFileValue; | 32 other.file_ = kInvalidPlatformFileValue; |
| 31 } | 33 } |
| 32 | 34 |
| 33 File& File::operator=(File&& other) { | 35 File& File::operator=(File&& other) { |
| 34 Close(); | 36 Close(); |
| 35 file_ = other.file_; | 37 file_ = other.file_; |
| 36 other.file_ = kInvalidPlatformFileValue; | 38 other.file_ = kInvalidPlatformFileValue; |
| 37 return *this; | 39 return *this; |
| 38 } | 40 } |
| 39 | 41 |
| 40 bool File::IsOpen() { | 42 bool File::IsOpen() { |
| 41 return file_ != kInvalidPlatformFileValue; | 43 return file_ != kInvalidPlatformFileValue; |
| 42 } | 44 } |
| 43 | 45 |
| 44 } // namespace rtc | 46 } // namespace rtc |
| OLD | NEW |