Base: Move platform_file.* to files/file.*
PlatformFile has grown beyond the initial expectations and it doesn't make
sense to continue supporting individual function wrappers instead of a
proper file class.
BUG=322664
TEST=base_unittests
R=brettw@chromium.org
Review URL: https://codereview.chromium.org/93513002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238504 0039d316-1c4b-4281-b951-d872f2087c98
CrOS-Libchrome-Original-Commit: f62ac7d5fc78bf1fa97895912dc6554d699209f7
diff --git a/base/files/file.cc b/base/files/file.cc
index bb411b8..4902f15 100644
--- a/base/files/file.cc
+++ b/base/files/file.cc
@@ -2,30 +2,63 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/files/file.h"
+
+// TODO(rvargas): remove this (needed for kInvalidPlatformFileValue).
#include "base/platform_file.h"
namespace base {
-PlatformFileInfo::PlatformFileInfo()
+File::Info::Info()
: size(0),
is_directory(false),
is_symbolic_link(false) {
}
-PlatformFileInfo::~PlatformFileInfo() {}
+File::Info::~Info() {
+}
+
+File::File()
+ : file_(kInvalidPlatformFileValue),
+ error_(FILE_OK),
+ created_(false),
+ async_(false) {
+}
#if !defined(OS_NACL)
-PlatformFile CreatePlatformFile(const FilePath& name,
- int flags,
- bool* created,
- PlatformFileError* error) {
+File::File(const FilePath& name, uint32 flags)
+ : file_(kInvalidPlatformFileValue),
+ error_(FILE_OK),
+ created_(false),
+ async_(false) {
if (name.ReferencesParent()) {
- if (error)
- *error = PLATFORM_FILE_ERROR_ACCESS_DENIED;
- return kInvalidPlatformFileValue;
+ error_ = FILE_ERROR_ACCESS_DENIED;
+ return;
}
- return CreatePlatformFileUnsafe(name, flags, created, error);
+ CreateBaseFileUnsafe(name, flags);
}
#endif
+File::File(RValue other)
+ : file_(other.object->TakePlatformFile()),
+ error_(other.object->error()),
+ created_(other.object->created()),
+ async_(other.object->async_) {
+}
+
+File::~File() {
+ Close();
+}
+
+File& File::operator=(RValue other) {
+ if (this != other.object) {
+ Close();
+ SetPlatformFile(other.object->TakePlatformFile());
+ error_ = other.object->error();
+ created_ = other.object->created();
+ async_ = other.object->async_;
+ }
+ return *this;
+}
+
} // namespace base