Guest Bill David Posted September 11, 2008 Posted September 11, 2008 I use Low Level I/O API (_open) to create a binary file. Then I use _chsize to set the size of this file (a big size). And then I _open this file for reading (get fd1), and _open it for writing (get fd2) and _write something to it. After that, I _read something from the beginning with fd1, but find: 1.I have written 65535 bytes to the file; (with fd1) 2.But I can only read 126 bytes out with the 3rd parameter as 1024. (with fd2) Is it possible? How to avoid it? Note: 1.Everything should have been done in a single thread. 2.I am writing an extension for another product, I must use fd instead of FILE* that's why I use Low Level I/O API instead of buffered FILE I/ O. 3.the following is part of my log: CStreamFileAccessor checkStatus, data length=65535. - CStreamFileAccessor checkStatus, written bytes=65535. - -- >result of write with fd2 CPlainFileAccessor updateStatusRecord, blockId=1,nBlocks=1. - CStreamFileAccessor call ::read, iHandle=3,uOffset=0,nBytes=1024. - -->request for 1024 bytes CConcreteFileAdaptor after reading, nCount=126. - --
Guest Anthony [MVP] Posted September 12, 2008 Posted September 12, 2008 Re: A question about using Low Level I/O API to read/write binary file I think this probably belongs in platformsdk newsgroup "Bill David" <billdavidcn@gmail.com> wrote in message news:a70c1a62-88d2-44eb-a9a8-b4eec7e49e41@p10g2000prf.googlegroups.com... > I use Low Level I/O API (_open) to create a binary file. Then I use > _chsize to set the size of this file (a big size). And then I _open > this file for reading (get fd1), and _open it for writing (get fd2) > and _write something to it. After that, I _read something from the > beginning with fd1, but find: > 1.I have written 65535 bytes to the file; (with fd1) > 2.But I can only read 126 bytes out with the 3rd parameter as 1024. > (with fd2) > Is it possible? How to avoid it? > > Note: > 1.Everything should have been done in a single thread. > 2.I am writing an extension for another product, I must use fd > instead > of FILE* that's why I use Low Level I/O API instead of buffered FILE > I/ > O. > 3.the following is part of my log: > CStreamFileAccessor checkStatus, data length=65535. - > CStreamFileAccessor checkStatus, written bytes=65535. - -- >>result > of write with fd2 > CPlainFileAccessor updateStatusRecord, blockId=1,nBlocks=1. - > CStreamFileAccessor call ::read, > iHandle=3,uOffset=0,nBytes=1024. - > -->request for 1024 bytes > CConcreteFileAdaptor after reading, nCount=126. - --
Recommended Posts