System.Directory module provides
copyFile function, used to copy file from old location to new location. If the
new file exists, the old file replaces it. Following is the signature of
copyFile function.
Prelude System.Directory> :t copyFile
copyFile :: FilePath -> FilePath
-> IO ()
DirectoryUtil.hs
import System.IO import System.Directory main = do putStrLn "Enter file path to copy" oldFile <- getLine putStrLn "Enter new name" newFile <- getLine copyFile oldFile newFile putStrLn "File copied"
$ ls -l /Users/harikrishna_gurram/aca*log -rw-r--r-- 1 harikrishna_gurram SYMC\Domain Users 1911 Apr 2 13:37 /Users/harikrishna_gurram/academyLogin.log $ $ runghc DirectoryUtil.hs Enter file path to copy /Users/harikrishna_gurram/academyLogin.log Enter new name /Users/harikrishna_gurram/academyLogin_backup.log File copied $ $ ls -l /Users/harikrishna_gurram/aca*log -rw-r--r-- 1 harikrishna_gurram SYMC\Domain Users 1911 Apr 2 13:37 /Users/harikrishna_gurram/academyLogin.log -rw-r--r-- 1 harikrishna_gurram SYMC\Domain Users 1911 Apr 6 14:58 /Users/harikrishna_gurram/academyLogin_backup.log
No comments:
Post a Comment