Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#1 Support for files that have Shrunk..

closed-fixed
nobody
None
5
2003-10-17
2003-01-24
Gil Peeters
No

Hello,

Dunno if anyone is interested, but I have made a very
simeple change that allows for files that have shrunk, or
been restarted..

We have a situation where we have a log file that we
are 'tail'ing and everytime the application restarts, the
log file is cleared and restarted...

This has the efect in TailForWin32 that we get an error
popup: "Could not allocate memory for file!"

This is because of a negative dwBufferSize value when
the file has shrunk..

I added the following lines of code in the ReaderThread
method in the TailView.cpp file from the "4.2.1" stable
version source...

I don't have a diff to create adiff file, but it is a simple
change so here goes.. It's around line 944..

}
return 1;
}

// New code STARTS here
// Check if the file has shrunk...
if (dwNewFileSize < dwOldFileSize)
{
// Clear the Text
pEdit->SetSel(0, -1);
pEdit->ReplaceSel("");
// setup as a bFirst..
bFirst = TRUE;
// Old size is now 0
dwOldFileSize = 0;
}
// New code ENDS here

if (bFirst && bIgnoreHotStartup)
{
dwBufferSize = dwNewFileSize + 1;
}
else

Cheers

Gil.

Discussion

  • Paul Perkins
    Paul Perkins
    2003-10-17

    Logged In: YES
    user_id=531602

    Hi Gil,

    This has now been added to 4.2.1-2 as part of the ongoing
    work.

    Thanks for your contribution.

     
  • Paul Perkins
    Paul Perkins
    2003-10-17

    • status: open --> closed-fixed