Mantis - Squeak
Viewing Issue Advanced Details
1305 Files minor always 06-03-05 21:16 12-12-05 11:24
chris  
andreas  
normal  
assigned 3.8  
open  
none    
none  
0001305: StandardFileStream>>truncate: bug
After using myFileStream>>#truncate:, the #size of the file still reflects the old size until you #close and then #open the file.

The size of the file should reflect what it was truncated to.

Notes
(0002912)
cdegroot   
10-19-05 23:57   
Reproducable on Win32. Seems to be in the primitives...

testTruncate
    "Mantis 0001305"
    | stream |
    [(FileDirectory default forceNewFileNamed: 'filestream.tst')
        nextPutAll: '42';
        close.
    
    stream := FileDirectory default oldFileNamed: 'filestream.tst'.
    [stream truncate.
    self assert: stream size = 0]
        ensure: [stream close]
    ]
        
        ensure: [FileDirectory default deleteFileNamed: 'filestream.tst' ifAbsent: nil]
(0002913)
cdegroot   
10-20-05 00:10   
On Win32, sqFileSize in the sqWin32FilePlugin.c returns f->fileSize instead of going to the OS. Which probably means that the truncate function should fix f->fileSize.
(0003287)
cdegroot   
12-12-05 11:24   
Andreas - could you check whether my analysis is correct here?