Page 1 of 1
How do I write DXF text to stdout?
Posted: Sat Mar 24, 2012 5:24 pm
by chainichek
I use DL_WriterA to write DXF text to some.dxf file. Is there any way to redirect DXF text to stdout?
Re: How do I write DXF text to stdout?
Posted: Thu Mar 29, 2012 11:04 pm
by andrew
Not directly from dxflib. You'd have to generate a temporary file and then stream it to stdout.
Re: How do I write DXF text to stdout?
Posted: Fri Mar 30, 2012 8:32 am
by chainichek
I use 'tmpnam' to generate temporary file name although the manual page on 'tmpnam' does not recommend to use this function:
#man 3 tmpnam
...
BUGS
Never use this function. Use mkstemp(3) or tmpfile(3) instead.
...
Could you recommend more coorect way to generate temporary file for writing DXF data?
Re: How do I write DXF text to stdout?
Posted: Mon Apr 02, 2012 2:41 pm
by andrew
The man page seems to suggest 'Use mkstemp(3) or tmpfile(3) instead.'
I haven't used these lately, but according to their man pages they might provide what you are looking for.
Re: How do I write DXF text to stdout?
Posted: Mon Apr 02, 2012 3:19 pm
by chainichek
DL_WriterA requires file name as parameter while these (safe) functions return file descriptor or stream -- not file name.
Re: How do I write DXF text to stdout?
Posted: Tue Apr 03, 2012 10:54 am
by andrew
You are right. dxflib would have to be adjusted to work with those functions.
A possible solution might be to create a temporary directory instead of a file using mkdtemp.
You could then create file(s) inside that directory with any fixed or dynamic name(s).