[Haskell-cafe] hFileSize vs length
gracjan at acchsh.com
Sat Mar 12 03:41:39 EST 2005
S. Alexander Jacobson wrote:
> I am using GHC 6.2 on windows and am finding that when I open a file and
> use hFileSize I get a different number than I get from reading in the
> file and calculating the length. I assume this is not a bug, but I
> don't know why its happening.
Isn't that because of line end conversion? EOL on windows is \r\n (2
bytes), when read converted on the fly to \n (1 char).
Try to open your file in binary mode.
> Also, why isn't there getFileSize function in System.Directory?
System.Posix.Files has getFileStatus and fileSize. No idea if they work
> S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
More information about the Haskell-Cafe