Mixe for Privacy and Anonymity in the Internet
Public Member Functions | Private Attributes | List of all members
CAFileSystemDirectory Class Reference

#include <CAFileSystemDirectory.hpp>

Collaboration diagram for CAFileSystemDirectory:

Public Member Functions

 CAFileSystemDirectory (UINT8 *strPath)
 
 ~CAFileSystemDirectory ()
 
SINT32 find (UINT8 *strPattern)
 
SINT32 getNextSearchResult (UINT8 *strResult, UINT32 sizeResult)
 

Private Attributes

UINT8m_strPath
 
UINT8m_strPattern
 
DIR * m_hSearch
 

Detailed Description

Definition at line 30 of file CAFileSystemDirectory.hpp.

Constructor & Destructor Documentation

◆ CAFileSystemDirectory()

CAFileSystemDirectory::CAFileSystemDirectory ( UINT8 strPath)

Definition at line 31 of file CAFileSystemDirectory.cpp.

32  {
33  m_strPath = new UINT8[strlen((char*)strPath) + 1];
34  strcpy((char*)m_strPath,(char*) strPath);
35 #ifdef _WIN32
36  m_hSearch = -1;
37 #else
38  m_hSearch = NULL;
39  m_strPattern = NULL;
40 #endif
41  }
unsigned char UINT8
Definition: basetypedefs.h:135

References m_hSearch, m_strPath, and m_strPattern.

◆ ~CAFileSystemDirectory()

CAFileSystemDirectory::~CAFileSystemDirectory ( )

Definition at line 43 of file CAFileSystemDirectory.cpp.

44  {
45 #ifdef _WIN32
46  if (m_hSearch >= 0)
47  {
48  _findclose(m_hSearch);
49  }
50 #else
51  if (m_hSearch != NULL)
52  {
53  closedir(m_hSearch);
54  }
55  delete m_strPattern;
56 #endif
57  delete m_strPath;
58  }

References m_hSearch, m_strPath, and m_strPattern.

Member Function Documentation

◆ find()

SINT32 CAFileSystemDirectory::find ( UINT8 strPattern)

Definition at line 60 of file CAFileSystemDirectory.cpp.

61  {
62 #ifdef _WIN32
63  UINT8* strSearchFor = new UINT8[strlen((char*)m_strPath) + strlen((char*)strPattern )+ 10];
64  strcpy((char*)strSearchFor, (char*)m_strPath);
65  strcat((char*)strSearchFor, (char*)strPattern);
66  m_hSearch = _findfirst( (char*)strSearchFor, &m_finddataFoundFile);
67  delete strSearchFor;
68  if (m_hSearch < 0)
69  {
70  m_hSearch = -1;
71  return E_UNKNOWN;
72  }
73  return E_SUCCESS;
74 #else
75  m_hSearch=opendir((char*)m_strPath);
76  if(m_hSearch==NULL)
77  return E_UNKNOWN;
78  m_strPattern = new UINT8[strlen((char*)strPattern) + 1];
79  strcpy((char*)m_strPattern,(char*) strPattern);
80  return E_SUCCESS;
81 #endif
82  }
const SINT32 E_SUCCESS
Definition: errorcodes.hpp:2
#define E_UNKNOWN
Definition: errorcodes.hpp:3

References E_SUCCESS, E_UNKNOWN, m_hSearch, m_strPath, and m_strPattern.

◆ getNextSearchResult()

SINT32 CAFileSystemDirectory::getNextSearchResult ( UINT8 strResult,
UINT32  sizeResult 
)

Definition at line 84 of file CAFileSystemDirectory.cpp.

85  {
86 #ifdef _WIN32
87  if (m_hSearch > 0)
88  {
89  strcpy((char*)strResult, (char*)m_strPath);
90  strcat((char*)strResult, (char*)m_finddataFoundFile.name);
91  SINT32 ret = _findnext(m_hSearch, &m_finddataFoundFile);
92  if (ret < 0)
93  {
94  _findclose(m_hSearch);
95  m_hSearch = -1;
96  }
97  return E_SUCCESS;
98  }
99  else
100  return E_UNKNOWN;
101 #else
102  if (m_hSearch !=NULL)
103  {
104  struct dirent * pEntry = NULL;
105  while ((pEntry = readdir(m_hSearch)) != NULL)
106  {
107  if (fnmatch((char*)m_strPattern, pEntry->d_name, FNM_PATHNAME) == 0)
108  {
109 
110  strcpy((char*)strResult, (char*)m_strPath);
111  strcat((char*)strResult, (char*)pEntry->d_name);
112  return E_SUCCESS;
113  }
114  }
115  closedir(m_hSearch);
116  m_hSearch = NULL;
117  return E_UNKNOWN;
118  }
119  else
120  return E_UNKNOWN;
121 #endif
122  }
signed int SINT32
Definition: basetypedefs.h:132

References E_SUCCESS, E_UNKNOWN, m_hSearch, m_strPath, and m_strPattern.

Member Data Documentation

◆ m_hSearch

DIR* CAFileSystemDirectory::m_hSearch
private

◆ m_strPath

UINT8* CAFileSystemDirectory::m_strPath
private

◆ m_strPattern

UINT8* CAFileSystemDirectory::m_strPattern
private

The documentation for this class was generated from the following files: