| 592 | CHAR8 mCommonLibFullPath[MAX_LONG_FILE_PATH]; |
| 593 | |
| 594 | CHAR8 * |
| 595 | LongFilePath ( |
| 596 | IN CHAR8 *FileName |
| 597 | ) |
| 598 | /*++ |
| 599 | |
| 600 | Routine Description: |
| 601 | Convert FileName to the long file path, which can support larger than 260 length. |
| 602 | |
| 603 | Arguments: |
| 604 | FileName - FileName. |
| 605 | |
| 606 | Returns: |
| 607 | LongFilePath A pointer to the converted long file path. |
| 608 | |
| 609 | --*/ |
| 610 | { |
| 611 | #ifdef __GNUC__ |
| 612 | // |
| 613 | // __GNUC__ may not be good way to differentiate unix and windows. Need more investigation here. |
| 614 | // unix has no limitation on file path. Just return FileName. |
| 615 | // |
| 616 | return FileName; |
| 617 | #else |
| 618 | CHAR8 *RootPath; |
| 619 | CHAR8 *PathPointer; |
| 620 | CHAR8 *NextPointer; |
| 621 | |
| 622 | PathPointer = (CHAR8 *) FileName; |
| 623 | |
| 624 | if (FileName != NULL) { |
| 625 | // |
| 626 | // Add the extension string first to support long file path. |
| 627 | // |
| 628 | mCommonLibFullPath[0] = 0; |
| 629 | strcpy (mCommonLibFullPath, WINDOWS_EXTENSION_PATH); |
| 630 | |
| 631 | if (strlen (FileName) > 1 && FileName[0] == '\\' && FileName[1] == '\\') { |
| 632 | // |
| 633 | // network path like \\server\share to \\?\UNC\server\share |
| 634 | // |
| 635 | strcpy (mCommonLibFullPath, WINDOWS_UNC_EXTENSION_PATH); |
| 636 | FileName ++; |
| 637 | } else if (strlen (FileName) < 3 || FileName[1] != ':' || (FileName[2] != '\\' && FileName[2] != '/')) { |
| 638 | // |
| 639 | // Relative file path. Convert it to absolute path. |
| 640 | // |
| 641 | RootPath = getcwd (NULL, 0); |
| 642 | if (RootPath != NULL) { |
| 643 | if (strlen (mCommonLibFullPath) + strlen (RootPath) > MAX_LONG_FILE_PATH - 1) { |
| 644 | Error (NULL, 0, 2000, "Invalid parameter", "RootPath is too long!"); |
| 645 | free (RootPath); |
| 646 | return NULL; |
| 647 | } |
| 648 | strncat (mCommonLibFullPath, RootPath, MAX_LONG_FILE_PATH - strlen (mCommonLibFullPath) - 1); |
| 649 | if (FileName[0] != '\\' && FileName[0] != '/') { |
| 650 | if (strlen (mCommonLibFullPath) + 1 > MAX_LONG_FILE_PATH - 1) { |
| 651 | Error (NULL, 0, 2000, "Invalid parameter", "RootPath is too long!"); |
no test coverage detected