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

Side by Side Diff: base/file_util_posix.cc

Issue 257143003: Cleanup random bits of base/. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 6 years, 7 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 | « no previous file | base/sequence_checker_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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 } 72 }
73 #else // defined(OS_BSD) || defined(OS_MACOSX) || defined(OS_NACL) 73 #else // defined(OS_BSD) || defined(OS_MACOSX) || defined(OS_NACL)
74 static int CallStat(const char *path, stat_wrapper_t *sb) { 74 static int CallStat(const char *path, stat_wrapper_t *sb) {
75 ThreadRestrictions::AssertIOAllowed(); 75 ThreadRestrictions::AssertIOAllowed();
76 return stat64(path, sb); 76 return stat64(path, sb);
77 } 77 }
78 static int CallLstat(const char *path, stat_wrapper_t *sb) { 78 static int CallLstat(const char *path, stat_wrapper_t *sb) {
79 ThreadRestrictions::AssertIOAllowed(); 79 ThreadRestrictions::AssertIOAllowed();
80 return lstat64(path, sb); 80 return lstat64(path, sb);
81 } 81 }
82 #endif // !(defined(OS_BSD) || defined(OS_MACOSX) || defined(OS_NACL)) 82 #endif // !(defined(OS_BSD) || defined(OS_MACOSX) || defined(OS_NACL))
83 83
84 // Helper for NormalizeFilePath(), defined below. 84 // Helper for NormalizeFilePath(), defined below.
85 bool RealPath(const FilePath& path, FilePath* real_path) { 85 bool RealPath(const FilePath& path, FilePath* real_path) {
86 ThreadRestrictions::AssertIOAllowed(); // For realpath(). 86 ThreadRestrictions::AssertIOAllowed(); // For realpath().
87 FilePath::CharType buf[PATH_MAX]; 87 FilePath::CharType buf[PATH_MAX];
88 if (!realpath(path.value().c_str(), buf)) 88 if (!realpath(path.value().c_str(), buf))
89 return false; 89 return false;
90 90
91 *real_path = FilePath(buf); 91 *real_path = FilePath(buf);
92 return true; 92 return true;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 bool result = false; 166 bool result = false;
167 FilePath path; 167 FilePath path;
168 168
169 ScopedFD fd(CreateAndOpenFdForTemporaryFile(FilePath("/dev/shm"), &path)); 169 ScopedFD fd(CreateAndOpenFdForTemporaryFile(FilePath("/dev/shm"), &path));
170 if (fd.is_valid()) { 170 if (fd.is_valid()) {
171 DeleteFile(path, false); 171 DeleteFile(path, false);
172 long sysconf_result = sysconf(_SC_PAGESIZE); 172 long sysconf_result = sysconf(_SC_PAGESIZE);
173 CHECK_GE(sysconf_result, 0); 173 CHECK_GE(sysconf_result, 0);
174 size_t pagesize = static_cast<size_t>(sysconf_result); 174 size_t pagesize = static_cast<size_t>(sysconf_result);
175 CHECK_GE(sizeof(pagesize), sizeof(sysconf_result)); 175 CHECK_GE(sizeof(pagesize), sizeof(sysconf_result));
176 void *mapping = mmap(NULL, pagesize, PROT_READ, MAP_SHARED, fd.get(), 0); 176 void* mapping = mmap(NULL, pagesize, PROT_READ, MAP_SHARED, fd.get(), 0);
177 if (mapping != MAP_FAILED) { 177 if (mapping != MAP_FAILED) {
178 if (mprotect(mapping, pagesize, PROT_READ | PROT_EXEC) == 0) 178 if (mprotect(mapping, pagesize, PROT_READ | PROT_EXEC) == 0)
179 result = true; 179 result = true;
180 munmap(mapping, pagesize); 180 munmap(mapping, pagesize);
181 } 181 }
182 } 182 }
183 return result; 183 return result;
184 } 184 }
185 #endif // defined(OS_LINUX) 185 #endif // defined(OS_LINUX)
186 186
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « no previous file | base/sequence_checker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698