LIB/GTK: reduce usage of System.Directory (directory package)
This commit is contained in:
parent
edb51ad1f6
commit
0ec4aaac54
@ -88,13 +88,6 @@ import Safe
|
|||||||
import System.Directory
|
import System.Directory
|
||||||
(
|
(
|
||||||
canonicalizePath
|
canonicalizePath
|
||||||
, doesFileExist
|
|
||||||
, executable
|
|
||||||
, getPermissions
|
|
||||||
, readable
|
|
||||||
, searchable
|
|
||||||
, writable
|
|
||||||
, Permissions
|
|
||||||
)
|
)
|
||||||
import System.FilePath
|
import System.FilePath
|
||||||
(
|
(
|
||||||
|
@ -86,8 +86,7 @@ import Safe
|
|||||||
)
|
)
|
||||||
import System.Directory
|
import System.Directory
|
||||||
(
|
(
|
||||||
executable
|
doesFileExist
|
||||||
, doesFileExist
|
|
||||||
, doesDirectoryExist
|
, doesDirectoryExist
|
||||||
)
|
)
|
||||||
import System.Environment
|
import System.Environment
|
||||||
|
@ -51,15 +51,9 @@ import IO.Error
|
|||||||
import IO.Utils
|
import IO.Utils
|
||||||
import System.Directory
|
import System.Directory
|
||||||
(
|
(
|
||||||
canonicalizePath
|
doesDirectoryExist
|
||||||
, createDirectory
|
|
||||||
, createDirectoryIfMissing
|
|
||||||
, doesDirectoryExist
|
|
||||||
, doesFileExist
|
, doesFileExist
|
||||||
, executable
|
|
||||||
, removeDirectory
|
|
||||||
, removeDirectoryRecursive
|
, removeDirectoryRecursive
|
||||||
, removeFile
|
|
||||||
)
|
)
|
||||||
import System.FilePath
|
import System.FilePath
|
||||||
(
|
(
|
||||||
@ -69,27 +63,40 @@ import System.FilePath
|
|||||||
, takeDirectory
|
, takeDirectory
|
||||||
, (</>)
|
, (</>)
|
||||||
)
|
)
|
||||||
|
import System.Posix.Directory
|
||||||
|
(
|
||||||
|
createDirectory
|
||||||
|
, removeDirectory
|
||||||
|
)
|
||||||
import System.Posix.Files
|
import System.Posix.Files
|
||||||
(
|
(
|
||||||
createSymbolicLink
|
createSymbolicLink
|
||||||
, readSymbolicLink
|
, readSymbolicLink
|
||||||
, fileAccess
|
, fileAccess
|
||||||
, getFileStatus
|
, getFileStatus
|
||||||
|
, groupExecuteMode
|
||||||
, groupReadMode
|
, groupReadMode
|
||||||
, groupWriteMode
|
, groupWriteMode
|
||||||
|
, otherExecuteMode
|
||||||
, otherReadMode
|
, otherReadMode
|
||||||
, otherWriteMode
|
, otherWriteMode
|
||||||
|
, ownerModes
|
||||||
, ownerReadMode
|
, ownerReadMode
|
||||||
, ownerWriteMode
|
, ownerWriteMode
|
||||||
, rename
|
, rename
|
||||||
, touchFile
|
, touchFile
|
||||||
, unionFileModes
|
, unionFileModes
|
||||||
|
, removeLink
|
||||||
)
|
)
|
||||||
import System.Posix.IO
|
import System.Posix.IO
|
||||||
(
|
(
|
||||||
closeFd
|
closeFd
|
||||||
, createFile
|
, createFile
|
||||||
)
|
)
|
||||||
|
import System.Posix.Types
|
||||||
|
(
|
||||||
|
FileMode
|
||||||
|
)
|
||||||
import System.Process
|
import System.Process
|
||||||
(
|
(
|
||||||
spawnProcess
|
spawnProcess
|
||||||
@ -170,7 +177,7 @@ copyDir cm from@(_ :/ Dir fromn _)
|
|||||||
= do
|
= do
|
||||||
let fromp = fullPath from
|
let fromp = fullPath from
|
||||||
top = fullPath to
|
top = fullPath to
|
||||||
destdirp = fullPath to </> fromn
|
destdirp = top </> fromn
|
||||||
throwDestinationInSource fromp destdirp
|
throwDestinationInSource fromp destdirp
|
||||||
throwSameFile fromp destdirp
|
throwSameFile fromp destdirp
|
||||||
|
|
||||||
@ -189,13 +196,14 @@ copyDir cm from@(_ :/ Dir fromn _)
|
|||||||
createDestdir destdir =
|
createDestdir destdir =
|
||||||
case cm of
|
case cm of
|
||||||
Merge ->
|
Merge ->
|
||||||
createDirectoryIfMissing False destdir
|
unlessM (doesDirectoryExist destdir)
|
||||||
|
(createDirectory destdir newDirPerms)
|
||||||
Strict -> do
|
Strict -> do
|
||||||
throwDirDoesExist destdir
|
throwDirDoesExist destdir
|
||||||
createDirectory destdir
|
createDirectory destdir newDirPerms
|
||||||
Replace -> do
|
Replace -> do
|
||||||
whenM (doesDirectoryExist destdir) (removeDirectoryRecursive destdir)
|
whenM (doesDirectoryExist destdir) (removeDirectoryRecursive destdir)
|
||||||
createDirectory destdir
|
createDirectory destdir newDirPerms
|
||||||
recreateSymlink' f destdir = do
|
recreateSymlink' f destdir = do
|
||||||
let destfilep = fullPath destdir </> (name . file $ f)
|
let destfilep = fullPath destdir </> (name . file $ f)
|
||||||
destfile <- Data.DirTree.readFile destfilep
|
destfile <- Data.DirTree.readFile destfilep
|
||||||
@ -325,7 +333,7 @@ easyMove _ _ = return ()
|
|||||||
-- |Deletes a symlink, which can either point to a file or directory.
|
-- |Deletes a symlink, which can either point to a file or directory.
|
||||||
deleteSymlink :: AnchoredFile FileInfo -> IO ()
|
deleteSymlink :: AnchoredFile FileInfo -> IO ()
|
||||||
deleteSymlink f@(_ :/ SymLink {})
|
deleteSymlink f@(_ :/ SymLink {})
|
||||||
= removeFile (fullPath f)
|
= removeLink (fullPath f)
|
||||||
deleteSymlink _
|
deleteSymlink _
|
||||||
= return ()
|
= return ()
|
||||||
|
|
||||||
@ -334,7 +342,7 @@ deleteSymlink _
|
|||||||
deleteFile :: AnchoredFile FileInfo -> IO ()
|
deleteFile :: AnchoredFile FileInfo -> IO ()
|
||||||
deleteFile (_ :/ SymLink {}) = return ()
|
deleteFile (_ :/ SymLink {}) = return ()
|
||||||
deleteFile f@(_ :/ RegFile {})
|
deleteFile f@(_ :/ RegFile {})
|
||||||
= removeFile (fullPath f)
|
= removeLink (fullPath f)
|
||||||
deleteFile _
|
deleteFile _
|
||||||
= return ()
|
= return ()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user