Structural deformable models
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
FFind Class Reference

#include <FFind.h>

Collaboration diagram for FFind:
Collaboration graph
[legend]

Public Member Functions

 FFind (const string &pattern)
 
void setPattern (const string &pattern)
 
template<class T >
int findFiles (const std::string &fmask, T iter)
 
 FFind ()
 
 FFind (const std::string &pattern)
 
void setPattern (const std::string &pattern)
 
template<class T >
int find (const std::string &fmask, T iter)
 

Static Public Member Functions

template<class T >
static int findFiles (const std::string &fmask, T iter)
 

Protected Attributes

string m_Pattern
 
string m_Dir
 
std::string m_Pattern
 
std::string m_Dir
 

Detailed Description

Definition at line 16 of file ffind.cpp.

Constructor & Destructor Documentation

FFind::FFind ( const string &  pattern)
inline

Definition at line 19 of file ffind.cpp.

19 { setPattern(pattern); }
void setPattern(const string &pattern)
Definition: ffind.cpp:20
FFind::FFind ( )
inline

Definition at line 18 of file FFind.h.

18 {}
FFind::FFind ( const std::string &  pattern)
inline

Definition at line 19 of file FFind.h.

References setPattern().

19 { setPattern(pattern); }
void setPattern(const string &pattern)
Definition: ffind.cpp:20

Member Function Documentation

template<class T >
int FFind::find ( const std::string &  fmask,
iter 
)
inline

Definition at line 35 of file FFind.h.

References __fixed_fnmatch(), __set_fnmatchpattern(), findFiles(), m_Dir, m_Pattern, and setPattern().

Referenced by findFiles().

35  {
36  setPattern(fmask);
37  int n,nn;
38 #ifdef LINUX
39  struct dirent **namelist;
40  // THIS IS NOT THREADSAFE :-(
42  nn = n = scandir(m_Dir.c_str(), &namelist, __fixed_fnmatch, alphasort);
43  if (n < 0)
44  return 0;
45  else {
46  while(n--) {
47  *iter++ = namelist[n]->d_name;
48  free(namelist[n]);
49  }
50  free(namelist);
51  }
52 #else
53  nn = n = ::findFiles(fmask, iter);
54 #endif
55  return nn;
56  }
int findFiles(const std::string &fmask, T iter)
Definition: ffind.cpp:33
const string & __set_fnmatchpattern(const string &pattern)
Definition: utils.cpp:15
string m_Pattern
Definition: ffind.cpp:53
string m_Dir
Definition: ffind.cpp:54
void setPattern(const string &pattern)
Definition: ffind.cpp:20
int __fixed_fnmatch(const struct dirent *dent)
Definition: ffind.cpp:12
template<class T >
int FFind::findFiles ( const std::string &  fmask,
iter 
)
inline

Definition at line 33 of file ffind.cpp.

References __fixed_fnmatch(), __fnmatchpattern, and perror().

Referenced by find(), and MStructure::getRefModelIDs().

33  {
34  setPattern(fmask);
35  struct dirent **namelist;
36  int n;
37  // THIS IS NOT THREADSAFE :-(
38  strncpy(__fnmatchpattern, m_Pattern.c_str(), 2047);
39  n = scandir(m_Dir.c_str(), &namelist, __fixed_fnmatch, alphasort);
40  if (n < 0)
41  perror("scandir");
42  else {
43  while(n--) {
44  *iter++ = namelist[n]->d_name;
45  free(namelist[n]);
46  }
47  free(namelist);
48  }
49 
50  }
char __fnmatchpattern[2048]
Definition: ffind.cpp:11
void perror(const char *errmsg)
Definition: ffind.cpp:57
string m_Pattern
Definition: ffind.cpp:53
string m_Dir
Definition: ffind.cpp:54
void setPattern(const string &pattern)
Definition: ffind.cpp:20
int __fixed_fnmatch(const struct dirent *dent)
Definition: ffind.cpp:12
template<class T >
static int FFind::findFiles ( const std::string &  fmask,
iter 
)
inlinestatic

Definition at line 59 of file FFind.h.

References find().

59  {
60  FFind ff;
61  return ff.find(fmask, iter);
62  }
int find(const std::string &fmask, T iter)
Definition: FFind.h:35
Definition: ffind.cpp:16
void FFind::setPattern ( const std::string &  pattern)
inline

Definition at line 20 of file FFind.h.

References m_Dir, m_Pattern, and NULL.

20  {
21  char *dname=NULL,*bname=NULL;
22 #ifdef LINUX
23  char *p1 = strdup(pattern.c_str());
24  char *p2 = strdup(pattern.c_str());
25  dname = dirname(p1);
26  bname = basename(p2);
27  m_Pattern = bname;
28  m_Dir = dname;
29  if(p1) free(p1);
30  if(p2) free(p2);
31 #endif
32  }
#define NULL
Definition: simpletypes.h:9
string m_Pattern
Definition: ffind.cpp:53
string m_Dir
Definition: ffind.cpp:54
void FFind::setPattern ( const string &  pattern)
inline

Definition at line 20 of file ffind.cpp.

References NULL.

Referenced by FFind(), and find().

20  {
21  char *dname=NULL,*bname=NULL;
22  char *p1 = strdup(pattern.c_str());
23  char *p2 = strdup(pattern.c_str());
24  dname = dirname(p1);
25  bname = basename(p2);
26  m_Pattern = bname;
27  m_Dir = dname;
28  if(p1) free(p1);
29  if(p2) free(p2);
30  }
#define NULL
Definition: simpletypes.h:9
string m_Pattern
Definition: ffind.cpp:53
string m_Dir
Definition: ffind.cpp:54

Member Data Documentation

string FFind::m_Dir
protected

Definition at line 54 of file ffind.cpp.

Referenced by find(), and setPattern().

std::string FFind::m_Dir
protected

Definition at line 66 of file FFind.h.

string FFind::m_Pattern
protected

Definition at line 53 of file ffind.cpp.

Referenced by find(), and setPattern().

std::string FFind::m_Pattern
protected

Definition at line 65 of file FFind.h.


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