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

Side by Side Diff: base/file_util.cc

Issue 6085015: Order function definitions in base/ according to the header. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: lrn2merge Created 9 years, 11 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 | « base/debug/trace_event.cc ('k') | base/file_util_posix.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/file_util.h" 5 #include "base/file_util.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <io.h> 8 #include <io.h>
9 #endif 9 #endif
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 return running_size; 308 return running_size;
309 } 309 }
310 310
311 /////////////////////////////////////////////// 311 ///////////////////////////////////////////////
312 // MemoryMappedFile 312 // MemoryMappedFile
313 313
314 MemoryMappedFile::~MemoryMappedFile() { 314 MemoryMappedFile::~MemoryMappedFile() {
315 CloseHandles(); 315 CloseHandles();
316 } 316 }
317 317
318 bool MemoryMappedFile::Initialize(base::PlatformFile file) { 318 bool MemoryMappedFile::Initialize(const FilePath& file_name) {
319 if (IsValid()) 319 if (IsValid())
320 return false; 320 return false;
321 321
322 file_ = file; 322 if (!MapFileToMemory(file_name)) {
323
324 if (!MapFileToMemoryInternal()) {
325 CloseHandles(); 323 CloseHandles();
326 return false; 324 return false;
327 } 325 }
328 326
329 return true; 327 return true;
330 } 328 }
331 329
332 bool MemoryMappedFile::Initialize(const FilePath& file_name) { 330 bool MemoryMappedFile::Initialize(base::PlatformFile file) {
333 if (IsValid()) 331 if (IsValid())
334 return false; 332 return false;
335 333
336 if (!MapFileToMemory(file_name)) { 334 file_ = file;
335
336 if (!MapFileToMemoryInternal()) {
337 CloseHandles(); 337 CloseHandles();
338 return false; 338 return false;
339 } 339 }
340 340
341 return true; 341 return true;
342 } 342 }
343 343
344 bool MemoryMappedFile::IsValid() {
345 return data_ != NULL;
346 }
347
344 bool MemoryMappedFile::MapFileToMemory(const FilePath& file_name) { 348 bool MemoryMappedFile::MapFileToMemory(const FilePath& file_name) {
345 file_ = base::CreatePlatformFile( 349 file_ = base::CreatePlatformFile(
346 file_name, base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ, 350 file_name, base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ,
347 NULL, NULL); 351 NULL, NULL);
348 352
349 if (file_ == base::kInvalidPlatformFileValue) { 353 if (file_ == base::kInvalidPlatformFileValue) {
350 LOG(ERROR) << "Couldn't open " << file_name.value(); 354 LOG(ERROR) << "Couldn't open " << file_name.value();
351 return false; 355 return false;
352 } 356 }
353 357
354 return MapFileToMemoryInternal(); 358 return MapFileToMemoryInternal();
355 } 359 }
356 360
357 bool MemoryMappedFile::IsValid() {
358 return data_ != NULL;
359 }
360
361 // Deprecated functions ---------------------------------------------------- 361 // Deprecated functions ----------------------------------------------------
362 362
363 #if defined(OS_WIN) 363 #if defined(OS_WIN)
364 void AppendToPath(std::wstring* path, const std::wstring& new_ending) { 364 void AppendToPath(std::wstring* path, const std::wstring& new_ending) {
365 if (!path) { 365 if (!path) {
366 NOTREACHED(); 366 NOTREACHED();
367 return; // Don't crash in this function in release builds. 367 return; // Don't crash in this function in release builds.
368 } 368 }
369 369
370 if (!EndsWithSeparator(FilePath(*path))) 370 if (!EndsWithSeparator(FilePath(*path)))
(...skipping 30 matching lines...) Expand all
401 // FileEnumerator 401 // FileEnumerator
402 // 402 //
403 // Note: the main logic is in file_util_<platform>.cc 403 // Note: the main logic is in file_util_<platform>.cc
404 404
405 bool FileEnumerator::ShouldSkip(const FilePath& path) { 405 bool FileEnumerator::ShouldSkip(const FilePath& path) {
406 FilePath::StringType basename = path.BaseName().value(); 406 FilePath::StringType basename = path.BaseName().value();
407 return IsDot(path) || (IsDotDot(path) && !(INCLUDE_DOT_DOT & file_type_)); 407 return IsDot(path) || (IsDotDot(path) && !(INCLUDE_DOT_DOT & file_type_));
408 } 408 }
409 409
410 } // namespace 410 } // namespace
OLDNEW
« no previous file with comments | « base/debug/trace_event.cc ('k') | base/file_util_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698