aboutsummaryrefslogtreecommitdiff
path: root/src/functionfiles.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/functionfiles.cpp')
-rw-r--r--src/functionfiles.cpp64
1 files changed, 32 insertions, 32 deletions
diff --git a/src/functionfiles.cpp b/src/functionfiles.cpp
index cd5b122..051ee3a 100644
--- a/src/functionfiles.cpp
+++ b/src/functionfiles.cpp
@@ -7,7 +7,7 @@
7 7
8#include <bu/plugger.h> 8#include <bu/plugger.h>
9PluginInterface3( pluginFunctionFiles, files, FunctionFiles, Function, 9PluginInterface3( pluginFunctionFiles, files, FunctionFiles, Function,
10 "Mike Buland", 0, 1 ); 10 "Mike Buland", 0, 1 );
11 11
12FunctionFiles::FunctionFiles() 12FunctionFiles::FunctionFiles()
13{ 13{
@@ -19,47 +19,47 @@ FunctionFiles::~FunctionFiles()
19 19
20Bu::String FunctionFiles::getName() const 20Bu::String FunctionFiles::getName() const
21{ 21{
22 return "files"; 22 return "files";
23} 23}
24 24
25Variable FunctionFiles::call( Variable &/*input*/, VarList lParams ) 25Variable FunctionFiles::call( Variable &/*input*/, VarList lParams )
26{ 26{
27 glob_t globbuf; 27 glob_t globbuf;
28 28
29 int flags = 0; 29 int flags = 0;
30 30
31 for( VarList::const_iterator i = lParams.begin(); i; i++ ) 31 for( VarList::const_iterator i = lParams.begin(); i; i++ )
32 { 32 {
33 switch( (*i).getType() ) 33 switch( (*i).getType() )
34 { 34 {
35 case Variable::typeString: 35 case Variable::typeString:
36 glob( (*i).getString().getStr(), flags, NULL, &globbuf ); 36 glob( (*i).getString().getStr(), flags, NULL, &globbuf );
37 flags |= GLOB_APPEND; 37 flags |= GLOB_APPEND;
38 break; 38 break;
39 39
40 case Variable::typeList: 40 case Variable::typeList:
41 throw Bu::ExceptionBase("Lists not supported in glob yet."); 41 throw Bu::ExceptionBase("Lists not supported in glob yet.");
42 break; 42 break;
43 43
44 default: 44 default:
45 throw Bu::ExceptionBase( 45 throw Bu::ExceptionBase(
46 "Cannot use a non-string or non-list as a parameter to glob" 46 "Cannot use a non-string or non-list as a parameter to glob"
47 ); 47 );
48 break; 48 break;
49 } 49 }
50 } 50 }
51 51
52 Variable vRet( Variable::typeList ); 52 Variable vRet( Variable::typeList );
53 struct stat s; 53 struct stat s;
54 for( size_t j = 0; j < globbuf.gl_pathc; j++ ) 54 for( size_t j = 0; j < globbuf.gl_pathc; j++ )
55 { 55 {
56 stat( globbuf.gl_pathv[j], &s ); 56 stat( globbuf.gl_pathv[j], &s );
57 if( S_ISREG( s.st_mode ) ) 57 if( S_ISREG( s.st_mode ) )
58 vRet.append( globbuf.gl_pathv[j] ); 58 vRet.append( globbuf.gl_pathv[j] );
59 } 59 }
60 60
61 globfree( &globbuf ); 61 globfree( &globbuf );
62 62
63 return vRet; 63 return vRet;
64} 64}
65 65