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 102873002: Move GetFileSize, NormalizeFilePath to base namespace (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
« no previous file with comments | « base/file_util.h ('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) 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/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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 if (!GetTempDir(&directory)) 158 if (!GetTempDir(&directory))
159 return NULL; 159 return NULL;
160 160
161 return CreateAndOpenTemporaryFileInDir(directory, path); 161 return CreateAndOpenTemporaryFileInDir(directory, path);
162 } 162 }
163 163
164 bool CreateDirectory(const FilePath& full_path) { 164 bool CreateDirectory(const FilePath& full_path) {
165 return CreateDirectoryAndGetError(full_path, NULL); 165 return CreateDirectoryAndGetError(full_path, NULL);
166 } 166 }
167 167
168 bool GetFileSize(const FilePath& file_path, int64* file_size) {
169 PlatformFileInfo info;
170 if (!file_util::GetFileInfo(file_path, &info))
171 return false;
172 *file_size = info.size;
173 return true;
174 }
175
168 } // namespace base 176 } // namespace base
169 177
170 // ----------------------------------------------------------------------------- 178 // -----------------------------------------------------------------------------
171 179
172 namespace file_util { 180 namespace file_util {
173 181
174 using base::FileEnumerator; 182 using base::FileEnumerator;
175 using base::FilePath; 183 using base::FilePath;
176 using base::kMaxUniqueFiles; 184 using base::kMaxUniqueFiles;
177 185
178 bool GetFileSize(const FilePath& file_path, int64* file_size) {
179 base::PlatformFileInfo info;
180 if (!GetFileInfo(file_path, &info))
181 return false;
182 *file_size = info.size;
183 return true;
184 }
185
186 bool TouchFile(const FilePath& path, 186 bool TouchFile(const FilePath& path,
187 const base::Time& last_accessed, 187 const base::Time& last_accessed,
188 const base::Time& last_modified) { 188 const base::Time& last_modified) {
189 int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_WRITE_ATTRIBUTES; 189 int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_WRITE_ATTRIBUTES;
190 190
191 #if defined(OS_WIN) 191 #if defined(OS_WIN)
192 // On Windows, FILE_FLAG_BACKUP_SEMANTICS is needed to open a directory. 192 // On Windows, FILE_FLAG_BACKUP_SEMANTICS is needed to open a directory.
193 if (DirectoryExists(path)) 193 if (DirectoryExists(path))
194 flags |= base::PLATFORM_FILE_BACKUP_SEMANTICS; 194 flags |= base::PLATFORM_FILE_BACKUP_SEMANTICS;
195 #endif // OS_WIN 195 #endif // OS_WIN
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 if (!PathExists(new_path) && 250 if (!PathExists(new_path) &&
251 (!have_suffix || !PathExists(FilePath(new_path.value() + suffix)))) { 251 (!have_suffix || !PathExists(FilePath(new_path.value() + suffix)))) {
252 return count; 252 return count;
253 } 253 }
254 } 254 }
255 255
256 return -1; 256 return -1;
257 } 257 }
258 258
259 } // namespace file_util 259 } // namespace file_util
OLDNEW
« no previous file with comments | « base/file_util.h ('k') | base/file_util_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698