[seed] Add os.open and os.close
- From: Robert Carr <racarr src gnome org>
- To: svn-commits-list gnome org
- Subject: [seed] Add os.open and os.close
- Date: Tue, 14 Apr 2009 21:40:25 -0400 (EDT)
commit be051da8de46f0ed206b99159c55fd0da25548ab
Author: Robert Carr <racarr mireia (none)>
Date: Tue Apr 14 21:40:12 2009 -0400
Add os.open and os.close
---
modules/os/os.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 48 insertions(+), 1 deletions(-)
diff --git a/modules/os/os.c b/modules/os/os.c
index 0979d6b..62bf411 100644
--- a/modules/os/os.c
+++ b/modules/os/os.c
@@ -518,6 +518,51 @@ seed_os_unsetenv (SeedContext ctx,
return seed_value_from_int (ctx, ret, exception);
}
+SeedValue
+seed_os_open (SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ size_t argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
+{
+ gchar *path;
+ gint flags, ret;
+
+ if (argument_count != 2)
+ {
+ EXPECTED_EXCEPTION("os.open", "2 arguments");
+ }
+
+ path = seed_value_to_string (ctx, arguments[0], exception);
+ flags = seed_value_to_int (ctx, arguments[1], exception);
+
+ ret = open (path, flags);
+ g_free (path);
+
+ return seed_value_from_int (ctx, ret, exception);
+}
+
+SeedValue
+seed_os_close (SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ size_t argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
+{
+ gint arg;
+
+ if (argument_count != 1)
+ {
+ EXPECTED_EXCEPTION("os.open", "2 arguments");
+ }
+
+ arg = seed_value_to_int (ctx, arguments[0], exception);
+
+ return seed_value_from_int (ctx, close (arg), exception);
+}
+
seed_static_function os_funcs[] = {
{"chdir", seed_os_chdir, 0},
{"fchdir", seed_os_fchdir, 0},
@@ -541,7 +586,9 @@ seed_static_function os_funcs[] = {
{"strerror", seed_os_strerror, 0},
{"umask", seed_os_umask, 0},
{"uname", seed_os_uname, 0},
- {"unsetenv", seed_os_unsetenv, 0}
+ {"unsetenv", seed_os_unsetenv, 0},
+ {"open", seed_os_open, 0},
+ {"close", seed_os_close, 0}
};
#define OS_DEFINE_ENUM(name, value) \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]