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

Unified Diff: webrtc/base/file.cc

Issue 2533213005: Add File::Open / Create functions to take an rtc::Pathname (Closed)
Patch Set: Resolve review comments Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/base/file.h ('k') | webrtc/base/file_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/file.cc
diff --git a/webrtc/base/file.cc b/webrtc/base/file.cc
index 74d48177e4b976ff27689e3e79c5a76f140beceb..8b5df9e9be4f74ae31cac62ff80aa340323bfad5 100644
--- a/webrtc/base/file.cc
+++ b/webrtc/base/file.cc
@@ -10,8 +10,19 @@
#include "webrtc/base/file.h"
+#include <utility>
+
namespace rtc {
+namespace {
+
+std::string NormalizePathname(Pathname&& path) {
+ path.Normalize();
+ return path.pathname();
+}
+
+} // namespace
+
File::File(PlatformFile file) : file_(file) {}
File::File() : file_(kInvalidPlatformFileValue) {}
@@ -20,14 +31,36 @@ File::~File() {
Close();
}
+// static
File File::Open(const std::string& path) {
return File(OpenPlatformFile(path));
}
+// static
+File File::Open(Pathname&& path) {
+ return Open(NormalizePathname(std::move(path)));
+}
+
+// static
+File File::Open(const Pathname& path) {
+ return Open(Pathname(path));
+}
+
+// static
File File::Create(const std::string& path) {
return File(CreatePlatformFile(path));
}
+// static
+File File::Create(Pathname&& path) {
+ return Create(NormalizePathname(std::move(path)));
+}
+
+// static
+File File::Create(const Pathname& path) {
+ return Create(Pathname(path));
+}
+
File::File(File&& other) : file_(other.file_) {
other.file_ = kInvalidPlatformFileValue;
}
« no previous file with comments | « webrtc/base/file.h ('k') | webrtc/base/file_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698