** Function: createDirRecursive ** Create folders recursivelly **********************************************************************/
| 193 | ** Create folders recursivelly |
| 194 | **********************************************************************/ |
| 195 | void createDirRecursive(String path, FS fs) { |
| 196 | String currentPath = ""; |
| 197 | int startIndex = 0; |
| 198 | // Serial.print("Verifying folder: "); |
| 199 | // Serial.println(path); |
| 200 | |
| 201 | while (startIndex < path.length()) { |
| 202 | int endIndex = path.indexOf("/", startIndex); |
| 203 | if (endIndex == -1) endIndex = path.length(); |
| 204 | |
| 205 | currentPath += path.substring(startIndex, endIndex); |
| 206 | if (currentPath.length() > 0) { |
| 207 | if (!fs.exists(currentPath)) { |
| 208 | fs.mkdir(currentPath); |
| 209 | // Serial.print("Creating folder: "); |
| 210 | // Serial.println(currentPath); |
| 211 | } |
| 212 | } |
| 213 | |
| 214 | if (endIndex < path.length()) { currentPath += "/"; } |
| 215 | startIndex = endIndex + 1; |
| 216 | } |
| 217 | } |
| 218 | /********************************************************************** |
| 219 | ** Function: handleUpload |
| 220 | ** handles uploads to the filserver |