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

Side by Side Diff: base/file_util_posix.cc

Issue 19610: Safe browsing cleanup:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 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.cc ('k') | base/file_util_win.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 <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <fnmatch.h> 9 #include <fnmatch.h>
10 #include <fts.h> 10 #include <fts.h>
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 } 346 }
347 347
348 FILE* OpenFile(const std::string& filename, const char* mode) { 348 FILE* OpenFile(const std::string& filename, const char* mode) {
349 return OpenFile(FilePath(filename), mode); 349 return OpenFile(FilePath(filename), mode);
350 } 350 }
351 351
352 FILE* OpenFile(const FilePath& filename, const char* mode) { 352 FILE* OpenFile(const FilePath& filename, const char* mode) {
353 return fopen(filename.value().c_str(), mode); 353 return fopen(filename.value().c_str(), mode);
354 } 354 }
355 355
356 int ReadFile(const std::wstring& filename, char* data, int size) { 356 int ReadFile(const FilePath& filename, char* data, int size) {
357 int fd = open(WideToUTF8(filename).c_str(), O_RDONLY); 357 int fd = open(filename.value().c_str(), O_RDONLY);
358 if (fd < 0) 358 if (fd < 0)
359 return -1; 359 return -1;
360 360
361 int ret_value = read(fd, data, size); 361 int ret_value = read(fd, data, size);
362 close(fd); 362 close(fd);
363 return ret_value; 363 return ret_value;
364 } 364 }
365 365
366 int WriteFile(const std::wstring& filename, const char* data, int size) { 366 int WriteFile(const FilePath& filename, const char* data, int size) {
367 int fd = creat(WideToUTF8(filename).c_str(), 0666); 367 int fd = creat(filename.value().c_str(), 0666);
368 if (fd < 0) 368 if (fd < 0)
369 return -1; 369 return -1;
370 370
371 // Allow for partial writes 371 // Allow for partial writes
372 ssize_t bytes_written_total = 0; 372 ssize_t bytes_written_total = 0;
373 do { 373 do {
374 ssize_t bytes_written_partial = write(fd, 374 ssize_t bytes_written_partial = write(fd,
375 data + bytes_written_total, 375 data + bytes_written_total,
376 size - bytes_written_total); 376 size - bytes_written_total);
377 if (bytes_written_partial < 0) { 377 if (bytes_written_partial < 0) {
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 munmap(data_, length_); 537 munmap(data_, length_);
538 if (file_ != -1) 538 if (file_ != -1)
539 close(file_); 539 close(file_);
540 540
541 data_ = NULL; 541 data_ = NULL;
542 length_ = 0; 542 length_ = 0;
543 file_ = -1; 543 file_ = -1;
544 } 544 }
545 545
546 } // namespace file_util 546 } // namespace file_util
OLDNEW
« no previous file with comments | « base/file_util.cc ('k') | base/file_util_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698