1 #include <proto/exec.h>
2 #include <proto/alib.h>
4 #include <dos/filesystem.h>
6 #include <exec/memory.h>
10 static struct IOFileSys
*CreateIOFS(ULONG type
, struct MsgPort
*port
, struct FileHandle
*fh
)
12 struct IOFileSys
*iofs
= (struct IOFileSys
*)AllocMem(sizeof(struct IOFileSys
), MEMF_PUBLIC
|MEMF_CLEAR
);
17 iofs
->IOFS
.io_Message
.mn_Node
.ln_Type
= NT_REPLYMSG
;
18 iofs
->IOFS
.io_Message
.mn_ReplyPort
= port
;
19 iofs
->IOFS
.io_Message
.mn_Length
= sizeof(struct IOFileSys
);
20 iofs
->IOFS
.io_Command
= type
;
21 iofs
->IOFS
.io_Flags
= 0;
22 iofs
->IOFS
.io_Device
= fh
->fh_Device
;
23 iofs
->IOFS
.io_Unit
= fh
->fh_Unit
;
28 static BPTR
DupFH(BPTR fh
, LONG mode
)
34 BPTR olddir
= CurrentDir(fh
);
45 struct FileHandle
*fhin
, *fhout
;
47 struct IOFileSys
*iofs
;
49 fhin
= Open("PIPEFS:__UNNAMED__", FMF_READ
|FMF_NONBLOCK
);
50 fhout
= DupFH(fhin
, FMF_WRITE
);
51 assert(fhin
!=NULL
&& fhout
!=NULL
);
52 ChangeMode(CHANGE_FH
, fhin
, FMF_READ
);
54 port
= CreatePort(NULL
, 0);
57 iofs
= CreateIOFS(FSA_WRITE
, port
, fhout
);
58 iofs
->io_Union
.io_WRITE
.io_Buffer
= "Test\n";
59 iofs
->io_Union
.io_WRITE
.io_Length
= 5;
65 iofs
= CreateIOFS(FSA_WRITE
, port
, fhout
);
66 iofs
->io_Union
.io_WRITE
.io_Buffer
= "Test\n";
67 iofs
->io_Union
.io_WRITE
.io_Length
= 5;