Răsfoiți Sursa

Renaming ComparePaths and IsPathToSameFile to use "Same" instead of "Compare" as they return bool, not int + SameFileName already exists in VCL

Source commit: 4d09a03368b69c64db9fadfcd050aa367af12e16
Martin Prikryl 9 ani în urmă
părinte
comite
4d2717d618

+ 2 - 2
source/core/Common.cpp

@@ -715,7 +715,7 @@ UnicodeString __fastcall ExpandEnvironmentVariables(const UnicodeString & Str)
   return Buf;
   return Buf;
 }
 }
 //---------------------------------------------------------------------------
 //---------------------------------------------------------------------------
-bool __fastcall CompareFileName(const UnicodeString & Path1, const UnicodeString & Path2)
+bool __fastcall IsPathToSameFile(const UnicodeString & Path1, const UnicodeString & Path2)
 {
 {
   UnicodeString ShortPath1 = ExtractShortPathName(Path1);
   UnicodeString ShortPath1 = ExtractShortPathName(Path1);
   UnicodeString ShortPath2 = ExtractShortPathName(Path2);
   UnicodeString ShortPath2 = ExtractShortPathName(Path2);
@@ -733,7 +733,7 @@ bool __fastcall CompareFileName(const UnicodeString & Path1, const UnicodeString
   return Result;
   return Result;
 }
 }
 //---------------------------------------------------------------------------
 //---------------------------------------------------------------------------
-bool __fastcall ComparePaths(const UnicodeString & Path1, const UnicodeString & Path2)
+bool __fastcall SamePaths(const UnicodeString & Path1, const UnicodeString & Path2)
 {
 {
   // TODO: ExpandUNCFileName
   // TODO: ExpandUNCFileName
   return AnsiSameText(IncludeTrailingBackslash(Path1), IncludeTrailingBackslash(Path2));
   return AnsiSameText(IncludeTrailingBackslash(Path1), IncludeTrailingBackslash(Path2));

+ 2 - 2
source/core/Common.h

@@ -82,8 +82,8 @@ void __fastcall ReformatFileNameCommand(UnicodeString & Command);
 UnicodeString __fastcall EscapeParam(const UnicodeString & Param);
 UnicodeString __fastcall EscapeParam(const UnicodeString & Param);
 UnicodeString __fastcall EscapePuttyCommandParam(UnicodeString Param);
 UnicodeString __fastcall EscapePuttyCommandParam(UnicodeString Param);
 UnicodeString __fastcall ExpandEnvironmentVariables(const UnicodeString & Str);
 UnicodeString __fastcall ExpandEnvironmentVariables(const UnicodeString & Str);
-bool __fastcall ComparePaths(const UnicodeString & Path1, const UnicodeString & Path2);
-bool __fastcall CompareFileName(const UnicodeString & Path1, const UnicodeString & Path2);
+bool __fastcall SamePaths(const UnicodeString & Path1, const UnicodeString & Path2);
+bool __fastcall IsPathToSameFile(const UnicodeString & Path1, const UnicodeString & Path2);
 int __fastcall CompareLogicalText(const UnicodeString & S1, const UnicodeString & S2);
 int __fastcall CompareLogicalText(const UnicodeString & S1, const UnicodeString & S2);
 bool __fastcall IsReservedName(UnicodeString FileName);
 bool __fastcall IsReservedName(UnicodeString FileName);
 UnicodeString __fastcall ApiPath(UnicodeString Path);
 UnicodeString __fastcall ApiPath(UnicodeString Path);

+ 1 - 1
source/forms/Preferences.cpp

@@ -2123,7 +2123,7 @@ void __fastcall TPreferencesDialog::PathEditBeforeDialog(
 void __fastcall TPreferencesDialog::PathEditAfterDialog(
 void __fastcall TPreferencesDialog::PathEditAfterDialog(
   TObject * /*Sender*/, UnicodeString & Name, bool & /*Action*/)
   TObject * /*Sender*/, UnicodeString & Name, bool & /*Action*/)
 {
 {
-  if (CompareFileName(Name, ExpandEnvironmentVariables(FBeforeDialogPath)))
+  if (IsPathToSameFile(Name, ExpandEnvironmentVariables(FBeforeDialogPath)))
   {
   {
     Name = FBeforeDialogPath;
     Name = FBeforeDialogPath;
   }
   }

+ 4 - 4
source/forms/ScpCommander.cpp

@@ -427,7 +427,7 @@ bool __fastcall TScpCommanderForm::IsFileControl(TObject * Control,
 //---------------------------------------------------------------------------
 //---------------------------------------------------------------------------
 void __fastcall TScpCommanderForm::ReloadLocalDirectory(const UnicodeString Directory)
 void __fastcall TScpCommanderForm::ReloadLocalDirectory(const UnicodeString Directory)
 {
 {
-  if (Directory.IsEmpty() || ComparePaths(Directory, LocalDirView->Path))
+  if (Directory.IsEmpty() || SamePaths(Directory, LocalDirView->Path))
   {
   {
     LocalDirView->ReloadDirectory();
     LocalDirView->ReloadDirectory();
     LocalDriveView->ValidateDirectory(LocalDriveView->Selected);
     LocalDriveView->ValidateDirectory(LocalDriveView->Selected);
@@ -1042,7 +1042,7 @@ void __fastcall TScpCommanderForm::SynchronizeBrowsingLocal(
       PrevPath = IncludeTrailingBackslash(PrevPath);
       PrevPath = IncludeTrailingBackslash(PrevPath);
       CommonPath = IncludeTrailingBackslash(CommonPath);
       CommonPath = IncludeTrailingBackslash(CommonPath);
       NewPath = RemoteDirView->Path;
       NewPath = RemoteDirView->Path;
-      while (!ComparePaths(PrevPath, CommonPath))
+      while (!SamePaths(PrevPath, CommonPath))
       {
       {
         if (NewPath == UnixExcludeTrailingBackslash(NewPath))
         if (NewPath == UnixExcludeTrailingBackslash(NewPath))
         {
         {
@@ -1746,7 +1746,7 @@ void __fastcall TScpCommanderForm::RemotePathLabelGetStatus(
 void __fastcall TScpCommanderForm::LocalPathLabelPathClick(
 void __fastcall TScpCommanderForm::LocalPathLabelPathClick(
   TCustomPathLabel * /*Sender*/, UnicodeString Path)
   TCustomPathLabel * /*Sender*/, UnicodeString Path)
 {
 {
-  if (ComparePaths(Path, LocalDirView->Path))
+  if (SamePaths(Path, LocalDirView->Path))
   {
   {
     OpenDirectory(osLocal);
     OpenDirectory(osLocal);
   }
   }
@@ -1896,7 +1896,7 @@ void __fastcall TScpCommanderForm::LocalPathComboUpdate()
 
 
     int Index = 0;
     int Index = 0;
     while ((Index < FLocalPathComboBoxPaths->Count) &&
     while ((Index < FLocalPathComboBoxPaths->Count) &&
-           !ComparePaths(FLocalPathComboBoxPaths->Strings[Index],
+           !SamePaths(FLocalPathComboBoxPaths->Strings[Index],
              LocalDirView->Path.SubString(1, FLocalPathComboBoxPaths->Strings[Index].Length())))
              LocalDirView->Path.SubString(1, FLocalPathComboBoxPaths->Strings[Index].Length())))
     {
     {
       Index++;
       Index++;

+ 1 - 1
source/forms/SiteAdvanced.cpp

@@ -1274,7 +1274,7 @@ void __fastcall TSiteAdvancedDialog::PathEditBeforeDialog(TObject * /*Sender*/,
 void __fastcall TSiteAdvancedDialog::PathEditAfterDialog(TObject * /*Sender*/,
 void __fastcall TSiteAdvancedDialog::PathEditAfterDialog(TObject * /*Sender*/,
   UnicodeString & Name, bool & /*Action*/)
   UnicodeString & Name, bool & /*Action*/)
 {
 {
-  if (CompareFileName(Name, ExpandEnvironmentVariables(FBeforeDialogPath)))
+  if (IsPathToSameFile(Name, ExpandEnvironmentVariables(FBeforeDialogPath)))
   {
   {
     Name = FBeforeDialogPath;
     Name = FBeforeDialogPath;
   }
   }

+ 1 - 1
source/windows/GUIConfiguration.cpp

@@ -738,7 +738,7 @@ void __fastcall TGUIConfiguration::LoadData(THierarchicalStorage * Storage)
   // it should be called only for custom users path, let's expect that the user
   // it should be called only for custom users path, let's expect that the user
   // can take care of it.
   // can take care of it.
   if ((FPuttyPath.SubString(1, 1) != L"\"") &&
   if ((FPuttyPath.SubString(1, 1) != L"\"") &&
-      (CompareFileName(ExpandEnvironmentVariables(FPuttyPath), FDefaultPuttyPathOnly) ||
+      (IsPathToSameFile(ExpandEnvironmentVariables(FPuttyPath), FDefaultPuttyPathOnly) ||
        FileExists(ApiPath(ExpandEnvironmentVariables(FPuttyPath)))))
        FileExists(ApiPath(ExpandEnvironmentVariables(FPuttyPath)))))
   {
   {
     FPuttyPath = FormatCommand(FPuttyPath, L"");
     FPuttyPath = FormatCommand(FPuttyPath, L"");

+ 1 - 1
source/windows/Setup.cpp

@@ -1913,7 +1913,7 @@ static bool __fastcall DoIsInstalled(HKEY RootKey)
     UnicodeString ExePath = ExcludeTrailingBackslash(ExtractFilePath(Application->ExeName));
     UnicodeString ExePath = ExcludeTrailingBackslash(ExtractFilePath(Application->ExeName));
     Result =
     Result =
       !InstallPath.IsEmpty() &&
       !InstallPath.IsEmpty() &&
-      CompareFileName(ExePath, InstallPath);
+      IsPathToSameFile(ExePath, InstallPath);
   }
   }
   return Result;
   return Result;
 }
 }

+ 1 - 1
source/windows/Tools.cpp

@@ -827,7 +827,7 @@ void __fastcall BrowseForExecutableT(T * Control, UnicodeString Title,
       try
       try
       {
       {
         // preserve unexpanded file, if the destination has not changed actually
         // preserve unexpanded file, if the destination has not changed actually
-        if (!CompareFileName(ExpandedProgram, FileDialog->FileName))
+        if (!IsPathToSameFile(ExpandedProgram, FileDialog->FileName))
         {
         {
           Program = FileDialog->FileName;
           Program = FileDialog->FileName;
           if (Escape)
           if (Escape)

+ 2 - 2
source/windows/WinConfiguration.cpp

@@ -1301,7 +1301,7 @@ UnicodeString __fastcall TWinConfiguration::GetExtensionId(const UnicodeString &
     std::unique_ptr<TStrings> ExtensionsPaths(GetExtensionsPaths());
     std::unique_ptr<TStrings> ExtensionsPaths(GetExtensionsPaths());
     for (int Index = 0; Index < ExtensionsPaths->Count; Index++)
     for (int Index = 0; Index < ExtensionsPaths->Count; Index++)
     {
     {
-      if (CompareFileName(Path, ExtensionsPaths->ValueFromIndex[Index]))
+      if (IsPathToSameFile(Path, ExtensionsPaths->ValueFromIndex[Index]))
       {
       {
         return IncludeTrailingBackslash(ExtensionsPaths->Names[Index]) + NameId;
         return IncludeTrailingBackslash(ExtensionsPaths->Names[Index]) + NameId;
       }
       }
@@ -3596,7 +3596,7 @@ int TCustomCommandList::FindIndexByFileName(const UnicodeString & FileName) cons
 {
 {
   for (int Index = 0; Index < FCommands->Count; Index++)
   for (int Index = 0; Index < FCommands->Count; Index++)
   {
   {
-    if (CompareFileName(Commands[Index]->FileName, FileName))
+    if (IsPathToSameFile(Commands[Index]->FileName, FileName))
     {
     {
       return Index;
       return Index;
     }
     }