[svn:parrot] r39851 - branches/io_cleanups/src/io

whiteknight at svn.parrot.org whiteknight at svn.parrot.org
Tue Jun 30 22:39:35 UTC 2009


Author: whiteknight
Date: Tue Jun 30 22:39:35 2009
New Revision: 39851
URL: https://trac.parrot.org/parrot/changeset/39851

Log:
[io_cleanups] add basic preliminary logic to support for Pipes to Parrot_io_open. Probably doesn't work as-is

Modified:
   branches/io_cleanups/src/io/api.c

Modified: branches/io_cleanups/src/io/api.c
==============================================================================
--- branches/io_cleanups/src/io/api.c	Tue Jun 30 22:20:45 2009	(r39850)
+++ branches/io_cleanups/src/io/api.c	Tue Jun 30 22:39:35 2009	(r39851)
@@ -236,15 +236,18 @@
 {
     ASSERT_ARGS(Parrot_io_open)
     PMC *new_filehandle, *filehandle;
-    INTVAL flags;
+    INTVAL flags = Parrot_io_parse_open_flags(interp, mode);
     if (PMC_IS_NULL(pmc)) {
-        new_filehandle = pmc_new(interp,
-            Parrot_get_ctx_HLL_type(interp, enum_class_FileHandle));
+        if (flags & PIO_F_PIPE)
+            new_filehandle = pmc_new(interp,
+                Parrot_get_ctx_HLL_type(interp, enum_class_PipeHandle));
+        else
+            new_filehandle = pmc_new(interp,
+                Parrot_get_ctx_HLL_type(interp, enum_class_FileHandle));
     }
     else
         new_filehandle = pmc;
 
-    flags = Parrot_io_parse_open_flags(interp, mode);
     if (new_filehandle->vtable->base_type == enum_class_FileHandle) {
         filehandle = PIO_OPEN(interp, new_filehandle, path, flags);
         if (PMC_IS_NULL(filehandle))
@@ -255,6 +258,12 @@
         SETATTR_FileHandle_mode(interp, new_filehandle, mode);
         Parrot_io_setbuf(interp, filehandle, PIO_UNBOUND);
     }
+    else if (new_filehandle->vtable->base_type == enum_class_PipeHandle) {
+        filehandle = PIO_OPEN_PIPE(interp, new_filehandle, path, flags);
+        if (PMC_IS_NULL(filehandle))
+            Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_PIO_ERROR,
+                "Unable to open pipe to command '%S'", path);
+    }
     else if (new_filehandle->vtable->base_type == enum_class_StringHandle) {
         SETATTR_StringHandle_flags(interp, pmc, flags);
         filehandle = pmc;


More information about the parrot-commits mailing list