| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 struct stat st; | 66 struct stat st; |
| 67 int res = ::stat(pathname.c_str(), &st); | 67 int res = ::stat(pathname.c_str(), &st); |
| 68 if (res == 0) { | 68 if (res == 0) { |
| 69 // Something exists at this location, check if it is a directory | 69 // Something exists at this location, check if it is a directory |
| 70 return S_ISDIR(st.st_mode) != 0; | 70 return S_ISDIR(st.st_mode) != 0; |
| 71 } else if (errno != ENOENT) { | 71 } else if (errno != ENOENT) { |
| 72 // Unexpected error | 72 // Unexpected error |
| 73 return false; | 73 return false; |
| 74 } | 74 } |
| 75 | 75 |
| 76 // Directory doesn't exist, look up one directory level | |
| 77 do { | |
| 78 --len; | |
| 79 } while ((len > 0) && (pathname[len - 1] != '/')); | |
| 80 | |
| 81 if (!CreateFolder(Pathname(pathname.substr(0, len)), mode)) { | |
| 82 return false; | |
| 83 } | |
| 84 | |
| 85 LOG(LS_INFO) << "Creating folder: " << pathname; | 76 LOG(LS_INFO) << "Creating folder: " << pathname; |
| 86 return (0 == ::mkdir(pathname.c_str(), mode)); | 77 return (0 == ::mkdir(pathname.c_str(), mode)); |
| 87 } | 78 } |
| 88 | 79 |
| 89 bool UnixFilesystem::CreateFolder(const Pathname &path) { | 80 bool UnixFilesystem::CreateFolder(const Pathname &path) { |
| 90 return CreateFolder(path, 0755); | 81 return CreateFolder(path, 0755); |
| 91 } | 82 } |
| 92 | 83 |
| 93 bool UnixFilesystem::DeleteFile(const Pathname &filename) { | 84 bool UnixFilesystem::DeleteFile(const Pathname &filename) { |
| 94 LOG(LS_INFO) << "Deleting file:" << filename.pathname(); | 85 LOG(LS_INFO) << "Deleting file:" << filename.pathname(); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 | 165 |
| 175 } // namespace rtc | 166 } // namespace rtc |
| 176 | 167 |
| 177 #if defined(__native_client__) | 168 #if defined(__native_client__) |
| 178 extern "C" int __attribute__((weak)) | 169 extern "C" int __attribute__((weak)) |
| 179 link(const char* oldpath, const char* newpath) { | 170 link(const char* oldpath, const char* newpath) { |
| 180 errno = EACCES; | 171 errno = EACCES; |
| 181 return -1; | 172 return -1; |
| 182 } | 173 } |
| 183 #endif | 174 #endif |
| OLD | NEW |