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
3 // found in the LICENSE file.
5 #include "base/files/file.h"
6 #include "base/files/file_path.h"
13 is_symbolic_link(false) {
20 : error_details_(FILE_ERROR_FAILED
),
26 File::File(const FilePath
& name
, uint32 flags
)
27 : error_details_(FILE_OK
),
30 Initialize(name
, flags
);
34 File::File(PlatformFile platform_file
)
35 : file_(platform_file
),
36 error_details_(FILE_OK
),
40 DCHECK_GE(platform_file
, -1);
44 File::File(Error error_details
)
45 : error_details_(error_details
),
50 File::File(RValue other
)
51 : file_(other
.object
->TakePlatformFile()),
52 error_details_(other
.object
->error_details()),
53 created_(other
.object
->created()),
54 async_(other
.object
->async_
) {
58 // Go through the AssertIOAllowed logic.
62 File
& File::operator=(RValue other
) {
63 if (this != other
.object
) {
65 SetPlatformFile(other
.object
->TakePlatformFile());
66 error_details_
= other
.object
->error_details();
67 created_
= other
.object
->created();
68 async_
= other
.object
->async_
;
74 void File::Initialize(const FilePath
& name
, uint32 flags
) {
75 if (name
.ReferencesParent()) {
76 error_details_
= FILE_ERROR_ACCESS_DENIED
;
79 InitializeUnsafe(name
, flags
);
83 std::string
File::ErrorToString(Error error
) {
87 case FILE_ERROR_FAILED
:
88 return "FILE_ERROR_FAILED";
89 case FILE_ERROR_IN_USE
:
90 return "FILE_ERROR_IN_USE";
91 case FILE_ERROR_EXISTS
:
92 return "FILE_ERROR_EXISTS";
93 case FILE_ERROR_NOT_FOUND
:
94 return "FILE_ERROR_NOT_FOUND";
95 case FILE_ERROR_ACCESS_DENIED
:
96 return "FILE_ERROR_ACCESS_DENIED";
97 case FILE_ERROR_TOO_MANY_OPENED
:
98 return "FILE_ERROR_TOO_MANY_OPENED";
99 case FILE_ERROR_NO_MEMORY
:
100 return "FILE_ERROR_NO_MEMORY";
101 case FILE_ERROR_NO_SPACE
:
102 return "FILE_ERROR_NO_SPACE";
103 case FILE_ERROR_NOT_A_DIRECTORY
:
104 return "FILE_ERROR_NOT_A_DIRECTORY";
105 case FILE_ERROR_INVALID_OPERATION
:
106 return "FILE_ERROR_INVALID_OPERATION";
107 case FILE_ERROR_SECURITY
:
108 return "FILE_ERROR_SECURITY";
109 case FILE_ERROR_ABORT
:
110 return "FILE_ERROR_ABORT";
111 case FILE_ERROR_NOT_A_FILE
:
112 return "FILE_ERROR_NOT_A_FILE";
113 case FILE_ERROR_NOT_EMPTY
:
114 return "FILE_ERROR_NOT_EMPTY";
115 case FILE_ERROR_INVALID_URL
:
116 return "FILE_ERROR_INVALID_URL";
118 return "FILE_ERROR_IO";