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

Side by Side Diff: base/file_util_posix.cc

Issue 319543004: Move and rename FdopenPlatformFile to file_util (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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) 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 #include <dirent.h> 7 #include <dirent.h>
8 #include <errno.h> 8 #include <errno.h>
9 #include <fcntl.h> 9 #include <fcntl.h>
10 #include <libgen.h> 10 #include <libgen.h>
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 647
648 FILE* OpenFile(const FilePath& filename, const char* mode) { 648 FILE* OpenFile(const FilePath& filename, const char* mode) {
649 ThreadRestrictions::AssertIOAllowed(); 649 ThreadRestrictions::AssertIOAllowed();
650 FILE* result = NULL; 650 FILE* result = NULL;
651 do { 651 do {
652 result = fopen(filename.value().c_str(), mode); 652 result = fopen(filename.value().c_str(), mode);
653 } while (!result && errno == EINTR); 653 } while (!result && errno == EINTR);
654 return result; 654 return result;
655 } 655 }
656 656
657 // NaCl doesn't implement system calls to open files directly.
658 #if !defined(OS_NACL)
659 FILE* FileToFILE(File file, const char* mode) {
660 FILE* stream = fdopen(file.GetPlatformFile(), mode);
661 if (stream)
662 file.TakePlatformFile();
663 return stream;
664 }
665 #endif // !defined(OS_NACL)
666
657 int ReadFile(const FilePath& filename, char* data, int max_size) { 667 int ReadFile(const FilePath& filename, char* data, int max_size) {
658 ThreadRestrictions::AssertIOAllowed(); 668 ThreadRestrictions::AssertIOAllowed();
659 int fd = HANDLE_EINTR(open(filename.value().c_str(), O_RDONLY)); 669 int fd = HANDLE_EINTR(open(filename.value().c_str(), O_RDONLY));
660 if (fd < 0) 670 if (fd < 0)
661 return -1; 671 return -1;
662 672
663 ssize_t bytes_read = HANDLE_EINTR(read(fd, data, max_size)); 673 ssize_t bytes_read = HANDLE_EINTR(read(fd, data, max_size));
664 if (IGNORE_EINTR(close(fd)) < 0) 674 if (IGNORE_EINTR(close(fd)) < 0)
665 return -1; 675 return -1;
666 return bytes_read; 676 return bytes_read;
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 result = false; 903 result = false;
894 if (IGNORE_EINTR(close(outfile)) < 0) 904 if (IGNORE_EINTR(close(outfile)) < 0)
895 result = false; 905 result = false;
896 906
897 return result; 907 return result;
898 } 908 }
899 #endif // !defined(OS_MACOSX) 909 #endif // !defined(OS_MACOSX)
900 910
901 } // namespace internal 911 } // namespace internal
902 } // namespace base 912 } // namespace base
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