Re: Changing File Size with OPENU? [message #10219 is a reply to message #10215] |
Mon, 27 October 1997 00:00  |
thompson
Messages: 584 Registered: August 1991
|
Senior Member |
|
|
Wayne:
I confirm this behaviour in IDL/v4.0.1 on a DEC Alpha workstation running
OSF/v4, including the difference in behavior when the "print,fstat(lun)" line
is uncommented. I can't see how a simple print statement to the terminal
screen could be expected to affect file I/O, so it must be a bug.
Have you tried writing something other than zeroes to the file? Do the bytes
go where you expected them to, or to some other location. Is the file simply
padded out with extra unwanted zeroes, with random values, or with data?
Bill
============================================================ ===================
Wayne Landsman <landsman@mpb.gsfc.nasa.gov> writes:
> I always thought that when opening a file with OPENU that the file
> wouldn't
> change size, unless one wrote past the end of the file. But below I
> give an
> example of a file changing size, even though I never reached the end of
> the
> file.
> I suspect this might be a IDL (or Solaris 2.6) bug, because if I
> uncomment the
> ;print,fstat(lun) line below, then the file size stays unchanged. But
> I
> don't trust my thought process right now after spending 3 hours trying
> to track
> down this bug. Anybody know if the behaviour in the example below is
> expected?
> --Wayne Landsman
> landsman@mpb.gsfc.nasa.gov
> ; IDL Version 5.0.2 (sunos sparc)
> ;Create a 250000 byte file
> openw,lun,'tester.dat',/get_lun
> writeu,lun,bytarr(250000)
> close,lun
> ;Make sure it really is 250000 bytes
> spawn,'ls -l tester.dat'
> ;-rw-r--r-- 1 landsman 250000 Oct 26 08:13 tester.dat
> ;Now open file for update and move
> ; 14400 + 2400 + 230000 = 246800 bytes into the file
> openu,lun,'tester.dat'
> point_lun,lun,14400 ;Offset to 14400 bytes
> b = bytarr(2400)
> readu,lun,b ;Now read 2400 bytes
> ;print,fstat(lun)
> writeu,lun,bytarr(230000) ;Now write 230000 bytes
> free_lun,lun
> spawn,'ls -l tester.dat' ;And file has changed size!!
> -rw-r--r-- 1 landsman 254992 Oct 26 08:13 tester.dat
|
|
|