diff options
Diffstat (limited to '')
-rw-r--r-- | src/functionread.cpp | 40 |
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> | ||
5 | PluginInterface3( pluginFunctionRead, read, FunctionRead, Function, | ||
6 | "Mike Buland", 0, 1 ); | ||
7 | |||
8 | FunctionRead::FunctionRead() | ||
9 | { | ||
10 | } | ||
11 | |||
12 | FunctionRead::~FunctionRead() | ||
13 | { | ||
14 | } | ||
15 | |||
16 | Bu::String FunctionRead::getName() const | ||
17 | { | ||
18 | return "read"; | ||
19 | } | ||
20 | |||
21 | Variable 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 | |||