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

Side by Side Diff: base/file_util.cc

Issue 1220001: Computes the total size of the files in a directory... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 9 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/file_util.h ('k') | base/file_util_unittest.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) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 // file_util::AbsolutePath() normalizes '/' to '\' on Windows, so we only need 261 // file_util::AbsolutePath() normalizes '/' to '\' on Windows, so we only need
262 // to check kSeparators[0]. 262 // to check kSeparators[0].
263 if (abs_child.value().length() <= abs_parent.value().length() || 263 if (abs_child.value().length() <= abs_parent.value().length() ||
264 abs_child.value()[abs_parent.value().length()] != 264 abs_child.value()[abs_parent.value().length()] !=
265 FilePath::kSeparators[0]) 265 FilePath::kSeparators[0])
266 return false; 266 return false;
267 267
268 return true; 268 return true;
269 } 269 }
270 270
271 int64 ComputeDirectorySize(const FilePath& root_path) {
272 int64 running_size = 0;
273 FileEnumerator file_iter(root_path, true, FileEnumerator::FILES);
274 for (FilePath current = file_iter.Next(); !current.empty();
275 current = file_iter.Next()) {
276 FileEnumerator::FindInfo info;
277 file_iter.GetFindInfo(&info);
278 #if defined(OS_WIN)
279 LARGE_INTEGER li = { info.nFileSizeLow, info.nFileSizeHigh };
280 running_size += li.QuadPart;
281 #else
282 running_size += info.stat.st_size;
283 #endif
284 }
285 return running_size;
286 }
287
271 /////////////////////////////////////////////// 288 ///////////////////////////////////////////////
272 // MemoryMappedFile 289 // MemoryMappedFile
273 290
274 MemoryMappedFile::~MemoryMappedFile() { 291 MemoryMappedFile::~MemoryMappedFile() {
275 CloseHandles(); 292 CloseHandles();
276 } 293 }
277 294
278 bool MemoryMappedFile::Initialize(base::PlatformFile file) { 295 bool MemoryMappedFile::Initialize(base::PlatformFile file) {
279 if (IsValid()) 296 if (IsValid())
280 return false; 297 return false;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 // FileEnumerator 442 // FileEnumerator
426 // 443 //
427 // Note: the main logic is in file_util_<platform>.cc 444 // Note: the main logic is in file_util_<platform>.cc
428 445
429 bool FileEnumerator::ShouldSkip(const FilePath& path) { 446 bool FileEnumerator::ShouldSkip(const FilePath& path) {
430 FilePath::StringType basename = path.BaseName().value(); 447 FilePath::StringType basename = path.BaseName().value();
431 return IsDot(path) || (IsDotDot(path) && !(INCLUDE_DOT_DOT & file_type_)); 448 return IsDot(path) || (IsDotDot(path) && !(INCLUDE_DOT_DOT & file_type_));
432 } 449 }
433 450
434 } // namespace 451 } // namespace
OLDNEW
« no previous file with comments | « base/file_util.h ('k') | base/file_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698