aboutsummaryrefslogtreecommitdiff
path: root/src/functionfilesin.cpp
blob: e3d8e920c03cdaa7221e9f538f3b117c340a29b2 (plain)
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
#include <dirent.h>

#include "functionfilesin.h"
#include "plugger.h"
#include "build.h"

PluginInterface2(filesIn, FunctionFilesIn, Function, "Mike Buland", 0, 1 );

FunctionFilesIn::FunctionFilesIn()
{
}

FunctionFilesIn::~FunctionFilesIn()
{
}

void FunctionFilesIn::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 = lParams.front() + "/";

	while( (e = readdir( d )) )
	{
		if( e->d_type == DT_REG )
		{
			lOutput.push_back( prefix + e->d_name );
		}
	}

	closedir( d );
}

Function *FunctionFilesIn::duplicate( Build &bld, const std::string &cont, VarMap *mExtra )
{
	Function *pRet = new FunctionFilesIn();
	pRet->copyData( this, bld, cont, mExtra );
	return pRet;
}