From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c9019477667b9c0f,start X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.75.170 with SMTP id d10mr5657391pbw.6.1323972906263; Thu, 15 Dec 2011 10:15:06 -0800 (PST) Path: lh20ni26141pbb.0!nntp.google.com!news1.google.com!postnews.google.com!u32g2000yqe.googlegroups.com!not-for-mail From: awdorrin Newsgroups: comp.lang.ada Subject: Writing Data to a file Date: Thu, 15 Dec 2011 10:13:05 -0800 (PST) Organization: http://groups.google.com Message-ID: <344d32d6-a667-407c-bb8e-e0c504e91688@u32g2000yqe.googlegroups.com> NNTP-Posting-Host: 192.91.171.42 Mime-Version: 1.0 X-Trace: posting.google.com 1323972906 4010 127.0.0.1 (15 Dec 2011 18:15:06 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 15 Dec 2011 18:15:06 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: u32g2000yqe.googlegroups.com; posting-host=192.91.171.42; posting-account=YkFdLgoAAADpWnfCBA6ZXMWTz2zHNd0j User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: HUALESRCNK X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 5.1; rv:8.0) Gecko/20100101 Firefox/8.0,gzip(gfe) Content-Type: text/plain; charset=ISO-8859-1 Date: 2011-12-15T10:13:05-08:00 List-Id: I have code that imports the unix 'write' function in order to write a stream of byte data. I had thought that replacing this call with the POSIX.IO.Write would make more sense, so that I was using more of a standard method. Unfortunately, I cannot access the write function within POSIX.IO, so I'm stuck with using the Write procedures. I have the following code, but I'm not sure that I'm doing this the right way... declare Buf_Last : Stream_Element_Count; Buf_Addr : System.Address := AREA_PTR + Storage_Offset(READ_OFFSET); Buf : Stream_Element_Array( 1 .. Stream_Element_Count( WRITE_OFFSET - READ_OFFSET) ); for Buf'Address use Buf_Addr; begin POSIX.IO.Write( File=>FileHandle, Buffer=>Buf, Last=>Buf_Last); end; The original code, using the imported function was: C_WRITE( File => FileHandle, Buffer=> (Q_AREA_PTR + Storage_Offset(READ_OFFSET), Num_Bytes=> (WRITE_OFFSET - READ_OFFSET)); having to use the declare section to overlay the Stream_Element_Array onto the memory segment of the buffer seems much more complicated; so I feel like there is likely an easier way to do this, using standard Ada, and not having to import the C write function. Anyone have any suggestions?