Explorar o código

Improved File class

- implemented TODO regarding normalizing foreign file
path for "equals" operator and "not equals" operator
Patrick %!s(int64=4) %!d(string=hai) anos
pai
achega
673cd13ecd
Modificáronse 1 ficheiros con 4 adicións e 3 borrados
  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()