[Haskell-cafe] Test if a file is empty or stat in haskell

Henk-Jan van Tuyl hjgtuyl at chello.nl
Thu Mar 5 14:20:23 EST 2009

On Thu, 05 Mar 2009 19:56:42 +0100, Anish Muttreja  
<anishmuttreja at gmail.com> wrote:

> I am looking for a way to test if a file is empty.
> Something like isFileEmpty along the lines of
> System.Directory.doesFileExist?
> A function that wraps stat would also serve the purpose.
> I get the feeling that someone must have felt the need for this before
> me, but Google search not yield anything, hence the question.
> Thanks!
> Anish

Searching for "size" with Hoogle lead me to System.IO.hFileSize:
   hFileSize :: Handle -> IO Integer
   For a handle hdl which attached to a physical file, hFileSize hdl  
returns the size of that file in 8-bit bytes.

Henk-Jan van Tuyl


More information about the Haskell-Cafe mailing list