FilenameField.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #include "FilenameField.h"
  2. #include "nde.h"
  3. /*
  4. Mac OS X implementation of FilenameField
  5. only the equals operator will be case-sensitive. substring search, ends, starts, etc. will be case-insensitive,
  6. to make things like "filename ends .mp3" easier
  7. TODO: it'd be massive overhead, but it'd be more correct to check if the file system is actually case sensitive (for the path being searched)
  8. */
  9. //---------------------------------------------------------------------------
  10. FilenameField::FilenameField(CFStringRef Str) : StringField(Str)
  11. {
  12. Type = FIELD_FILENAME;
  13. }
  14. //---------------------------------------------------------------------------
  15. FilenameField::FilenameField()
  16. {
  17. Type = FIELD_FILENAME;
  18. }
  19. //---------------------------------------------------------------------------
  20. int FilenameField::Compare(Field *Entry)
  21. {
  22. if (!Entry) return -1;
  23. if (Entry->GetType() != GetType()) return 0;
  24. CFStringRef compareString = ((StringField*)Entry)->GetString();
  25. if (!String && !compareString) return 0;
  26. if (!String && compareString) return 1;
  27. if (!compareString) return -1;
  28. return CFStringCompare(String, compareString, 0);
  29. }
  30. Field *FilenameField::Clone(Table *pTable)
  31. {
  32. FilenameField *clone = new FilenameField(String);
  33. clone->Pos = FIELD_CLONE;
  34. clone->ID = ID;
  35. clone->MaxSizeOnDisk = GetDataSize();
  36. return clone;
  37. }