| 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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 } | 211 } |
| 212 | 212 |
| 213 bool UnixFilesystem::GetFileSize(const Pathname& pathname, size_t *size) { | 213 bool UnixFilesystem::GetFileSize(const Pathname& pathname, size_t *size) { |
| 214 struct stat st; | 214 struct stat st; |
| 215 if (::stat(pathname.pathname().c_str(), &st) != 0) | 215 if (::stat(pathname.pathname().c_str(), &st) != 0) |
| 216 return false; | 216 return false; |
| 217 *size = st.st_size; | 217 *size = st.st_size; |
| 218 return true; | 218 return true; |
| 219 } | 219 } |
| 220 | 220 |
| 221 bool UnixFilesystem::GetFileTime(const Pathname& path, FileTimeType which, | |
| 222 time_t* time) { | |
| 223 struct stat st; | |
| 224 if (::stat(path.pathname().c_str(), &st) != 0) | |
| 225 return false; | |
| 226 switch (which) { | |
| 227 case FTT_CREATED: | |
| 228 *time = st.st_ctime; | |
| 229 break; | |
| 230 case FTT_MODIFIED: | |
| 231 *time = st.st_mtime; | |
| 232 break; | |
| 233 case FTT_ACCESSED: | |
| 234 *time = st.st_atime; | |
| 235 break; | |
| 236 default: | |
| 237 return false; | |
| 238 } | |
| 239 return true; | |
| 240 } | |
| 241 | |
| 242 char* UnixFilesystem::CopyString(const std::string& str) { | 221 char* UnixFilesystem::CopyString(const std::string& str) { |
| 243 size_t size = str.length() + 1; | 222 size_t size = str.length() + 1; |
| 244 | 223 |
| 245 char* buf = new char[size]; | 224 char* buf = new char[size]; |
| 246 if (!buf) { | 225 if (!buf) { |
| 247 return nullptr; | 226 return nullptr; |
| 248 } | 227 } |
| 249 | 228 |
| 250 strcpyn(buf, size, str.c_str()); | 229 strcpyn(buf, size, str.c_str()); |
| 251 return buf; | 230 return buf; |
| 252 } | 231 } |
| 253 | 232 |
| 254 } // namespace rtc | 233 } // namespace rtc |
| 255 | 234 |
| 256 #if defined(__native_client__) | 235 #if defined(__native_client__) |
| 257 extern "C" int __attribute__((weak)) | 236 extern "C" int __attribute__((weak)) |
| 258 link(const char* oldpath, const char* newpath) { | 237 link(const char* oldpath, const char* newpath) { |
| 259 errno = EACCES; | 238 errno = EACCES; |
| 260 return -1; | 239 return -1; |
| 261 } | 240 } |
| 262 #endif | 241 #endif |
| OLD | NEW |