Amiga.org
Operating System Specific Discussions => Amiga OS => Amiga OS -- Development => Topic started by: on April 06, 2003, 10:48:59 AM
-
I guess there is no "/dev/null" on Amiga using libnix or ixemul so what do I use instead if I want to open a "null" file, that is no file at all with fopen("dev/null",method) ?
-
"fopen("Nil:",method);" should have the same effect (untested).
-
why on earth would you want to do that?
-
Redicection of stderr maybe?
-
W ? You mean creating an empty file, like "#touch file" ?
-
This is why. I asked how to avoid fdopen() in another forum:
----
>> I need to replace some fdopen with something else or link with some library
>> that contains fdopen. I'm running a crosscompiler on Amiga for PPC and I
>> can't emulate fdopen.
>> Anyone have an idea how I can solve it?
MR> Try using fopen on another file and then replacing the fd in the structure
MR> before any I/O on the file. Not actually legal, but may work if you're
MR> desperate.
Another method: do fopen() of devnull, ask fileno() and call dup2().
It requires fileno() which isn't standard C function, but doesn't require
knowledge of struct FILE internals.
------
FILE* fdopen( int fd, const char* method ) {
FILE* f = fopen( "/dev/null", method );
int d, se;
if( !f ) return NULL;
d = fileno(f);
if( dup2( fd, d ) < 0 ) { se = errno; fclose(f); errno = se; return NULL; }
return f;
}
-
>Redicection of stderr maybe?
Memory is short.. :)
-
JoJo wrote:
>Redicection of stderr maybe?
Memory is short.. :)
Not half! Too much stuff competing for my immediate attention this weekend...
In the end I got next to nothing done anyway!
-edit-
You post this before or after you sent me the pmail with the fdopen() replacement?