Remove unneeded wc_str(). Correct comparison order.

This commit is contained in:
Jief L 2020-04-27 15:13:09 +03:00
parent de2bb5f950
commit a188e19f02
8 changed files with 29 additions and 22 deletions

View File

@ -190,7 +190,7 @@ CreateBootOptionDevicePath (
//
// Create file path node with FileName
//
*DevicePath = FileDevicePath(FileDeviceHandle, FileName.wc_str());
*DevicePath = FileDevicePath(FileDeviceHandle, FileName);
if (*DevicePath == NULL) {
return EFI_OUT_OF_RESOURCES;
}

View File

@ -1334,7 +1334,7 @@ EFI_STATUS SetStartupDiskVolume (
//
DevPath = Volume->DevicePath;
if (LoaderPath.notEmpty()) {
FileDevPath = FileDevicePath (NULL, LoaderPath.wc_str());
FileDevPath = FileDevicePath (NULL, LoaderPath);
DevPath = AppendDevicePathNode (DevPath, FileDevPath);
}
DBG(" * DevPath: %ls\n", Volume->VolName/*, FileDevicePathToStr (DevPath)*/);

View File

@ -361,7 +361,7 @@ STATIC XStringArray LinuxKernelOptions(IN EFI_FILE_PROTOCOL *Dir,
while (Index < LinuxInitImagePathCount) {
XStringW InitRd = SWPrintf(LinuxInitImagePath[Index++].c_str(), (Version == NULL) ? L"" : Version);
if (InitRd.notEmpty()) {
if (FileExists(Dir, InitRd.wc_str())) {
if (FileExists(Dir, InitRd)) {
XStringArray CustomOptions;
CustomOptions.Add(SPrintf("root=/dev/disk/by-partuuid/%ls", PartUUID));
CustomOptions.Add(SPrintf("initrd=%ls\\%ls", LINUX_BOOT_ALT_PATH, InitRd.wc_str()));
@ -471,7 +471,7 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST XStringW& LoaderPath,
// Get the loader device path
// LoaderDevicePath = FileDevicePath(Volume->DeviceHandle, (*LoaderPath == L'\\') ? (LoaderPath + 1) : LoaderPath);
LoaderDevicePath = FileDevicePath(Volume->DeviceHandle, LoaderPath.wc_str());
LoaderDevicePath = FileDevicePath(Volume->DeviceHandle, LoaderPath);
if (LoaderDevicePath == NULL) {
return NULL;
}
@ -1032,7 +1032,7 @@ BOOLEAN AddLoaderEntry(IN CONST XStringW& LoaderPath, IN CONST XStringArray& Loa
LOADER_ENTRY *Entry;
INTN HVi;
if ((LoaderPath.isEmpty()) || (Volume == NULL) || (Volume->RootDir == NULL) || !FileExists(Volume->RootDir, LoaderPath.wc_str())) {
if ((LoaderPath.isEmpty()) || (Volume == NULL) || (Volume->RootDir == NULL) || !FileExists(Volume->RootDir, LoaderPath)) {
return FALSE;
}
@ -1094,9 +1094,9 @@ VOID AddPRSEntry(REFIT_VOLUME *Volume)
//CONST INTN Rock = 2;
//CONST INTN Scissor = 4;
WhatBoot |= FileExists(Volume->RootDir, RockBoot.wc_str())?Rock:0;
WhatBoot |= FileExists(Volume->RootDir, PaperBoot.wc_str())?Paper:0;
WhatBoot |= FileExists(Volume->RootDir, ScissorBoot.wc_str())?Scissor:0;
WhatBoot |= FileExists(Volume->RootDir, RockBoot)?Rock:0;
WhatBoot |= FileExists(Volume->RootDir, PaperBoot)?Paper:0;
WhatBoot |= FileExists(Volume->RootDir, ScissorBoot)?Scissor:0;
switch (WhatBoot) {
case Paper:
case (Paper | Rock):
@ -1167,7 +1167,7 @@ VOID ScanLoader(VOID)
} else {
AddLoaderEntry(L"\\.IABootFiles\\boot.efi"_XSW, NullXStringArray, L"macOS Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.12 - 10.13.3
}
} else if (FileExists(Volume->RootDir, L"\\.IAPhysicalMedia") && FileExists(Volume->RootDir, MACOSX_LOADER_PATH.wc_str())) {
} else if (FileExists(Volume->RootDir, L"\\.IAPhysicalMedia") && FileExists(Volume->RootDir, MACOSX_LOADER_PATH)) {
AddLoaderEntry(MACOSX_LOADER_PATH, NullXStringArray, L"macOS Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.13.4+
}
// 2nd stage - InstallESD/AppStore/startosinstall/Fusion Drive
@ -1181,7 +1181,7 @@ VOID ScanLoader(VOID)
AddLoaderEntry(L"\\NetInstall macOS High Sierra.nbi\\i386\\booter"_XSW, NullXStringArray, L"macOS Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0);
// Use standard location for boot.efi, according to the install files is present
// That file indentifies a DVD/ESD/BaseSystem/Fusion Drive Install Media, so when present, check standard path to avoid entry duplication
if (FileExists(Volume->RootDir, MACOSX_LOADER_PATH.wc_str())) {
if (FileExists(Volume->RootDir, MACOSX_LOADER_PATH)) {
if (FileExists(Volume->RootDir, L"\\System\\Installation\\CDIS\\Mac OS X Installer.app")) {
// InstallDVD/BaseSystem
AddLoaderEntry(MACOSX_LOADER_PATH, NullXStringArray, L"Mac OS X Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.6/10.7
@ -1265,7 +1265,7 @@ VOID ScanLoader(VOID)
// check for Android loaders
for (Index = 0; Index < AndroidEntryDataCount; ++Index) {
UINTN aIndex, aFound;
if (FileExists(Volume->RootDir, AndroidEntryData[Index].Path.wc_str())) {
if (FileExists(Volume->RootDir, AndroidEntryData[Index].Path)) {
aFound = 0;
for (aIndex = 0; aIndex < ANDX86_FINDLEN; ++aIndex) {
if ((AndroidEntryData[Index].Find[aIndex].isEmpty()) || FileExists(Volume->RootDir, AndroidEntryData[Index].Find[aIndex])) ++aFound;
@ -1297,7 +1297,7 @@ VOID ScanLoader(VOID)
XStringW File = SWPrintf("EFI\\%ls\\grubx64.efi", DirEntry->FileName);
XStringW OSName = SPrintf("%ls", DirEntry->FileName); // this is folder name, for example "ubuntu"
OSName.lowerAscii(); // lowercase for icon name
if (FileExists(Volume->RootDir, File.wc_str())) {
if (FileExists(Volume->RootDir, File)) {
// check if nonstandard icon mapping is needed
for (Index = 0; Index < LinuxIconMappingCount; ++Index) {
if (StrCmp(OSName.wc_str(),LinuxIconMapping[Index].DirectoryName) == 0) {
@ -1443,7 +1443,7 @@ VOID ScanLoader(VOID)
if (FileInfo->FileSize > 0) {
// get the kernel file path
XStringW NewPath = SWPrintf("%ls\\%ls", LINUX_BOOT_PATH, FileInfo->FileName);
if ( Path > NewPath ) {
if ( Path < NewPath ) {
Path = NewPath;
}else{
Path.setEmpty();
@ -1469,7 +1469,7 @@ VOID ScanLoader(VOID)
if (FileInfo->FileSize > 0) {
// get the kernel file path
XStringW NewPath = SWPrintf("%ls\\%ls", LINUX_BOOT_PATH, FileInfo->FileName);
if ( Path < NewPath ) {
if ( Path > NewPath ) {
Path = NewPath;
}else{
Path.setEmpty();
@ -1802,7 +1802,7 @@ STATIC VOID AddCustomEntry(IN UINTN CustomIndex,
Custom->KernelScan = KERNEL_SCAN_ALL;
break;
}
} else if (!FileExists(Volume->RootDir, CustomPath.wc_str())) {
} else if (!FileExists(Volume->RootDir, CustomPath)) {
DBG("skipped because path does not exist\n");
continue;
}

View File

@ -80,7 +80,7 @@ STATIC BOOLEAN AddToolEntry(IN CONST XStringW& LoaderPath, IN CONST CHAR16 *Full
REFIT_MENU_ENTRY_LOADER_TOOL *Entry;
// Check the loader exists
if ((LoaderPath.isEmpty()) || (Volume == NULL) || (Volume->RootDir == NULL) ||
!FileExists(Volume->RootDir, LoaderPath.wc_str())) {
!FileExists(Volume->RootDir, LoaderPath)) {
return FALSE;
}
// Allocate the entry
@ -101,7 +101,7 @@ STATIC BOOLEAN AddToolEntry(IN CONST XStringW& LoaderPath, IN CONST CHAR16 *Full
Entry->Image = Image;
// Entry->ImageHover = ImageHover;
Entry->LoaderPath = LoaderPath;
Entry->DevicePath = FileDevicePath(Volume->DeviceHandle, Entry->LoaderPath.wc_str());
Entry->DevicePath = FileDevicePath(Volume->DeviceHandle, Entry->LoaderPath);
Entry->DevicePathString = FileDevicePathToStr(Entry->DevicePath);
Entry->LoadOptions = Options;
//actions
@ -132,7 +132,7 @@ STATIC VOID AddCloverEntry(IN CONST XStringW& LoaderPath, IN CONST CHAR16 *Loade
Entry->Volume = Volume;
Entry->LoaderPath = LoaderPath;
Entry->VolName = Volume->VolName;
Entry->DevicePath = FileDevicePath(Volume->DeviceHandle, Entry->LoaderPath.wc_str());
Entry->DevicePath = FileDevicePath(Volume->DeviceHandle, Entry->LoaderPath);
Entry->DevicePathString = FileDevicePathToStr(Entry->DevicePath);
Entry->Flags = 0;
Entry->LoadOptions.setEmpty();
@ -222,7 +222,7 @@ VOID ScanTool(VOID)
DBG(" Deleted /EFI label\n");
}
if (FileExists(Volume->RootDir, CLOVER_MEDIA_FILE_NAME.wc_str())) {
if (FileExists(Volume->RootDir, CLOVER_MEDIA_FILE_NAME)) {
DBG(" Found Clover\n");
// Volume->BootType = BOOTING_BY_EFI;
AddCloverEntry(CLOVER_MEDIA_FILE_NAME, L"Clover Boot Options", Volume);
@ -305,7 +305,7 @@ VOID AddCustomTool(VOID)
}
}
// Check the tool exists on the volume
if (!FileExists(Volume->RootDir, Custom->Path.wc_str())) {
if (!FileExists(Volume->RootDir, Custom->Path)) {
DBG("skipped because path does not exist\n");
continue;
}

View File

@ -129,7 +129,7 @@ void FILM::GetFrames(XTheme& TheTheme /*, const XStringW& Path*/) // Path alread
} else {
XStringW Name = SWPrintf("%ls\\%ls_%03lld.png", Path.wc_str(), Path.wc_str(), Index);
// DBG("try to load %ls\n", Name.wc_str()); //fine
if (FileExists(ThemeDir, Name.wc_str())) {
if (FileExists(ThemeDir, Name)) {
Status = NewImage.LoadXImage(ThemeDir, Name);
}
// DBG(" read status=%s\n", strerror(Status));

View File

@ -560,7 +560,7 @@ EFI_STATUS egScreenShot(VOID)
for (UINTN Index = 0; Index < 60; Index++) {
// ScreenshotName = PoolPrint(L"%a%d.png", ScreenShotName, Index);
XStringW Name = SWPrintf("EFI\\CLOVER\\misc\\screenshot%lld.png", Index);
if (!FileExists(SelfRootDir, Name.wc_str())) {
if (!FileExists(SelfRootDir, Name)) {
Status = egSaveFile(SelfRootDir, Name.wc_str(), FileData, FileDataLength);
if (!EFI_ERROR(Status)) {
break;

View File

@ -332,6 +332,8 @@ REFIT_VOLUME *FindVolumeByName(IN CHAR16 *VolName);
BOOLEAN FileExists(IN CONST EFI_FILE *BaseDir, IN CONST CHAR16 *RelativePath);
BOOLEAN FileExists(IN CONST EFI_FILE *BaseDir, IN CONST XStringW& RelativePath);
inline EFI_DEVICE_PATH_PROTOCOL* FileDevicePath (IN EFI_HANDLE Device, IN CONST XStringW& FileName) { return FileDevicePath(Device, FileName.wc_str()); }
BOOLEAN DeleteFile(IN EFI_FILE *Root, IN CONST CHAR16 *RelativePath);
EFI_STATUS DirNextEntry(IN EFI_FILE *Directory, IN OUT EFI_FILE_INFO **DirEntry, IN UINTN FilterMode);

View File

@ -1974,6 +1974,11 @@ RefitMain (IN EFI_HANDLE ImageHandle,
construct_globals_objects(); // do this after SelfLoadedImage is initialized
#ifdef JIEF_DEBUG
all_tests();
printf("StrCmp(L\"aab\", L\"aac\")=%d\n", StrCmp(L"aac", L"aab") > 0);
printf("StrCmp(L\"aab\"_XSW, L\"aac\"_XSW)=%d\n", L"aac"_XSW > L"aab"_XSW);
PauseForKey(L"press\n");
#endif
//dumping SETTING structure