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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 default_filesystem_ = new UnixFilesystem(); | 127 default_filesystem_ = new UnixFilesystem(); |
128 #endif | 128 #endif |
129 } | 129 } |
130 return default_filesystem_; | 130 return default_filesystem_; |
131 } | 131 } |
132 | 132 |
133 DirectoryIterator* FilesystemInterface::IterateDirectory() { | 133 DirectoryIterator* FilesystemInterface::IterateDirectory() { |
134 return new DirectoryIterator(); | 134 return new DirectoryIterator(); |
135 } | 135 } |
136 | 136 |
137 bool FilesystemInterface::DeleteFolderContents(const Pathname &folder) { | |
138 bool success = true; | |
139 RTC_CHECK(IsFolder(folder)); | |
140 DirectoryIterator *di = IterateDirectory(); | |
141 if (!di) | |
142 return false; | |
143 if (di->Iterate(folder)) { | |
144 do { | |
145 if (di->Name() == "." || di->Name() == "..") | |
146 continue; | |
147 Pathname subdir; | |
148 subdir.SetFolder(folder.pathname()); | |
149 if (di->IsDirectory()) { | |
150 subdir.AppendFolder(di->Name()); | |
151 if (!DeleteFolderAndContents(subdir)) { | |
152 success = false; | |
153 } | |
154 } else { | |
155 subdir.SetFilename(di->Name()); | |
156 if (!DeleteFile(subdir)) { | |
157 success = false; | |
158 } | |
159 } | |
160 } while (di->Next()); | |
161 } | |
162 delete di; | |
163 return success; | |
164 } | |
165 | |
166 bool FilesystemInterface::DeleteFolderAndContents(const Pathname& folder) { | |
167 return DeleteFolderContents(folder) && DeleteEmptyFolder(folder); | |
168 } | |
169 | |
170 } // namespace rtc | 137 } // namespace rtc |
OLD | NEW |