Haskell語言Directory模塊中函數doesFileExist的用法及代碼示例。
用法類型:
FilePath -> IO Bool
手術doesFileExist如果參數文件存在且不是目錄,則返回True,否則返回False。
示例1:
源碼:
import IO
import Directory
main = do hdl <- openFile "/tmp/foo.txt" WriteMode
hPutStr hdl "Hello"
hClose hdl
x <- doesFileExist "/tmp/foo.txt"
print x
y <- doesFileExist "/tmp"
print y
輸出:
True
輸出:
False
注:本文由純淨天空篩選整理自 haskell doesFileExist。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。