Changeset 1544


Ignore:
Timestamp:
2000-09-13T21:34:31+12:00 (24 years ago)
Author:
cs025
Message:

Made comparison in FilePath case-insensitive.

Location:
trunk/gsinstaller
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsinstaller/FilePath.cpp

    r1541 r1544  
    195195}
    196196
    197 bool FilePath::equals(FilePath &other)
    198 {
    199   if (this->path.compare(other.path) == 0)
    200     {
    201       return true;
    202     }
    203 
    204   return false;
    205 }
    206 
    207 bool FilePath::equals(const char *other)
    208 {
    209   if (strcmp(this->path.c_str(), other) == 0)
    210     {
    211       return true;
    212     }
    213 
    214   return false;
     197int FilePath::compare(const FilePath &other) const
     198{ string::const_iterator thisc = this->path.begin();
     199    string::const_iterator otherc = other.path.begin();
     200
     201  while (thisc != this->path.end() && otherc != other.path.end())
     202  { if (toupper(*thisc) != toupper(*otherc))
     203    { return (toupper(*thisc) - toupper(*otherc));
     204    }
     205    thisc ++;
     206    otherc ++;
     207  }
     208
     209  return this->path.size() - other.path.size();
     210}
     211
     212int FilePath::compare(const char *other) const
     213{
     214  return strcmpi(this->path.c_str(), other);
    215215}
    216216
     
    357357      parent = this->parent();
    358358
    359       if (parent->equals(thisFile.cString()))
     359      if (*parent == thisFile)
    360360    {
    361361      delete parent;
  • trunk/gsinstaller/FilePath.h

    r1541 r1544  
    1111#endif
    1212#endif
     13
     14#include <string.h>
    1315
    1416class FilePath
     
    2527  FilePath(int nPaths, ...);
    2628  FilePath(FilePath &path, string subPath);
    27   bool equals(FilePath &path);
    28   bool equals(const char *path);
    2929  bool isRoot();
    3030  bool isEmpty();
     31  int compare(const FilePath &other) const;
     32  int compare(const char *other) const;
    3133  FilePath *append(FilePath &path);
    3234  FilePath *append(char *path);
     
    3840  const char *cString();
    3941  string pathString();
    40   bool operator==(const FilePath &b) const { return this->path == b.path; }
    41   bool operator!=(const FilePath &b) const { return this->path != b.path; }
    42   bool operator<(const FilePath &b) const { return this->path < b.path; }
     42  bool operator==(const FilePath &b) const { return this->compare(b) == 0; }
     43  bool operator!=(const FilePath &b) const { return this->compare(b) != 0; }
     44  bool operator<(const FilePath &b) const { return this->compare(b) < 0; }
    4345};
    4446#endif
Note: See TracChangeset for help on using the changeset viewer.