Test if a file is empty or stat in haskell

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

Am Donnerstag, 5. März 2009 19:56 schrieb Anish Muttreja:
I am looking for a way to test if a file is empty. Something like isFileEmpty along the lines of System.Directory.doesFileExist?
If you're on a *nixy OS, System.Posix.Files getFileStatus, fileSize ... dunno if Windows has similar functionality.
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

On Thu, Mar 05, 2009 at 08:15:03PM +0100, Daniel Fischer wrote:
Am Donnerstag, 5. März 2009 19:56 schrieb Anish Muttreja:
I am looking for a way to test if a file is empty. Something like isFileEmpty along the lines of System.Directory.doesFileExist?
If you're on a *nixy OS, System.Posix.Files
getFileStatus, fileSize ...
Great, thanks.
dunno if Windows has similar functionality.
I am on Linux. BTW, Hoogle does not seem to know about System.Posix.Files, though it did point me to System.IO.FileSize which would also have served the purpose. http://www.haskell.org/hoogle/?hoogle=fileSize Thanks, Anish
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

Hi
I am on Linux. BTW, Hoogle does not seem to know about System.Posix.Files, though it did point me to System.IO.FileSize which would also have served the purpose.
To build the Hoogle libraries I need to build the packages. I run Windows not Linux, so its a bit difficult to index System.Posix - but I am trying to shortly. Thanks Neil

getFileStatus, fileSize ...
Great, thanks. BTW, Hoogle does not seem to know about System.Posix.Files, though it did point me to System.IO.FileSize which would also have served the purpose.
Yep, this was discussed in a Hoogle and Network.Socket thread I started last week. There is a wiki for summarizing thoughts [1]. Some time this weekend or next week I intend to submit a Hoogle ticket proposing what I see as an agreeable outcome. At that point I hope Neil will accept and maybe even find time to write code. The final step would involve me buying Neil a beer - I've lots of beer-debt to the Haskell community. [1] http://haskell.org/haskellwiki/Hoogle/Packages

On Thu, Mar 05, 2009 at 03:43:22PM -0500, Thomas DuBuisson wrote:
getFileStatus, fileSize ...
Great, thanks. BTW, Hoogle does not seem to know about System.Posix.Files, though it did point me to System.IO.FileSize which would also have served the purpose.
Yep, this was discussed in a Hoogle and Network.Socket thread I started last week. There is a wiki for summarizing thoughts [1]. Some time this weekend or next week I intend to submit a Hoogle ticket proposing what I see as an agreeable outcome. At that point I hope Neil will accept and maybe even find time to write code. The final step would involve me buying Neil a beer - I've lots of beer-debt to the Haskell community.
Thanks Michael and Neil, for maintaining Hoogle. Hoogle is becoming a victim of it's own success. We depend on it and so want it to do everything :-). I cannot edit the wiki page because creating new logins is currently disabled. My only suggestion is that perhaps the Hoogle front page should have a discrete disclaimer about the current scope of indexed packages until a solution is found. It might be useful for someone new. Anish

On Thu, 05 Mar 2009 19:56:42 +0100, Anish Muttreja
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. -- Regards, Henk-Jan van Tuyl -- http://functor.bamikanarie.com http://Van.Tuyl.eu/ --
participants (5)
-
Anish Muttreja
-
Daniel Fischer
-
Henk-Jan van Tuyl
-
Neil Mitchell
-
Thomas DuBuisson