From: Caolan McNamara (Caolan.McNamara at domain ul.ie)
Date: Wed 01 Sep 1999 - 16:11:53 IST
On 01-Sep-99 John P . Looney wrote:
> Anyone know a reliable way of checking if someone has added to a mailfile
>? I don't want to trip a wire if someone deletes a mail, etc.
Are you just looking for code suitable for a mail notification sort of thing ?
Where you just want to raise a flag when there is unread mail ? Maybe theres
a better way but the last time i went at it yonks ago
I just regularly did a fstat and if the mtime was < atime then we had been read
since the last addition, otherwise it was modified without any read since. And
for this case i ended up with a bletcherous storing of the last known size and
checking if we were bigger since the last read. If did mean that if the mailfile
had been shortened by 2k and a new mail of 1k had been added, all between
rescanning times, then i missed it. Not great but it worked in practice, seeing
as after the first mail notification app check we were resynced, which took
place every few ms, so you only would miss one mail max, until the next showed
up, loads of mail notification apps show this buglet. It depends I suppose on
how mail programs handle the mail file, if they were so good as to reopen the
mailfile when closing down after deleting mail just to do a read on it all
would be well :-)
It would be better to extract the headers of the mails in the mailfile and note
the absence or addition of various mails through that mechanism, that way you
know for sure if it has been added to or not, thats what id do if I was doing it
again. For the general case of ordinary files, you cant really tell the
a) having something removed
b) something added on
c) and something removed and added on in one session
a and b is easy coz of the filesize, but c aint going to happen without a copy
of the file to diff against, or for a file thats in a particular record format
i.e. a mailfile, you only need a certain subset of data to compare against.
I wonder am i talking out my butt now, all i ever looked at then was fstats man
page,i could have gotten it way wrong, and been suffering ever since.
>Microsoft. The best reason in the world to drink beer.
>Irish Linux Users' Group: ilug at domain linux.ie
>http://www.linux.ie/mailman/listinfo/ilug for (un)subscription information.
>List maintainer: listmaster at domain linux.ie
Real Life: Caolan McNamara * Doing: MSc in HCI
Work: Caolan.McNamara at domain ul.ie * Phone: +353-86-8790257
URL: http://www.csn.ul.ie/~caolan * Sig: an oblique strategy
The most important thing is the thing most easily forgotten
This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:04:31 GMT