Procházet zdrojové kódy

Improved File class

- implemented TODO regarding normalizing foreign file
path for "equals" operator and "not equals" operator
Patrick před 4 roky
rodič
revize
673cd13ecd
1 změnil soubory, kde provedl 4 přidání a 3 odebrání
  1. 4 3
      source/io/File.cpp

+ 4 - 3
source/io/File.cpp

@@ -26,15 +26,16 @@ absoluteFilePath(ls_std::File::_normalizePath(std::move(_absoluteFilePath)))
 {}
 
 // TODO: also compare executable, readable, writable flag
-// TODO: normalize foreign file path for comparison
 bool ls_std::File::operator==(File &_file)
 {
-  return this->absoluteFilePath == _file.getAbsoluteFilePath();
+  std::string normalizedForeignFilePath = ls_std::File::_normalizePath(_file.getAbsoluteFilePath());
+  return this->absoluteFilePath == normalizedForeignFilePath;
 }
 
 bool ls_std::File::operator!=(File &_file)
 {
-  return this->absoluteFilePath != _file.getAbsoluteFilePath();
+  std::string normalizedForeignFilePath = ls_std::File::_normalizePath(_file.getAbsoluteFilePath());
+  return this->absoluteFilePath != normalizedForeignFilePath;
 }
 
 bool ls_std::File::canExecute()