Csound Csound-dev Csound-tekno Search About

[Csnd-dev] File handling internals and max string length advice

Date2022-01-26 18:33
FromRichard Knight
Subject[Csnd-dev] File handling internals and max string length advice
Following a mailing list discussion a month or two ago, I had a look at 
implementing some new opcodes:


dates2: like dates, but takes a C-style srftime format. strftime 
requires allocated memory - is CSOUND->strsmax the right thing to use 
for max string length? I am not sure if that would be excessive for the 
purpose though and perhaps a specified max length could be better eg 
1024 characters and as long as specified in the manual that could be OK 
- any opinions?


fprints2 & fprintks2 : like fprints and fprintks, but overwrite on each 
call instead of appending. I looked at using fout_deinit_callback and 
CSOUND->FileClose to close/reopen the file, but had some difficulty 
working out the file index bits etc in the way the existing file 
handling is built in Csound. I considered that ftruncate could be used 
instead of closing/reopening each time, although haven't used the 
function before and as I understand it is not recommendable to ftruncate 
an open file, also ftruncate is POSIX only I think. I did have some 
partial success with the truncate approach but am at a bit of a loss on 
the best way to do this, so any advice/suggestions/existing bits of code 
to look at would be appreciated.


thanks