[erlang-questions] size of an open file
Thu May 15 11:06:07 CEST 2008
If I understand you correctly you have the resources to do the
open the file and start to read from it. When you hit eof you wait a
while and try again. After some time of getting nothing but eof you can
test if the current position is bigger than the file size of the
original file name. When this happens you close the current file and
open the original file name. Repeat.
This will fail if the current file is (re)moved at position 1000, and
the new file with the original name manages to fill up to exactly 1000
before you test its size. Given a program that rapidly fills many small
files with exactly the same content that is not unlikely.
If you have that scenario you need to know how fast the file fills so
that you can test its size before it manages to become full.
On Thu, 2008-05-15 at 16:55 +1000, jm wrote:
> Bengt Kleberg wrote:
> > Greetings,
> > What are your requirements?
> > Do you have enough time/cpu/etc to open/close the file when reading the
> > tail part of it?
> > bengt
> This started as a programming exercise while I had nothing better to do
> waiting for a quote from a vendor. The idea was to get more experience
> with erlang by writing something which normally has side effects and to
> use some of the functions which I've not used in erlang yet. I decided
> to try and imitate unix's "tail -F" to some extent, ie tail with follow
> file. There isn't any requirements beyond that. What I have at the
> moment reads in from a file and breaks it into lines. There are two
> version one which returns the lines and continutation info and another
> which uses lists:foreach to call a passed in function on each line.
> The next step is to add the follow file functionality. Speed is not
> important. I may us it later in a program. If that happens then I'd be
> reading from multiple files similtaneously, so concurrentency may be.
> erlang-questions mailing list
More information about the erlang-questions