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

Side by Side Diff: base/files/file_win.cc

Issue 109273002: Convert base::MemoryMappedFile to use File instead of PlatformFile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 unified diff | Download patch | Annotate | Revision Log
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 #include "base/files/file.h" 5 #include "base/files/file.h"
6 6
7 #include <io.h> 7 #include <io.h>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/metrics/sparse_histogram.h" 11 #include "base/metrics/sparse_histogram.h"
12 #include "base/threading/thread_restrictions.h" 12 #include "base/threading/thread_restrictions.h"
13 13
14 namespace base { 14 namespace base {
15 15
16 void File::CreateBaseFileUnsafe(const FilePath& name, uint32 flags) { 16 void File::InitializeUnsafe(const FilePath& name, uint32 flags) {
17 base::ThreadRestrictions::AssertIOAllowed(); 17 base::ThreadRestrictions::AssertIOAllowed();
18 DCHECK(!IsValid()); 18 DCHECK(!IsValid());
19 19
20 DWORD disposition = 0; 20 DWORD disposition = 0;
21 21
22 if (flags & FLAG_OPEN) 22 if (flags & FLAG_OPEN)
23 disposition = OPEN_EXISTING; 23 disposition = OPEN_EXISTING;
24 24
25 if (flags & FLAG_CREATE) { 25 if (flags & FLAG_CREATE) {
26 DCHECK(!disposition); 26 DCHECK(!disposition);
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 190
191 int File::WriteAtCurrentPos(const char* data, int size) { 191 int File::WriteAtCurrentPos(const char* data, int size) {
192 NOTREACHED(); 192 NOTREACHED();
193 return -1; 193 return -1;
194 } 194 }
195 195
196 int File::WriteAtCurrentPosNoBestEffort(const char* data, int size) { 196 int File::WriteAtCurrentPosNoBestEffort(const char* data, int size) {
197 return WriteAtCurrentPos(data, size); 197 return WriteAtCurrentPos(data, size);
198 } 198 }
199 199
200 bool File::Truncate(int64 length) { 200 int64 File::GetLength() {
201 base::ThreadRestrictions::AssertIOAllowed();
202 DCHECK(IsValid());
203 LARGE_INTEGER size;
204 if (!::GetFileSizeEx(file_.Get(), &size))
205 return -1;
206
207 return static_cast<int64>(size.QuadPart);
208 }
209
210 bool File::SetLength(int64 length) {
201 base::ThreadRestrictions::AssertIOAllowed(); 211 base::ThreadRestrictions::AssertIOAllowed();
202 DCHECK(IsValid()); 212 DCHECK(IsValid());
203 213
204 // Get the current file pointer. 214 // Get the current file pointer.
205 LARGE_INTEGER file_pointer; 215 LARGE_INTEGER file_pointer;
206 LARGE_INTEGER zero; 216 LARGE_INTEGER zero;
207 zero.QuadPart = 0; 217 zero.QuadPart = 0;
208 if (::SetFilePointerEx(file_, zero, &file_pointer, FILE_CURRENT) == 0) 218 if (::SetFilePointerEx(file_, zero, &file_pointer, FILE_CURRENT) == 0)
209 return false; 219 return false;
210 220
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 last_error); 320 last_error);
311 return FILE_ERROR_FAILED; 321 return FILE_ERROR_FAILED;
312 } 322 }
313 } 323 }
314 324
315 void File::SetPlatformFile(PlatformFile file) { 325 void File::SetPlatformFile(PlatformFile file) {
316 file_.Set(file); 326 file_.Set(file);
317 } 327 }
318 328
319 } // namespace base 329 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698