[lug] CreateFile problem

ljp ljp at llornkcor.com
Tue Apr 10 06:00:04 MDT 2001


At 23:01 4/9/2001 -0700, you wrote:
>hi guys,
>im trying to create a file of predefined size. In
>windows i was able to do it with CreateFile. Is it
>possible to do the same in linux?

you could use
open( O_CREAT, 0644);
and then lseek the number of bytes you want.

   short data[]={0};

      int fd=::open( filename, O_RDWR |O_CREAT, 0644);
         ::lseek( fd, fileLength, SEEK_SET);
         ::write( fd, data, SEEK_SET);

ljp




More information about the LUG mailing list