| 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 25 matching lines...) Expand all Loading... |
| 36 #include "base/logging.h" | 36 #include "base/logging.h" |
| 37 #include "base/memory/scoped_ptr.h" | 37 #include "base/memory/scoped_ptr.h" |
| 38 #include "base/memory/singleton.h" | 38 #include "base/memory/singleton.h" |
| 39 #include "base/path_service.h" | 39 #include "base/path_service.h" |
| 40 #include "base/posix/eintr_wrapper.h" | 40 #include "base/posix/eintr_wrapper.h" |
| 41 #include "base/stl_util.h" | 41 #include "base/stl_util.h" |
| 42 #include "base/strings/string_util.h" | 42 #include "base/strings/string_util.h" |
| 43 #include "base/strings/stringprintf.h" | 43 #include "base/strings/stringprintf.h" |
| 44 #include "base/strings/sys_string_conversions.h" | 44 #include "base/strings/sys_string_conversions.h" |
| 45 #include "base/strings/utf_string_conversions.h" | 45 #include "base/strings/utf_string_conversions.h" |
| 46 #include "base/sys_info.h" |
| 46 #include "base/threading/thread_restrictions.h" | 47 #include "base/threading/thread_restrictions.h" |
| 47 #include "base/time/time.h" | 48 #include "base/time/time.h" |
| 48 | 49 |
| 49 #if defined(OS_ANDROID) | 50 #if defined(OS_ANDROID) |
| 50 #include "base/os_compat_android.h" | 51 #include "base/os_compat_android.h" |
| 51 #endif | 52 #endif |
| 52 | 53 |
| 53 #if !defined(OS_IOS) | 54 #if !defined(OS_IOS) |
| 54 #include <grp.h> | 55 #include <grp.h> |
| 55 #endif | 56 #endif |
| 56 | 57 |
| 57 #if defined(OS_CHROMEOS) | |
| 58 #include "base/chromeos/chromeos_version.h" | |
| 59 #endif | |
| 60 | |
| 61 namespace base { | 58 namespace base { |
| 62 | 59 |
| 63 namespace { | 60 namespace { |
| 64 | 61 |
| 65 #if defined(OS_BSD) || defined(OS_MACOSX) | 62 #if defined(OS_BSD) || defined(OS_MACOSX) |
| 66 typedef struct stat stat_wrapper_t; | 63 typedef struct stat stat_wrapper_t; |
| 67 static int CallStat(const char *path, stat_wrapper_t *sb) { | 64 static int CallStat(const char *path, stat_wrapper_t *sb) { |
| 68 ThreadRestrictions::AssertIOAllowed(); | 65 ThreadRestrictions::AssertIOAllowed(); |
| 69 return stat(path, sb); | 66 return stat(path, sb); |
| 70 } | 67 } |
| (...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 *path = FilePath("/dev/shm"); | 761 *path = FilePath("/dev/shm"); |
| 765 return true; | 762 return true; |
| 766 } | 763 } |
| 767 #endif | 764 #endif |
| 768 return GetTempDir(path); | 765 return GetTempDir(path); |
| 769 } | 766 } |
| 770 #endif // !defined(OS_ANDROID) | 767 #endif // !defined(OS_ANDROID) |
| 771 | 768 |
| 772 FilePath GetHomeDir() { | 769 FilePath GetHomeDir() { |
| 773 #if defined(OS_CHROMEOS) | 770 #if defined(OS_CHROMEOS) |
| 774 if (base::chromeos::IsRunningOnChromeOS()) | 771 if (base::SysInfo::IsRunningOnChromeOS()) |
| 775 return FilePath("/home/chronos/user"); | 772 return FilePath("/home/chronos/user"); |
| 776 #endif | 773 #endif |
| 777 | 774 |
| 778 const char* home_dir = getenv("HOME"); | 775 const char* home_dir = getenv("HOME"); |
| 779 if (home_dir && home_dir[0]) | 776 if (home_dir && home_dir[0]) |
| 780 return FilePath(home_dir); | 777 return FilePath(home_dir); |
| 781 | 778 |
| 782 #if defined(OS_ANDROID) | 779 #if defined(OS_ANDROID) |
| 783 DLOG(WARNING) << "OS_ANDROID: Home directory lookup not yet implemented."; | 780 DLOG(WARNING) << "OS_ANDROID: Home directory lookup not yet implemented."; |
| 784 #else | 781 #else |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 949 result = false; | 946 result = false; |
| 950 if (HANDLE_EINTR(close(outfile)) < 0) | 947 if (HANDLE_EINTR(close(outfile)) < 0) |
| 951 result = false; | 948 result = false; |
| 952 | 949 |
| 953 return result; | 950 return result; |
| 954 } | 951 } |
| 955 #endif // !defined(OS_MACOSX) | 952 #endif // !defined(OS_MACOSX) |
| 956 | 953 |
| 957 } // namespace internal | 954 } // namespace internal |
| 958 } // namespace base | 955 } // namespace base |
| OLD | NEW |