<HTML><HEAD></HEAD>
<BODY dir=ltr>
<DIV dir=ltr>
<DIV style="FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: 12pt">
<DIV>Wouldn’t the timestamp of the file have changed?</DIV>
<DIV> </DIV>
<DIV>For this case you could also do a checksum or crc of the file. If the
file is huge it may be enough to crc just the first few kilobytes of the
file.</DIV>
<DIV> </DIV>
<DIV>Indy Singh<BR>IndigoSTAR Software -- www.indigostar.com</DIV>
<DIV
style="FONT-STYLE: normal; DISPLAY: inline; FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: small; FONT-WEIGHT: normal; TEXT-DECORATION: none">
<DIV style="FONT: 10pt tahoma">
<DIV> </DIV>
<DIV style="BACKGROUND: #f5f5f5">
<DIV style="font-color: black"><B>From:</B> <A title=fulko.hew@gmail.com
href="mailto:fulko.hew@gmail.com">Fulko Hew</A> </DIV>
<DIV><B>Sent:</B> Friday, May 04, 2012 1:45 PM</DIV>
<DIV><B>To:</B> <A title=toronto-pm@pm.org
href="mailto:toronto-pm@pm.org">TPM</A> </DIV>
<DIV><B>Subject:</B> [tpm] more problems than solutions this
week</DIV></DIV></DIV>
<DIV> </DIV></DIV>
<DIV
style="FONT-STYLE: normal; DISPLAY: inline; FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: small; FONT-WEIGHT: normal; TEXT-DECORATION: none"><FONT
face="courier new,monospace">Here's the next problem...<BR><BR>How can you tell
if a file pointer has been rewound?<BR><BR>The task:<BR><BR>...Follow the
contents of a file (and process any new data)<BR><BR>The problem:<BR><BR>While
testing the various permutations of how a file (log files)<BR>can get updated
you have typical actions like:<BR>- append new data onto the
end (new stuff)<BR>- delete the file and start over
(after log file rotation)<BR><BR>So one of my test modes was to use shell
redirection to<BR>write to a file. ie. echo "stuff" > file<BR><BR>What
I thought/expected would happen is that shell would create<BR>a new copy of the
file and write the string into it.<BR>[So when my app detects that the inode
changed, it would<BR>start reading the new file from the beginning.]<BR><BR>But
what I've found is that the inode doesn't change!<BR>[so I'd assume that the
">" redirection simply rewinds<BR>the write pointer to offset zero and writes
the string<BR>and then truncates the file at that point.]<BR><BR>So how can I
detect that?<BR><BR>One solution I considered was: to remember what the size
of<BR>the file was (the last time I looked) and if the new size<BR>is smaller...
it must have been truncated using this<BR>technique. That might work for
the majority of occurrances,<BR>but it doesn't work with the simplest
test.<BR><BR>echo `date` > file results in a 28 octet
long file so
I'll<BR>
remember that it was 28 bytes long for later<BR>...<BR>echo `date` >
file the inode hasn't changed and neither
has<BR>
the file size, yet there was 'new
stuff<BR>
that needs processing, that I won't see.<BR>...<BR><BR>Suggestions?<BR>(Or do I
just throw up my hands in disgust and say I can't/don't<BR>handle that
condition?)<BR><BR><BR>Fulko<BR><BR></FONT>
<P>
<HR>
_______________________________________________<BR>toronto-pm mailing
list<BR>toronto-pm@pm.org<BR>http://mail.pm.org/mailman/listinfo/toronto-pm<BR></DIV></DIV></DIV></BODY></HTML>