Get a long pretty path based on a DOS 8.3 path
| 368 | // Get a long pretty path based on a DOS 8.3 path |
| 369 | // |
| 370 | void CardReader::printLongPath(char * const path) { |
| 371 | |
| 372 | int i, pathLen = path ? strlen(path) : 0; |
| 373 | |
| 374 | // SERIAL_ECHOPGM("Full Path: "); SERIAL_ECHOLN(path); |
| 375 | |
| 376 | // Zero out slashes to make segments |
| 377 | for (i = 0; i < pathLen; i++) if (path[i] == '/') path[i] = '\0'; |
| 378 | |
| 379 | MediaFile diveDir = root; // start from the root for segment 1 |
| 380 | for (i = 0; i < pathLen;) { |
| 381 | |
| 382 | if (path[i] == '\0') i++; // move past a single nul |
| 383 | |
| 384 | char *segment = &path[i]; // The segment after most slashes |
| 385 | |
| 386 | // If a segment is empty (extra-slash) then exit |
| 387 | if (!*segment) break; |
| 388 | |
| 389 | // Go to the next segment |
| 390 | while (path[++i]) { } |
| 391 | |
| 392 | //SERIAL_ECHOLNPGM("Looking for segment: ", segment); |
| 393 | |
| 394 | // Find the item, setting the long filename |
| 395 | diveDir.rewind(); |
| 396 | selectByName(diveDir, segment); |
| 397 | |
| 398 | // Print /LongNamePart to serial output or the short name if not available |
| 399 | SERIAL_CHAR('/'); |
| 400 | SERIAL_ECHO(longFilename[0] ? longFilename : filename); |
| 401 | |
| 402 | // If the filename was printed then that's it |
| 403 | if (!flag.filenameIsDir) break; |
| 404 | |
| 405 | // SERIAL_ECHOPGM("Opening dir: "); SERIAL_ECHOLN(segment); |
| 406 | |
| 407 | // Open the sub-item as the new dive parent |
| 408 | MediaFile dir; |
| 409 | if (!dir.open(&diveDir, segment, O_READ)) { |
| 410 | SERIAL_EOL(); |
| 411 | SERIAL_ECHO_START(); |
| 412 | SERIAL_ECHOPGM(STR_SD_CANT_OPEN_SUBDIR, segment); |
| 413 | break; |
| 414 | } |
| 415 | |
| 416 | diveDir.close(); |
| 417 | diveDir = dir; |
| 418 | |
| 419 | } // while i<pathLen |
| 420 | |
| 421 | SERIAL_EOL(); |
| 422 | } |
| 423 | |
| 424 | void CardReader::getLongPath(char * const pathLong, char * const pathShort) { |
| 425 |
no test coverage detected