** Function name: pasteFile ** Description: paste file to new folder ***************************************************************************************/
| 273 | ** Description: paste file to new folder |
| 274 | ***************************************************************************************/ |
| 275 | bool pasteFile(FS fs, String path) { |
| 276 | // Using Global Buffer |
| 277 | |
| 278 | // Abrir o arquivo original |
| 279 | File sourceFile = fs.open(fileToCopy, FILE_READ); |
| 280 | if (!sourceFile) { |
| 281 | // Serial.println("Falha ao abrir o arquivo original para leitura"); |
| 282 | return false; |
| 283 | } |
| 284 | |
| 285 | // Criar o arquivo de destino |
| 286 | File destFile = fs.open(path + "/" + fileToCopy.substring(fileToCopy.lastIndexOf('/') + 1), FILE_WRITE); |
| 287 | if (!destFile) { |
| 288 | // Serial.println("Falha ao criar o arquivo de destino"); |
| 289 | sourceFile.close(); |
| 290 | return false; |
| 291 | } |
| 292 | |
| 293 | // Ler dados do arquivo original e escrever no arquivo de destino |
| 294 | size_t bytesRead; |
| 295 | int tot = sourceFile.size(); |
| 296 | int prog = 0; |
| 297 | const int bufSize = 1024; |
| 298 | uint8_t buff[1024] = {0}; |
| 299 | // tft.drawRect(5,tftHeight-12, (tftWidth-10), 9, bruceConfig.priColor); |
| 300 | while ((bytesRead = sourceFile.read(buff, bufSize)) > 0) { |
| 301 | if (destFile.write(buff, bytesRead) != bytesRead) { |
| 302 | // Serial.println("Falha ao escrever no arquivo de destino"); |
| 303 | sourceFile.close(); |
| 304 | destFile.close(); |
| 305 | return false; |
| 306 | } else { |
| 307 | prog += bytesRead; |
| 308 | float rad = 360 * prog / tot; |
| 309 | tft.drawArc( |
| 310 | tftWidth / 2, |
| 311 | tftHeight / 2, |
| 312 | tftHeight / 4, |
| 313 | tftHeight / 5, |
| 314 | 0, |
| 315 | int(rad), |
| 316 | ALCOLOR, |
| 317 | bruceConfig.bgColor, |
| 318 | true |
| 319 | ); |
| 320 | // tft.fillRect(7,tftHeight-10, (tftWidth-14)*prog/tot, 5, bruceConfig.priColor); |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | // Fechar ambos os arquivos |
| 325 | sourceFile.close(); |
| 326 | destFile.close(); |
| 327 | return true; |
| 328 | } |
| 329 | |
| 330 | /*************************************************************************************** |
| 331 | ** Function name: createFolder |