blob: c97504f9c737a438c1b2bd585e58bddb087810ed [file] [log] [blame]
Viktor Palmkvist4ec6a0c2016-09-02 13:38:32 +02001/*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#include "webrtc/base/file.h"
12
13namespace rtc {
14
15File::File(PlatformFile file) : file_(file) {}
16
17File::~File() {
18 Close();
19}
20
Viktor Palmkvist971eb272016-09-16 10:19:23 +020021File File::Open(const std::string& path) {
22 return File(OpenPlatformFile(path));
23}
24
25File File::Create(const std::string& path) {
26 return File(CreatePlatformFile(path));
27}
28
Viktor Palmkvist4ec6a0c2016-09-02 13:38:32 +020029File::File(File&& other) : file_(other.file_) {
30 other.file_ = kInvalidPlatformFileValue;
31}
32
33File& File::operator=(File&& other) {
34 Close();
35 file_ = other.file_;
36 other.file_ = kInvalidPlatformFileValue;
37 return *this;
38}
39
40bool File::IsOpen() {
41 return file_ != kInvalidPlatformFileValue;
42}
43
44} // namespace rtc