MCPcopy Create free account
hub / github.com/CloverHackyColor/CloverBootloader / LongFilePath

Function LongFilePath

BaseTools/Source/C/Common/CommonLib.c:594–735  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

592CHAR8 mCommonLibFullPath[MAX_LONG_FILE_PATH];
593
594CHAR8 *
595LongFilePath (
596 IN CHAR8 *FileName
597 )
598/*++
599
600Routine Description:
601 Convert FileName to the long file path, which can support larger than 260 length.
602
603Arguments:
604 FileName - FileName.
605
606Returns:
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!");

Callers 15

GetFileImageFunction · 0.70
PutFileImageFunction · 0.70
ProcessIncludeFileFunction · 0.70
OsPathExistsFunction · 0.70
GenCrc32.cFile · 0.50
WriteMapFileFunction · 0.50
AddFileFunction · 0.50
GenerateFvImageFunction · 0.50
CalculateFvSizeFunction · 0.50
FfsRebaseFunction · 0.50
GenerateCapImageFunction · 0.50
GenFv.cFile · 0.50

Calls 6

strncatFunction · 0.85
strstrFunction · 0.85
ErrorFunction · 0.70
strcpyFunction · 0.50
strlenFunction · 0.50
freeFunction · 0.50

Tested by

no test coverage detected