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() { | 17 File::~File() { |
18 Close(); | 18 Close(); |
19 } | 19 } |
20 | 20 |
| 21 File File::Open(const std::string& path) { |
| 22 return File(OpenPlatformFile(path)); |
| 23 } |
| 24 |
| 25 File File::Create(const std::string& path) { |
| 26 return File(CreatePlatformFile(path)); |
| 27 } |
| 28 |
21 File::File(File&& other) : file_(other.file_) { | 29 File::File(File&& other) : file_(other.file_) { |
22 other.file_ = kInvalidPlatformFileValue; | 30 other.file_ = kInvalidPlatformFileValue; |
23 } | 31 } |
24 | 32 |
25 File& File::operator=(File&& other) { | 33 File& File::operator=(File&& other) { |
26 Close(); | 34 Close(); |
27 file_ = other.file_; | 35 file_ = other.file_; |
28 other.file_ = kInvalidPlatformFileValue; | 36 other.file_ = kInvalidPlatformFileValue; |
29 return *this; | 37 return *this; |
30 } | 38 } |
31 | 39 |
32 bool File::IsOpen() { | 40 bool File::IsOpen() { |
33 return file_ != kInvalidPlatformFileValue; | 41 return file_ != kInvalidPlatformFileValue; |
34 } | 42 } |
35 | 43 |
36 } // namespace rtc | 44 } // namespace rtc |
OLD | NEW |