Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1.  
  2. #ifndef __filescanner_h__
  3. #define __filescanner_h__
  4.  
  5. #ifdef WIN32
  6. #include <io.h>
  7. #include <direct.h>
  8. #define DIRSEP "\\"
  9. #endif
  10.  
  11. #include <sys/stat.h>
  12.  
  13. #ifdef HAVE_CONFIG_H
  14. #include "config.h"
  15. #endif
  16. #ifdef HAVE_DIRENT_H
  17. #define _GCC_BUILD_
  18. #include <dirent.h>
  19. #define DIRSEP "/"
  20. #endif //HAVE_DIRENT_H
  21.  
  22. #include <string.h>
  23. #include "lispassert.h"
  24.  
  25. class CFileNode
  26. {
  27. public:
  28.   inline CFileNode() : iIsDir(0),iName(""),iDir("") {};
  29.   inline void Set(int aIsDir,char* aName)
  30.   {
  31.     iIsDir = aIsDir;
  32.     iName  = aName;
  33.     strcpy(iFullName,iDir);
  34.     if (strlen(iDir))
  35.       strcat(iFullName,DIRSEP);
  36.     strcat(iFullName,aName);
  37.   }
  38.   inline int IsDirectory() {return iIsDir;};
  39.   inline char* FullName() {return iFullName;};
  40.   inline void SetRoot(char* aDir) {iDir=aDir;};
  41. private:
  42.   int iIsDir;
  43.   char *iName;
  44.   char iFullName[500];
  45.   char* iDir;
  46. };
  47.  
  48. class CFileScanner
  49. {
  50. public:
  51.   CFileScanner();
  52.   ~CFileScanner();
  53.   CFileNode* First(char* base,char* dir);
  54.   CFileNode* Next();
  55. private:
  56.   CFileScanner(const CFileScanner& aFileScanner)
  57.     : iCurNode()
  58. #ifdef _GCC_BUILD_
  59.   ,dp(NULL),entry(NULL),statbuf()
  60. #endif
  61.   {
  62.     // copy constructor not written yet, hence the assert
  63.     LISPASSERT(0);
  64.   }
  65.   CFileScanner& operator=(const CFileScanner& aFileScanner)
  66.   {
  67.     // copy constructor not written yet, hence the assert
  68.     LISPASSERT(0);
  69.     return *this;
  70.   }
  71. private:
  72.   CFileNode iCurNode;
  73.  
  74.   char fulldir[500];
  75.  
  76. #ifdef _GCC_BUILD_
  77.   DIR *dp;
  78.   struct dirent* entry;
  79.   struct stat statbuf;
  80. #endif
  81.  
  82. #ifdef WIN32
  83.   long handle;
  84.   struct _finddata_t info;
  85.   int first;
  86. #endif
  87. };
  88.  
  89. #endif // __scanfiles_h__
  90.