frank cui wrote:
Thanks John and Peter for the reply.
Ok, to make this question more specific, the author of this book is making
a program to check if the files can be read off from the disk.
And he does so by checking two steps, first is making sure the meta data of
this file looks fine,
Yes, but the stat fields he checks could be valid and still all have the
value of zero. I would expect that only fields 0, 1 and 12 (DEV, INO
and MODE) would normally be non-zero.
and secondly by reading byte by byte from this file
to actually check the file's content readability.
You would probably only need to read one byte to see if the file is
readable. He is checking that the operating system returns the same
number of bytes that stat says the file contains. And you couldn't
confirm that by seeking to the end of the file and reading one byte
because there may be invalid disk sectors in the middle of the file that
are unreadable.
John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction. -- Albert Einstein
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/