Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1196)

Side by Side Diff: webrtc/base/file.cc

Issue 2877023002: Move webrtc/{base => rtc_base} (Closed)
Patch Set: update presubmit.py and DEPS include rules Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/base/file.h ('k') | webrtc/base/file_posix.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
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
13 #include <utility>
14
15 namespace rtc {
16
17 namespace {
18
19 std::string NormalizePathname(Pathname&& path) {
20 path.Normalize();
21 return path.pathname();
22 }
23
24 } // namespace
25
26 File::File(PlatformFile file) : file_(file) {}
27
28 File::File() : file_(kInvalidPlatformFileValue) {}
29
30 File::~File() {
31 Close();
32 }
33
34 // static
35 File File::Open(const std::string& path) {
36 return File(OpenPlatformFile(path));
37 }
38
39 // static
40 File File::Open(Pathname&& path) {
41 return Open(NormalizePathname(std::move(path)));
42 }
43
44 // static
45 File File::Open(const Pathname& path) {
46 return Open(Pathname(path));
47 }
48
49 // static
50 File File::Create(const std::string& path) {
51 return File(CreatePlatformFile(path));
52 }
53
54 // static
55 File File::Create(Pathname&& path) {
56 return Create(NormalizePathname(std::move(path)));
57 }
58
59 // static
60 File File::Create(const Pathname& path) {
61 return Create(Pathname(path));
62 }
63
64 // static
65 bool File::Remove(const std::string& path) {
66 return RemoveFile(path);
67 }
68
69 // static
70 bool File::Remove(Pathname&& path) {
71 return Remove(NormalizePathname(std::move(path)));
72 }
73
74 // static
75 bool File::Remove(const Pathname& path) {
76 return Remove(Pathname(path));
77 }
78
79 File::File(File&& other) : file_(other.file_) {
80 other.file_ = kInvalidPlatformFileValue;
81 }
82
83 File& File::operator=(File&& other) {
84 Close();
85 file_ = other.file_;
86 other.file_ = kInvalidPlatformFileValue;
87 return *this;
88 }
89
90 bool File::IsOpen() {
91 return file_ != kInvalidPlatformFileValue;
92 }
93
94 } // namespace rtc
OLDNEW
« no previous file with comments | « webrtc/base/file.h ('k') | webrtc/base/file_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698