How do I write DXF text to stdout?

Use this forum to ask questions about how to do things in dxflib.

Moderator: andrew

How do I write DXF text to stdout?

Postby chainichek » Sat Mar 24, 2012 5:24 pm

I use DL_WriterA to write DXF text to some.dxf file. Is there any way to redirect DXF text to stdout?
chainichek
 
Posts: 3
Joined: Sat Mar 24, 2012 5:14 pm

Re: How do I write DXF text to stdout?

Postby andrew » Thu Mar 29, 2012 11:04 pm

Not directly from dxflib. You'd have to generate a temporary file and then stream it to stdout.
andrew
Site Admin
 
Posts: 1839
Joined: Fri Mar 30, 2007 6:07 am

Re: How do I write DXF text to stdout?

Postby chainichek » Fri Mar 30, 2012 8:32 am

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?
chainichek
 
Posts: 3
Joined: Sat Mar 24, 2012 5:14 pm

Re: How do I write DXF text to stdout?

Postby andrew » Mon Apr 02, 2012 2:41 pm

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.
andrew
Site Admin
 
Posts: 1839
Joined: Fri Mar 30, 2007 6:07 am

Re: How do I write DXF text to stdout?

Postby chainichek » Mon Apr 02, 2012 3:19 pm

DL_WriterA requires file name as parameter while these (safe) functions return file descriptor or stream -- not file name.
chainichek
 
Posts: 3
Joined: Sat Mar 24, 2012 5:14 pm

Re: How do I write DXF text to stdout?

Postby andrew » Tue Apr 03, 2012 10:54 am

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).
andrew
Site Admin
 
Posts: 1839
Joined: Fri Mar 30, 2007 6:07 am


Return to dxflib 'How Do I' Questions

Who is online

Users browsing this forum: No registered users and 1 guest