ffsco.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. //#include "ffsco.h"
  2. //////////////////////////////////////////////////////////////////////
  3. // ffsco.h: interface for the helper_coffs::ffsco class.
  4. //
  5. //////////////////////////////////////////////////////////////////////
  6. /*
  7. * Copyright 2004, ??? (www.???.com). All rights reserved.
  8. * Copyright 1990-2004, ???.
  9. *
  10. * See the COPYING file for the terms of usage and distribution.
  11. */
  12. //////////////////////////////////////////////////////////////////////
  13. // ...
  14. // create@2004-03-17
  15. // by ???
  16. //////////////////////////////////////////////////////////////////////
  17. #ifndef __FFSCO__
  18. //#if !defined(__FFSCO__)
  19. #define __FFSCO__
  20. #ifndef WIN32
  21. #error now only for WIN32(platform).
  22. #endif
  23. //#include <iostream>
  24. //#include <algorithm>
  25. #include <string>
  26. #include <vector>
  27. #include <sstream>
  28. using namespace std;
  29. #pragma warning(disable:4786)
  30. namespace helper_coffs {
  31. const int max_limit = 0x100000; //--1048576
  32. const int def_limit = 0x10000; //--65536
  33. const char c_pathSeparator = '\\';
  34. const string s_pathSeparator = "\\";
  35. //--find files collection
  36. class ffsco
  37. {
  38. public:
  39. typedef vector<string> typeT;
  40. virtual int match(string fext_, string file_); //--文件匹配检测
  41. public:
  42. void test(); //--example
  43. int find(string path_, string fext_ = "");
  44. public:
  45. string get(int i = 0) { return _co.at(i); }
  46. int count() { return _co_dir.size() + _co_file.size(); }
  47. //int count() { return _co.size(); }
  48. typeT co() { return _co; }
  49. typeT co_dir() { return _co_dir; }
  50. typeT co_file() { return _co_file; }
  51. public:
  52. int limit() { return _limit; }
  53. //void limit(int limit_) { _limit = limit_; }
  54. void limit(int limit_); //--设置结果文件数目上限
  55. public:
  56. int dirs() { return _dirs; } //get
  57. void dirs(int dirs) { _dirs = dirs; } //--set
  58. int dir(string s); //--判断s是否为目录
  59. private:
  60. int _limit; //--limit
  61. int _dirs; //--dirs-是否查找子目录(默认0-不查找)
  62. typeT _co_file;
  63. typeT _co_dir;
  64. typeT _co;
  65. public:
  66. ffsco();
  67. virtual ~ffsco();
  68. private:
  69. inline int _limit_() { return count() == limit(); } //--limit test
  70. inline string _uppercase_(string s); //--转换s到大写字母
  71. };
  72. }; //--namespace helper_coffs
  73. #endif //--__FFSCO__