PtMultiText and large files

the PtMultiText widget does not like large files yet??
It takes a huge amount of time, just to load a 200.000 byte
textfile …for the text to render in the widget.
perhaps there is a faster way to load text than this? :slight_smile:)

some old sourcecode

/* open the file /
if((fp=fopen(info.path,“r”))==NULL)
{
}
else {
/
check the filesize and allocate memory /
if(stat(info.path, &buf) != -1) {
infil = (char
)malloc(buf.st_size);
if(infil != NULL) {
file_ok=1;
}
}

}

if(file_ok==1) {
/* put the file in an array… */
while(ch != EOF)
{
ch=fgetc(fp);
infil[i++] = ch;
}
PtSetResource(ABW_textarea, Pt_ARG_TEXT_STRING,infil,NULL);
}

This is the slowest way to load a file:

while(ch != EOF)
{
ch=fgetc(fp);
infil[i++] = ch;
}

use read(fp, …) instead.

Then see if this was the reason for the slow operation.
Markus



“kvack” <eh@nospam.ty> wrote in message
news:Voyager.001005222445.1863695A@localhost.localdomain

the PtMultiText widget does not like large files yet??
It takes a huge amount of time, just to load a 200.000 byte
textfile …for the text to render in the widget.
perhaps there is a faster way to load text than this? > :slight_smile:> )

some old sourcecode

/* open the file /
if((fp=fopen(info.path,“r”))==NULL)
{
}
else {
/
check the filesize and allocate memory /
if(stat(info.path, &buf) != -1) {
infil = (char
)malloc(buf.st_size);
if(infil != NULL) {
file_ok=1;
}
}

}

if(file_ok==1) {
/* put the file in an array… */
while(ch != EOF)
{
ch=fgetc(fp);
infil[i++] = ch;
}
PtSetResource(ABW_textarea, Pt_ARG_TEXT_STRING,infil,NULL);
}