I am adapting the Boyer-Moore-Horspool text search algorithm to get the text input from a file. Many of the examples on the net use a string variable rather than a file. The one example that uses a file does not use the Boyer-Moore-Horspool method. Arrgguuhh!!!
To read the text file, I am using a BlockRead. For efficiency, I want to read the entire text file with one read. The data is read into an array of char. I can hard code the array ending value to a huge number like 262,140 ((2**18)-1) or larger which could waste a lot of space.
Is there a way I can quickly calculate the size of the file that is equal to or slightly larger than the exact size of the file?
Please see code below.
arBuffer : array [0..MaxSize] of char
BufEnd : integer;
BlockRead(F, arBuffer, SizeOf(arBuffer), BufEnd);
BufPtr := 0;