loot / libloot

A C++ library for accessing LOOT's metadata and sorting functionality.
GNU General Public License v3.0
32 stars 11 forks source link

Consider introducing a new API type to represent case-insensitive filenames #69

Closed Ortham closed 4 years ago

Ortham commented 4 years ago

LOOT has to perform some case-insensitive string comparisons when working with filenames that may not correspond to files that actually exist, but it's not obvious when a string is treated case-insensitively. Introducing a new wrapper type could help with that.

The wrapper type would look something like:

class Filename {
public:
  explicit Filename();
  explicit Filename(const std::string& filename);

  std::string ToString() const; // Or overload operator<< for ostream, or implement an explicit cast operator.
private:
  std::string filename_;
};

// Also implement comparison operators using CompareFilename and specialise 
// std::hash using NormalizeFilename.

Things that would use this new Filename class:

Ortham commented 4 years ago

Done in 15d98c9c20ac4000e11fb992a6e9d84de3da344b and 062ab24139032806350537a42005d14e46944838.