diff options
author | Mike Buland <eichlan@xagasoft.com> | 2011-06-03 07:18:23 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2011-06-03 07:18:23 +0000 |
commit | f16f239688b632fc54684c3e0e1430fd89a67db5 (patch) | |
tree | 6a6d4f3b5d5f4974af4c3cc47c7892e46c5ef201 /src/functionopen.cpp | |
parent | 4f1e5849d4a48eb674d81164ba4baba4ad51a89f (diff) | |
download | build-f16f239688b632fc54684c3e0e1430fd89a67db5.tar.gz build-f16f239688b632fc54684c3e0e1430fd89a67db5.tar.bz2 build-f16f239688b632fc54684c3e0e1430fd89a67db5.tar.xz build-f16f239688b632fc54684c3e0e1430fd89a67db5.zip |
I added basic support for "opaque" type variables. I think there's one more
tweak to it that I would like to make, but it's fine for now. I also added
open, close, read, and write functions. They work just fine, but I'll also add
a readLine function, and maybe even a readToken function later.
Diffstat (limited to '')
-rw-r--r-- | src/functionopen.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/functionopen.cpp b/src/functionopen.cpp new file mode 100644 index 0000000..4026a8c --- /dev/null +++ b/src/functionopen.cpp | |||
@@ -0,0 +1,42 @@ | |||
1 | #include "functionopen.h" | ||
2 | #include "filemgr.h" | ||
3 | |||
4 | #include <bu/plugger.h> | ||
5 | PluginInterface3( pluginFunctionOpen, open, FunctionOpen, Function, | ||
6 | "Mike Buland", 0, 1 ); | ||
7 | |||
8 | FunctionOpen::FunctionOpen() | ||
9 | { | ||
10 | } | ||
11 | |||
12 | FunctionOpen::~FunctionOpen() | ||
13 | { | ||
14 | } | ||
15 | |||
16 | Bu::String FunctionOpen::getName() const | ||
17 | { | ||
18 | return "open"; | ||
19 | } | ||
20 | |||
21 | Variable FunctionOpen::call( Variable &input, VarList lParams ) | ||
22 | { | ||
23 | if( lParams.getSize() != 2 ) | ||
24 | { | ||
25 | throw Bu::ExceptionBase( | ||
26 | "open takes two parameters, filename and mode." | ||
27 | ); | ||
28 | } | ||
29 | Bu::String sMode = lParams.last().toString().toLower(); | ||
30 | int iMode = Bu::File::Create; | ||
31 | if( sMode.find('w') ) | ||
32 | iMode |= Bu::File::Write; | ||
33 | if( sMode.find('r') ) | ||
34 | iMode |= Bu::File::Read; | ||
35 | Variable vRet( | ||
36 | (void *)FileMgr::getInstance().open( | ||
37 | lParams.first().toString(), iMode | ||
38 | ) | ||
39 | ); | ||
40 | return vRet; | ||
41 | } | ||
42 | |||