ffsco.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. public:
  41. ffsco();
  42. virtual ~ffsco();
  43. virtual int match(string fext_, string file_); //--文件匹配检测
  44. void test(); //--example
  45. int find(string path_, string fext_ = "");
  46. string get(int i = 0) { return _co.at(i); }
  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. int limit() { return _limit; }
  52. void limit( int limit_); //--设置结果文件数目上限
  53. int dirs() { return _dirs; } //get
  54. void dirs( int dirs) { _dirs = dirs; } //--set 1:查找子目录; 0:不查找子目录
  55. int dir( string& s); //--判断s是否为目录
  56. void Clear();
  57. private:
  58. inline string _uppercase_( string& s); //--转换s到大写字母
  59. void findex( string path_, string fext_);
  60. private:
  61. int _limit; //--limit
  62. int _dirs; //--dirs-是否查找子目录(默认0-不查找)
  63. typeT _co_file;
  64. typeT _co_dir;
  65. typeT _co;
  66. };
  67. }; //--namespace helper_coffs
  68. #endif //--__FFSCO__