2013-12-12 84 views

回答

3

您可以使用getFileStatusfileSize從System.Posix模塊要做到這一點:

import System.Posix 
main = getFileStatus "/path/to/file" >>= print . fileSize 

編輯:System.Posixunix包,它僅適用於Linux和類似的規定。但是,unix-compat程序包提供了一個導出這些相同功能的System.PosixCompat.Files模塊,並且可在Windows上工作。 (和Linux?)

+0

顯然,這將在Linux上工作;它會在Windows上工作嗎? – MathematicalOrchid

+0

編輯:我以爲會,但現在我不確定。 – fjh

+0

看看我的包索引,我看到'System.Posix.Types',但如果我嘗試導入任何其他POSIX模塊,GHCi會給我一個錯誤。 – MathematicalOrchid

相關問題