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

Side by Side Diff: base/files/file.h

Issue 109273002: Convert base::MemoryMappedFile to use File instead of PlatformFile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Posix GetSize Created 6 years, 12 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | base/files/file.cc » ('j') | media/base/media_file_checker.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef BASE_FILES_FILE_H_ 5 #ifndef BASE_FILES_FILE_H_
6 #define BASE_FILES_FILE_H_ 6 #define BASE_FILES_FILE_H_
7 7
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 #if defined(OS_WIN) 9 #if defined(OS_WIN)
10 #include <windows.h> 10 #include <windows.h>
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 explicit File(PlatformFile platform_file); 150 explicit File(PlatformFile platform_file);
151 151
152 // Move constructor for C++03 move emulation of this type. 152 // Move constructor for C++03 move emulation of this type.
153 File(RValue other); 153 File(RValue other);
154 154
155 ~File(); 155 ~File();
156 156
157 // Move operator= for C++03 move emulation of this type. 157 // Move operator= for C++03 move emulation of this type.
158 File& operator=(RValue other); 158 File& operator=(RValue other);
159 159
160 // Creates or opens the given file.
161 void Initialize(const FilePath& name, uint32 flags);
162
160 // Creates or opens the given file, allowing paths with traversal ('..') 163 // Creates or opens the given file, allowing paths with traversal ('..')
161 // components. Use only with extreme care. 164 // components. Use only with extreme care.
162 void CreateBaseFileUnsafe(const FilePath& name, uint32 flags); 165 void InitializeUnsafe(const FilePath& name, uint32 flags);
163 166
164 bool IsValid() const; 167 bool IsValid() const;
165 168
166 // Returns true if a new file was created (or an old one truncated to zero 169 // Returns true if a new file was created (or an old one truncated to zero
167 // length to simulate a new file, which can happen with 170 // length to simulate a new file, which can happen with
168 // FLAG_CREATE_ALWAYS), and false otherwise. 171 // FLAG_CREATE_ALWAYS), and false otherwise.
169 bool created() const { return created_; } 172 bool created() const { return created_; }
170 173
171 // Returns the OS result of opening this file. 174 // Returns the OS result of opening this file.
172 Error error() const { return error_; } 175 Error error() const { return error_; }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 // with FLAG_APPEND. 212 // with FLAG_APPEND.
210 int Write(int64 offset, const char* data, int size); 213 int Write(int64 offset, const char* data, int size);
211 214
212 // Save as above but without seek. 215 // Save as above but without seek.
213 int WriteAtCurrentPos(const char* data, int size); 216 int WriteAtCurrentPos(const char* data, int size);
214 217
215 // Save as above but does not make any effort to write all data on all 218 // Save as above but does not make any effort to write all data on all
216 // platforms. Returns the number of bytes written, or -1 on error. 219 // platforms. Returns the number of bytes written, or -1 on error.
217 int WriteAtCurrentPosNoBestEffort(const char* data, int size); 220 int WriteAtCurrentPosNoBestEffort(const char* data, int size);
218 221
222 // Returns the current size of this file, or a negative number on failure.
223 int64 GetLength();
224
219 // Truncates the file to the given length. If |length| is greater than the 225 // Truncates the file to the given length. If |length| is greater than the
220 // current size of the file, the file is extended with zeros. If the file 226 // current size of the file, the file is extended with zeros. If the file
221 // doesn't exist, |false| is returned. 227 // doesn't exist, |false| is returned.
222 bool Truncate(int64 length); 228 bool SetLength(int64 length);
223 229
224 // Flushes the buffers. 230 // Flushes the buffers.
225 bool Flush(); 231 bool Flush();
226 232
227 // Updates the file times. 233 // Updates the file times.
228 bool SetTimes(Time last_access_time, Time last_modified_time); 234 bool SetTimes(Time last_access_time, Time last_modified_time);
229 235
230 // Returns some basic information for the given file. 236 // Returns some basic information for the given file.
231 bool GetInfo(Info* info); 237 bool GetInfo(Info* info);
232 238
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 #endif 277 #endif
272 278
273 Error error_; 279 Error error_;
274 bool created_; 280 bool created_;
275 bool async_; 281 bool async_;
276 }; 282 };
277 283
278 } // namespace base 284 } // namespace base
279 285
280 #endif // BASE_FILES_FILE_H_ 286 #endif // BASE_FILES_FILE_H_
OLDNEW
« no previous file with comments | « no previous file | base/files/file.cc » ('j') | media/base/media_file_checker.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698