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

Side by Side Diff: base/file_util.cc

Issue 9074: Port more of url_request_unittest.cc.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years, 1 month 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include <fstream> 9 #include <fstream>
10 10
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 char buf[1 << 16]; 282 char buf[1 << 16];
283 size_t len; 283 size_t len;
284 while ((len = fread(buf, 1, sizeof(buf), file)) > 0) { 284 while ((len = fread(buf, 1, sizeof(buf), file)) > 0) {
285 contents->append(buf, len); 285 contents->append(buf, len);
286 } 286 }
287 CloseFile(file); 287 CloseFile(file);
288 288
289 return true; 289 return true;
290 } 290 }
291 291
292 bool GetFileSize(const std::wstring& file_path, int64* file_size) { 292 bool GetFileSize(const FilePath& file_path, int64* file_size) {
293 FileInfo info; 293 FileInfo info;
294 if (!GetFileInfo(file_path, &info)) 294 if (!GetFileInfo(file_path, &info))
295 return false; 295 return false;
296 *file_size = info.size; 296 *file_size = info.size;
297 return true; 297 return true;
298 } 298 }
299 299
300 bool CloseFile(FILE* file) { 300 bool CloseFile(FILE* file) {
301 if (file == NULL) 301 if (file == NULL)
302 return true; 302 return true;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 } 342 }
343 bool CreateDirectory(const std::wstring& full_path) { 343 bool CreateDirectory(const std::wstring& full_path) {
344 return CreateDirectory(FilePath::FromWStringHack(full_path)); 344 return CreateDirectory(FilePath::FromWStringHack(full_path));
345 } 345 }
346 bool GetCurrentDirectory(std::wstring* path_str) { 346 bool GetCurrentDirectory(std::wstring* path_str) {
347 FilePath path; 347 FilePath path;
348 if (!GetCurrentDirectory(&path)) 348 if (!GetCurrentDirectory(&path))
349 return false; 349 return false;
350 *path_str = path.ToWStringHack(); 350 *path_str = path.ToWStringHack();
351 return true; 351 return true;
352 } 352 }
agl 2008/11/04 20:57:27 Possibly put a line between the functions.
353 bool GetFileInfo(const std::wstring& file_path, FileInfo* results) {
354 return GetFileInfo(FilePath::FromWStringHack(file_path), results);
355 }
356 bool GetFileSize(const std::wstring& file_path, int64* file_size) {
357 return GetFileSize(FilePath::FromWStringHack(file_path), file_size);
358 }
353 bool GetTempDir(std::wstring* path_str) { 359 bool GetTempDir(std::wstring* path_str) {
354 FilePath path; 360 FilePath path;
355 if (!GetTempDir(&path)) 361 if (!GetTempDir(&path))
356 return false; 362 return false;
357 *path_str = path.ToWStringHack(); 363 *path_str = path.ToWStringHack();
358 return true; 364 return true;
359 } 365 }
360 366
361 } // namespace 367 } // namespace
362 368
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