1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
#include <dirent.h>
#include "functiondirectoriesin.h"
#include "plugger.h"
PluginInterface2(directoriesIn, FunctionDirectoriesIn, Function, "Mike Buland", 0, 1 );
FunctionDirectoriesIn::FunctionDirectoriesIn()
{
}
FunctionDirectoriesIn::~FunctionDirectoriesIn()
{
}
void FunctionDirectoriesIn::execute( Build *bld, const StringList &lInput, StringList &lOutput )
{
DIR *d = opendir( lParams.front().c_str() );
if( d == NULL )
throw BuildException(
"Can't open directory %s.",
lParams.front().c_str()
);
struct dirent *e;
std::string prefix;
if( lParams.size() >= 2 )
{
StringList::iterator i = lParams.begin();
i++;
prefix = *i;
}
else
{
prefix = lParams.front() + "/";
}
while( (e = readdir( d )) )
{
if( e->d_type == DT_DIR )
{
if( e->d_name[0] == '.' || e->d_name[0] == '\0' )
continue;
std::string sOut = prefix + e->d_name;
lOutput.push_back( sOut );
if( bld )
{
std::string sV = lParams.front() + "/";
sV += e->d_name;
bld->set( sOut, "fulldir", sV );
}
else
{
printf("no build access.\n");
}
}
}
closedir( d );
}
Function *FunctionDirectoriesIn::duplicate( Build &bld, const StringList *cont, VarMap *mExtra )
{
Function *pRet = new FunctionDirectoriesIn();
pRet->copyData( this, bld, cont, mExtra );
return pRet;
}
|