aboutsummaryrefslogtreecommitdiff
path: root/src/functiondirs.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/functiondirs.cpp')
-rw-r--r--src/functiondirs.cpp64
1 files changed, 32 insertions, 32 deletions
diff --git a/src/functiondirs.cpp b/src/functiondirs.cpp
index e3b88dd..8ed0442 100644
--- a/src/functiondirs.cpp
+++ b/src/functiondirs.cpp
@@ -7,7 +7,7 @@
7 7
8#include <bu/plugger.h> 8#include <bu/plugger.h>
9PluginInterface3( pluginFunctionDirs, dirs, FunctionDirs, Function, 9PluginInterface3( pluginFunctionDirs, dirs, FunctionDirs, Function,
10 "Mike Buland", 0, 1 ); 10 "Mike Buland", 0, 1 );
11 11
12FunctionDirs::FunctionDirs() 12FunctionDirs::FunctionDirs()
13{ 13{
@@ -19,47 +19,47 @@ FunctionDirs::~FunctionDirs()
19 19
20Bu::String FunctionDirs::getName() const 20Bu::String FunctionDirs::getName() const
21{ 21{
22 return "dirs"; 22 return "dirs";
23} 23}
24 24
25Variable FunctionDirs::call( Variable &/*input*/, VarList lParams ) 25Variable FunctionDirs::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_ISDIR( s.st_mode ) ) 57 if( S_ISDIR( 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