MODULE = IO PACKAGE = IO::File PREFIX = f
-OutputStream
+SV *
new_tmpfile(packname = "IO::File")
char * packname
+ PREINIT:
+ OutputStream fp;
+ GV *gv;
CODE:
#ifdef PerlIO
- RETVAL = PerlIO_tmpfile();
+ fp = PerlIO_tmpfile();
#else
- RETVAL = tmpfile();
+ fp = tmpfile();
#endif
- OUTPUT:
- RETVAL
+ gv = (GV*)SvREFCNT_inc(newGVgen(packname));
+ hv_delete(GvSTASH(gv), GvNAME(gv), GvNAMELEN(gv), G_DISCARD);
+ if (do_open(gv, "+>&", 3, FALSE, 0, 0, fp)) {
+ ST(0) = sv_2mortal(newRV_noinc((SV*)gv));
+ sv_bless(ST(0), gv_stashpv(packname, TRUE));
+ }
+ else {
+ ST(0) = &sv_undef;
+ SvREFCNT_dec(gv);
+ }
MODULE = IO PACKAGE = IO::Handle PREFIX = f