You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

104 lines
2.8 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * Turbo Vision - Version 2.0
  3. *
  4. * Copyright (c) 1994 by Borland International
  5. * All Rights Reserved.
  6. *
  7. Modified by Robert H�hne to be used for RHIDE.
  8. *
  9. *
  10. */
  11. #if defined( Uses_TFileCollection ) && !defined( __TFileCollection )
  12. #define __TFileCollection
  13. class TSearchRec;
  14. const unsigned fcolAlphabetical=0, fcolDirsFirst=1, fcolDirsLast=2,
  15. fcolTypeMask=0x1F;
  16. const unsigned fcolCaseInsensitive=0x20, fcolCaseSensitive=0, fcolCaseBit=5;
  17. const unsigned fcolParentLast=0x40, fcolParentFirst=0, fcolParentBit=6;
  18. const unsigned fcolDotsLast=0x80, fcolDotsFirst=0, fcolDotsBit=7;
  19. const unsigned fcolHideEndTilde=0x100; // *~
  20. const unsigned fcolHideEndBkp =0x200; // *.bkp
  21. const unsigned fcolHideStartDot=0x400; // .*
  22. const unsigned fcolHideBit=8, fcolHideMask=0xF00;
  23. // Avoid replacing free by MSS's macro
  24. #include <tv/no_mss.h>
  25. class TFileCollection: public TSortedCollection
  26. {
  27. public:
  28. TFileCollection( ccIndex aLimit, ccIndex aDelta) :
  29. TSortedCollection( aLimit, aDelta ) { duplicates=True; }
  30. TSearchRec *at( ccIndex index )
  31. { return (TSearchRec *)TSortedCollection::at( index ); }
  32. void remove( TSearchRec *item )
  33. { TSortedCollection::remove( item ); }
  34. void free( TSearchRec *item )
  35. { TSortedCollection::free( item ); }
  36. void atPut( ccIndex index, TSearchRec *item )
  37. { TSortedCollection::atPut( index, item ); }
  38. TSearchRec *firstThat( ccTestFunc Test, void *arg );
  39. TSearchRec *lastThat( ccTestFunc Test, void *arg );
  40. static unsigned sortOptions;
  41. private:
  42. virtual void freeItem( void *item )
  43. { delete (TSearchRec *)item; }
  44. virtual int compare( void *key1, void *key2 );
  45. #if !defined( NO_STREAM )
  46. virtual const char *streamableName() const
  47. { return name; }
  48. virtual void *readItem( ipstream& );
  49. virtual void writeItem( void *, opstream& );
  50. protected:
  51. TFileCollection( StreamableInit ) : TSortedCollection ( streamableInit ) {}
  52. public:
  53. static const char * const name;
  54. static TStreamable *build();
  55. #endif // NO_STREAM
  56. };
  57. #include <tv/yes_mss.h>
  58. #if !defined( NO_STREAM )
  59. inline ipstream& operator >> ( ipstream& is, TFileCollection& cl )
  60. { return is >> (TStreamable&)cl; }
  61. inline ipstream& operator >> ( ipstream& is, TFileCollection*& cl )
  62. { return is >> (void *&)cl; }
  63. inline opstream& operator << ( opstream& os, TFileCollection& cl )
  64. { return os << (TStreamable&)cl; }
  65. inline opstream& operator << ( opstream& os, TFileCollection* cl )
  66. { return os << (TStreamable *)cl; }
  67. #endif // NO_STREAM
  68. inline TSearchRec *TFileCollection::firstThat( ccTestFunc func, void *arg )
  69. {
  70. return (TSearchRec *)TSortedCollection::firstThat( ccTestFunc(func), arg );
  71. }
  72. inline TSearchRec *TFileCollection::lastThat( ccTestFunc func, void *arg )
  73. {
  74. return (TSearchRec *)TSortedCollection::lastThat( ccTestFunc(func), arg );
  75. }
  76. #endif // Uses_TFileCollection