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

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

Issue 1549853002: Switch to standard integer types in base/files/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 5 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
« no previous file with comments | « base/files/file_util.h ('k') | base/files/file_util_mac.mm » ('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) 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_util.h" 5 #include "base/files/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>
11 11
12 #include <fstream> 12 #include <fstream>
13 #include <limits> 13 #include <limits>
14 14
15 #include "base/files/file_enumerator.h" 15 #include "base/files/file_enumerator.h"
16 #include "base/files/file_path.h" 16 #include "base/files/file_path.h"
17 #include "base/logging.h" 17 #include "base/logging.h"
18 #include "base/strings/string_piece.h" 18 #include "base/strings/string_piece.h"
19 #include "base/strings/string_util.h" 19 #include "base/strings/string_util.h"
20 #include "base/strings/stringprintf.h" 20 #include "base/strings/stringprintf.h"
21 #include "base/strings/utf_string_conversions.h" 21 #include "base/strings/utf_string_conversions.h"
22 #include "build/build_config.h"
22 23
23 namespace base { 24 namespace base {
24 25
25 #if !defined(OS_NACL_NONSFI) 26 #if !defined(OS_NACL_NONSFI)
26 namespace { 27 namespace {
27 28
28 // The maximum number of 'uniquified' files we will try to create. 29 // The maximum number of 'uniquified' files we will try to create.
29 // This is used when the filename we're trying to download is already in use, 30 // This is used when the filename we're trying to download is already in use,
30 // so we create a new unique filename by appending " (nnn)" before the 31 // so we create a new unique filename by appending " (nnn)" before the
31 // extension, where 1 <= nnn <= kMaxUniqueFiles. 32 // extension, where 1 <= nnn <= kMaxUniqueFiles.
32 // Also used by code that cleans up said files. 33 // Also used by code that cleans up said files.
33 static const int kMaxUniqueFiles = 100; 34 static const int kMaxUniqueFiles = 100;
34 35
35 } // namespace 36 } // namespace
36 37
37 int64 ComputeDirectorySize(const FilePath& root_path) { 38 int64_t ComputeDirectorySize(const FilePath& root_path) {
38 int64 running_size = 0; 39 int64_t running_size = 0;
39 FileEnumerator file_iter(root_path, true, FileEnumerator::FILES); 40 FileEnumerator file_iter(root_path, true, FileEnumerator::FILES);
40 while (!file_iter.Next().empty()) 41 while (!file_iter.Next().empty())
41 running_size += file_iter.GetInfo().GetSize(); 42 running_size += file_iter.GetInfo().GetSize();
42 return running_size; 43 return running_size;
43 } 44 }
44 45
45 bool Move(const FilePath& from_path, const FilePath& to_path) { 46 bool Move(const FilePath& from_path, const FilePath& to_path) {
46 if (from_path.ReferencesParent() || to_path.ReferencesParent()) 47 if (from_path.ReferencesParent() || to_path.ReferencesParent())
47 return false; 48 return false;
48 return internal::MoveUnsafe(from_path, to_path); 49 return internal::MoveUnsafe(from_path, to_path);
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 if (!GetTempDir(&directory)) 179 if (!GetTempDir(&directory))
179 return NULL; 180 return NULL;
180 181
181 return CreateAndOpenTemporaryFileInDir(directory, path); 182 return CreateAndOpenTemporaryFileInDir(directory, path);
182 } 183 }
183 184
184 bool CreateDirectory(const FilePath& full_path) { 185 bool CreateDirectory(const FilePath& full_path) {
185 return CreateDirectoryAndGetError(full_path, NULL); 186 return CreateDirectoryAndGetError(full_path, NULL);
186 } 187 }
187 188
188 bool GetFileSize(const FilePath& file_path, int64* file_size) { 189 bool GetFileSize(const FilePath& file_path, int64_t* file_size) {
189 File::Info info; 190 File::Info info;
190 if (!GetFileInfo(file_path, &info)) 191 if (!GetFileInfo(file_path, &info))
191 return false; 192 return false;
192 *file_size = info.size; 193 *file_size = info.size;
193 return true; 194 return true;
194 } 195 }
195 196
196 bool TouchFile(const FilePath& path, 197 bool TouchFile(const FilePath& path,
197 const Time& last_accessed, 198 const Time& last_accessed,
198 const Time& last_modified) { 199 const Time& last_modified) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 (!have_suffix || !PathExists(FilePath(new_path.value() + suffix)))) { 253 (!have_suffix || !PathExists(FilePath(new_path.value() + suffix)))) {
253 return count; 254 return count;
254 } 255 }
255 } 256 }
256 257
257 return -1; 258 return -1;
258 } 259 }
259 #endif // !defined(OS_NACL_NONSFI) 260 #endif // !defined(OS_NACL_NONSFI)
260 261
261 } // namespace base 262 } // namespace base
OLDNEW
« no previous file with comments | « base/files/file_util.h ('k') | base/files/file_util_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698