| 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 <fnmatch.h> | 10 #include <fnmatch.h> |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 #include "base/utf_string_conversions.h" | 47 #include "base/utf_string_conversions.h" |
| 48 | 48 |
| 49 #if defined(OS_ANDROID) | 49 #if defined(OS_ANDROID) |
| 50 #include "base/os_compat_android.h" | 50 #include "base/os_compat_android.h" |
| 51 #endif | 51 #endif |
| 52 | 52 |
| 53 #if !defined(OS_IOS) | 53 #if !defined(OS_IOS) |
| 54 #include <grp.h> | 54 #include <grp.h> |
| 55 #endif | 55 #endif |
| 56 | 56 |
| 57 #if defined(OS_CHROMEOS) |
| 58 #include "base/chromeos/chromeos_version.h" |
| 59 #endif |
| 60 |
| 57 namespace file_util { | 61 namespace file_util { |
| 58 | 62 |
| 59 namespace { | 63 namespace { |
| 60 | 64 |
| 61 #if defined(OS_BSD) || defined(OS_MACOSX) | 65 #if defined(OS_BSD) || defined(OS_MACOSX) |
| 62 typedef struct stat stat_wrapper_t; | 66 typedef struct stat stat_wrapper_t; |
| 63 static int CallStat(const char *path, stat_wrapper_t *sb) { | 67 static int CallStat(const char *path, stat_wrapper_t *sb) { |
| 64 base::ThreadRestrictions::AssertIOAllowed(); | 68 base::ThreadRestrictions::AssertIOAllowed(); |
| 65 return stat(path, sb); | 69 return stat(path, sb); |
| 66 } | 70 } |
| (...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1009 if (use_dev_shm) { | 1013 if (use_dev_shm) { |
| 1010 *path = FilePath("/dev/shm"); | 1014 *path = FilePath("/dev/shm"); |
| 1011 return true; | 1015 return true; |
| 1012 } | 1016 } |
| 1013 #endif | 1017 #endif |
| 1014 return GetTempDir(path); | 1018 return GetTempDir(path); |
| 1015 } | 1019 } |
| 1016 #endif // !defined(OS_ANDROID) | 1020 #endif // !defined(OS_ANDROID) |
| 1017 | 1021 |
| 1018 FilePath GetHomeDir() { | 1022 FilePath GetHomeDir() { |
| 1023 #if defined(OS_CHROMEOS) |
| 1024 if (base::chromeos::IsRunningOnChromeOS()) |
| 1025 return FilePath("/home/chronos/user"); |
| 1026 #endif |
| 1027 |
| 1019 const char* home_dir = getenv("HOME"); | 1028 const char* home_dir = getenv("HOME"); |
| 1020 if (home_dir && home_dir[0]) | 1029 if (home_dir && home_dir[0]) |
| 1021 return FilePath(home_dir); | 1030 return FilePath(home_dir); |
| 1022 | 1031 |
| 1023 #if defined(OS_ANDROID) | 1032 #if defined(OS_ANDROID) |
| 1024 DLOG(WARNING) << "OS_ANDROID: Home directory lookup not yet implemented."; | 1033 DLOG(WARNING) << "OS_ANDROID: Home directory lookup not yet implemented."; |
| 1025 #else | 1034 #else |
| 1026 // g_get_home_dir calls getpwent, which can fall through to LDAP calls. | 1035 // g_get_home_dir calls getpwent, which can fall through to LDAP calls. |
| 1027 base::ThreadRestrictions::AssertIOAllowed(); | 1036 base::ThreadRestrictions::AssertIOAllowed(); |
| 1028 | 1037 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1151 | 1160 |
| 1152 allowed_group_ids.insert(group_record->gr_gid); | 1161 allowed_group_ids.insert(group_record->gr_gid); |
| 1153 } | 1162 } |
| 1154 | 1163 |
| 1155 return VerifyPathControlledByUser( | 1164 return VerifyPathControlledByUser( |
| 1156 kFileSystemRoot, path, kRootUid, allowed_group_ids); | 1165 kFileSystemRoot, path, kRootUid, allowed_group_ids); |
| 1157 } | 1166 } |
| 1158 #endif // defined(OS_MACOSX) && !defined(OS_IOS) | 1167 #endif // defined(OS_MACOSX) && !defined(OS_IOS) |
| 1159 | 1168 |
| 1160 } // namespace file_util | 1169 } // namespace file_util |
| OLD | NEW |