aboutsummaryrefslogtreecommitdiff
path: root/src/functionread.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/functionread.cpp')
-rw-r--r--src/functionread.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/functionread.cpp b/src/functionread.cpp
new file mode 100644
index 0000000..789e9e1
--- /dev/null
+++ b/src/functionread.cpp
@@ -0,0 +1,40 @@
1#include "functionread.h"
2#include "filemgr.h"
3
4#include <bu/plugger.h>
5PluginInterface3( pluginFunctionRead, read, FunctionRead, Function,
6 "Mike Buland", 0, 1 );
7
8FunctionRead::FunctionRead()
9{
10}
11
12FunctionRead::~FunctionRead()
13{
14}
15
16Bu::String FunctionRead::getName() const
17{
18 return "read";
19}
20
21Variable FunctionRead::call( Variable &input, VarList lParams )
22{
23 Variable vRet;
24 if( lParams.getSize() == 1 )
25 {
26 int iSize = lParams.first().toInt();
27 Bu::String sBuf( iSize );
28 sBuf.resize(
29 FileMgr::getInstance().get( (int)input.getOpaque() ).read(
30 sBuf.getStr(), iSize
31 )
32 );
33 vRet = sBuf;
34 return vRet;
35 }
36 throw Bu::ExceptionBase(
37 "read takes zero or one parameters."
38 );
39}
40