[View] [Edit] [Lock] [References] [Attachments] [History] [Home] [Changes] [Search] [Help]
test[nodeJS] 048 File truncation (async)
"048-5 Tuncating file with #truncate:len:with:"
'Content generated by S8.Content generated by S8.Content generated by S8.' outputToFile: (TestPath,'Sample48-5.txt').
NodeJS fs truncate: (TestPath,'Sample48-5.txt') len:1 with:[:error|
error isNil ifFalse:[ ^self error: '048-5 ', error]
].
"048-6 Truncating file with #ftruncate:len:with:"
| fs |
fs := NodeJS fs.
fs open:(TestPath, 'Sample48-6.txt') flags:#w mode: 0666 with: [:error :fd|
error isNil ifFalse: [self error: '048-6 ' ,error].
fs write: fd data: 'Content generated by S8.Content generated by S8.Content generated by S8' position: 0 encoding: #utf8 with:[:er :written :string|
er isNil ifFalse: [^self error:'048-6 ', er].
[fs fsyncSync: fd]
on: Error
do: [:ex| ^self error: '048-6 ' ,ex].
fs ftruncate: fd len:1 with:[:e|
e isNil ifFalse:[ ^self error: '048-6 '].
fs closeSync:fd.
].
].
].