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

Side by Side Diff: base/files/file_util_posix.cc

Issue 1396613004: Use permissions 0666 on POSIX platforms except Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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
« no previous file with comments | « no previous file | no next file » | 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/files/file_util.h" 5 #include "base/files/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 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 return -1; 667 return -1;
668 668
669 ssize_t bytes_read = HANDLE_EINTR(read(fd, data, max_size)); 669 ssize_t bytes_read = HANDLE_EINTR(read(fd, data, max_size));
670 if (IGNORE_EINTR(close(fd)) < 0) 670 if (IGNORE_EINTR(close(fd)) < 0)
671 return -1; 671 return -1;
672 return bytes_read; 672 return bytes_read;
673 } 673 }
674 674
675 int WriteFile(const FilePath& filename, const char* data, int size) { 675 int WriteFile(const FilePath& filename, const char* data, int size) {
676 ThreadRestrictions::AssertIOAllowed(); 676 ThreadRestrictions::AssertIOAllowed();
677 int fd = HANDLE_EINTR(creat(filename.value().c_str(), 0640)); 677 #if !defined(OS_ANDROID)
Lei Zhang 2015/10/13 08:46:40 nit: how about being positive with if-else defines
hashimoto 2015/10/14 03:18:14 Acknowledged.
678 const mode_t mode = 0666;
679 #else
680 const mode_t mode = 0640; // Be strict on Android. crbug.com/362887
681 #endif
682 int fd = HANDLE_EINTR(creat(filename.value().c_str(), mode));
678 if (fd < 0) 683 if (fd < 0)
679 return -1; 684 return -1;
680 685
681 int bytes_written = WriteFileDescriptor(fd, data, size) ? size : -1; 686 int bytes_written = WriteFileDescriptor(fd, data, size) ? size : -1;
682 if (IGNORE_EINTR(close(fd)) < 0) 687 if (IGNORE_EINTR(close(fd)) < 0)
683 return -1; 688 return -1;
684 return bytes_written; 689 return bytes_written;
685 } 690 }
686 691
687 bool WriteFileDescriptor(const int fd, const char* data, int size) { 692 bool WriteFileDescriptor(const int fd, const char* data, int size) {
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 return false; 919 return false;
915 920
916 DeleteFile(from_path, true); 921 DeleteFile(from_path, true);
917 return true; 922 return true;
918 } 923 }
919 924
920 } // namespace internal 925 } // namespace internal
921 926
922 #endif // !defined(OS_NACL_NONSFI) 927 #endif // !defined(OS_NACL_NONSFI)
923 } // namespace base 928 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698