| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 return S_ISDIR(st.st_mode); | 137 return S_ISDIR(st.st_mode); |
| 138 } | 138 } |
| 139 | 139 |
| 140 bool UnixFilesystem::IsFile(const Pathname& pathname) { | 140 bool UnixFilesystem::IsFile(const Pathname& pathname) { |
| 141 struct stat st; | 141 struct stat st; |
| 142 int res = ::stat(pathname.pathname().c_str(), &st); | 142 int res = ::stat(pathname.pathname().c_str(), &st); |
| 143 // Treat symlinks, named pipes, etc. all as files. | 143 // Treat symlinks, named pipes, etc. all as files. |
| 144 return res == 0 && !S_ISDIR(st.st_mode); | 144 return res == 0 && !S_ISDIR(st.st_mode); |
| 145 } | 145 } |
| 146 | 146 |
| 147 bool UnixFilesystem::IsAbsent(const Pathname& pathname) { | |
| 148 struct stat st; | |
| 149 int res = ::stat(pathname.pathname().c_str(), &st); | |
| 150 // Note: we specifically maintain ENOTDIR as an error, because that implies | |
| 151 // that you could not call CreateFolder(pathname). | |
| 152 return res != 0 && ENOENT == errno; | |
| 153 } | |
| 154 | |
| 155 bool UnixFilesystem::GetFileSize(const Pathname& pathname, size_t *size) { | 147 bool UnixFilesystem::GetFileSize(const Pathname& pathname, size_t *size) { |
| 156 struct stat st; | 148 struct stat st; |
| 157 if (::stat(pathname.pathname().c_str(), &st) != 0) | 149 if (::stat(pathname.pathname().c_str(), &st) != 0) |
| 158 return false; | 150 return false; |
| 159 *size = st.st_size; | 151 *size = st.st_size; |
| 160 return true; | 152 return true; |
| 161 } | 153 } |
| 162 | 154 |
| 163 char* UnixFilesystem::CopyString(const std::string& str) { | 155 char* UnixFilesystem::CopyString(const std::string& str) { |
| 164 size_t size = str.length() + 1; | 156 size_t size = str.length() + 1; |
| 165 | 157 |
| 166 char* buf = new char[size]; | 158 char* buf = new char[size]; |
| 167 if (!buf) { | 159 if (!buf) { |
| 168 return nullptr; | 160 return nullptr; |
| 169 } | 161 } |
| 170 | 162 |
| 171 strcpyn(buf, size, str.c_str()); | 163 strcpyn(buf, size, str.c_str()); |
| 172 return buf; | 164 return buf; |
| 173 } | 165 } |
| 174 | 166 |
| 175 } // namespace rtc | 167 } // namespace rtc |
| 176 | 168 |
| 177 #if defined(__native_client__) | 169 #if defined(__native_client__) |
| 178 extern "C" int __attribute__((weak)) | 170 extern "C" int __attribute__((weak)) |
| 179 link(const char* oldpath, const char* newpath) { | 171 link(const char* oldpath, const char* newpath) { |
| 180 errno = EACCES; | 172 errno = EACCES; |
| 181 return -1; | 173 return -1; |
| 182 } | 174 } |
| 183 #endif | 175 #endif |
| OLD | NEW |