OLD | NEW |
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 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 return -1; | 658 return -1; |
659 | 659 |
660 ssize_t bytes_read = HANDLE_EINTR(read(fd, data, max_size)); | 660 ssize_t bytes_read = HANDLE_EINTR(read(fd, data, max_size)); |
661 if (IGNORE_EINTR(close(fd)) < 0) | 661 if (IGNORE_EINTR(close(fd)) < 0) |
662 return -1; | 662 return -1; |
663 return bytes_read; | 663 return bytes_read; |
664 } | 664 } |
665 | 665 |
666 int WriteFile(const FilePath& filename, const char* data, int size) { | 666 int WriteFile(const FilePath& filename, const char* data, int size) { |
667 ThreadRestrictions::AssertIOAllowed(); | 667 ThreadRestrictions::AssertIOAllowed(); |
668 int fd = HANDLE_EINTR(creat(filename.value().c_str(), 0666)); | 668 int fd = HANDLE_EINTR(creat(filename.value().c_str(), 0640)); |
669 if (fd < 0) | 669 if (fd < 0) |
670 return -1; | 670 return -1; |
671 | 671 |
672 int bytes_written = WriteFileDescriptor(fd, data, size); | 672 int bytes_written = WriteFileDescriptor(fd, data, size); |
673 if (IGNORE_EINTR(close(fd)) < 0) | 673 if (IGNORE_EINTR(close(fd)) < 0) |
674 return -1; | 674 return -1; |
675 return bytes_written; | 675 return bytes_written; |
676 } | 676 } |
677 | 677 |
678 int WriteFileDescriptor(const int fd, const char* data, int size) { | 678 int WriteFileDescriptor(const int fd, const char* data, int size) { |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 result = false; | 890 result = false; |
891 if (IGNORE_EINTR(close(outfile)) < 0) | 891 if (IGNORE_EINTR(close(outfile)) < 0) |
892 result = false; | 892 result = false; |
893 | 893 |
894 return result; | 894 return result; |
895 } | 895 } |
896 #endif // !defined(OS_MACOSX) | 896 #endif // !defined(OS_MACOSX) |
897 | 897 |
898 } // namespace internal | 898 } // namespace internal |
899 } // namespace base | 899 } // namespace base |
OLD | NEW |