Haskell語言Directory模塊中函數renameDirectory的用法及代碼示例。
用法類型:
FilePath -> FilePath -> IO ()
renameDirectoryold new將現有目錄的名稱從old更改為new。如果新目錄已經存在,則將其自動替換為舊目錄。如果新目錄既不是舊目錄也不是舊目錄的別名,則將其刪除,就像通過removeDirectory。一致的實現不需要在所有情況下都支持重命名目錄(例如,重命名到現有目錄或跨不同的物理設備),但是必須記錄約束。
示例1:
源碼:
import Directory
main = do createDirectory "/tmp/BAR"
a <- doesDirectoryExist "/tmp/BAR"
renameDirectory "/tmp/BAR" "/tmp/FOO"
b <- doesDirectoryExist "/tmp/BAR"
c <- doesDirectoryExist "/tmp/FOO"
print (a,b,c)
輸出:
(True,False,True)
注:本文由純淨天空篩選整理自 haskell renameDirectory。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。