| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/files/file.h" | 5 #include "base/files/file.h" |
| 6 | 6 |
| 7 // TODO(rvargas): remove this (needed for kInvalidPlatformFileValue). | 7 // TODO(rvargas): remove this (needed for kInvalidPlatformFileValue). |
| 8 #include "base/platform_file.h" | 8 #include "base/platform_file.h" |
| 9 | 9 |
| 10 namespace base { | 10 namespace base { |
| 11 | 11 |
| 12 File::Info::Info() | 12 File::Info::Info() |
| 13 : size(0), | 13 : size(0), |
| 14 is_directory(false), | 14 is_directory(false), |
| 15 is_symbolic_link(false) { | 15 is_symbolic_link(false) { |
| 16 } | 16 } |
| 17 | 17 |
| 18 File::Info::~Info() { | 18 File::Info::~Info() { |
| 19 } | 19 } |
| 20 | 20 |
| 21 File::File() | 21 File::File() |
| 22 : file_(kInvalidPlatformFileValue), | 22 : file_(kInvalidPlatformFileValue), |
| 23 error_(FILE_OK), | 23 error_details_(FILE_OK), |
| 24 created_(false), | 24 created_(false), |
| 25 async_(false) { | 25 async_(false) { |
| 26 } | 26 } |
| 27 | 27 |
| 28 #if !defined(OS_NACL) | 28 #if !defined(OS_NACL) |
| 29 File::File(const FilePath& name, uint32 flags) | 29 File::File(const FilePath& name, uint32 flags) |
| 30 : file_(kInvalidPlatformFileValue), | 30 : file_(kInvalidPlatformFileValue), |
| 31 error_(FILE_OK), | 31 error_details_(FILE_OK), |
| 32 created_(false), | 32 created_(false), |
| 33 async_(false) { | 33 async_(false) { |
| 34 Initialize(name, flags); | 34 Initialize(name, flags); |
| 35 } | 35 } |
| 36 #endif | 36 #endif |
| 37 | 37 |
| 38 File::File(PlatformFile platform_file) | 38 File::File(PlatformFile platform_file) |
| 39 : file_(platform_file), | 39 : file_(platform_file), |
| 40 error_(FILE_OK), | 40 error_details_(FILE_OK), |
| 41 created_(false), | 41 created_(false), |
| 42 async_(false) { | 42 async_(false) { |
| 43 } | 43 } |
| 44 | 44 |
| 45 File::File(RValue other) | 45 File::File(RValue other) |
| 46 : file_(other.object->TakePlatformFile()), | 46 : file_(other.object->TakePlatformFile()), |
| 47 error_(other.object->error()), | 47 error_details_(other.object->error_details()), |
| 48 created_(other.object->created()), | 48 created_(other.object->created()), |
| 49 async_(other.object->async_) { | 49 async_(other.object->async_) { |
| 50 } | 50 } |
| 51 | 51 |
| 52 File::~File() { | 52 File::~File() { |
| 53 Close(); | 53 Close(); |
| 54 } | 54 } |
| 55 | 55 |
| 56 File& File::operator=(RValue other) { | 56 File& File::operator=(RValue other) { |
| 57 if (this != other.object) { | 57 if (this != other.object) { |
| 58 Close(); | 58 Close(); |
| 59 SetPlatformFile(other.object->TakePlatformFile()); | 59 SetPlatformFile(other.object->TakePlatformFile()); |
| 60 error_ = other.object->error(); | 60 error_details_ = other.object->error_details(); |
| 61 created_ = other.object->created(); | 61 created_ = other.object->created(); |
| 62 async_ = other.object->async_; | 62 async_ = other.object->async_; |
| 63 } | 63 } |
| 64 return *this; | 64 return *this; |
| 65 } | 65 } |
| 66 | 66 |
| 67 #if !defined(OS_NACL) | 67 #if !defined(OS_NACL) |
| 68 void File::Initialize(const FilePath& name, uint32 flags) { | 68 void File::Initialize(const FilePath& name, uint32 flags) { |
| 69 if (name.ReferencesParent()) { | 69 if (name.ReferencesParent()) { |
| 70 error_ = FILE_ERROR_ACCESS_DENIED; | 70 error_details_ = FILE_ERROR_ACCESS_DENIED; |
| 71 return; | 71 return; |
| 72 } | 72 } |
| 73 InitializeUnsafe(name, flags); | 73 InitializeUnsafe(name, flags); |
| 74 } | 74 } |
| 75 #endif | 75 #endif |
| 76 | 76 |
| 77 } // namespace base | 77 } // namespace base |
| OLD | NEW |