Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
5439f0ee
Commit
5439f0ee
authored
Jun 28, 2016
by
kaiha
Browse files
Rework copyDirectoryContent
parent
21f3e056
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/Rules/Actions.hs
View file @
5439f0ee
...
...
@@ -2,7 +2,7 @@ module Rules.Actions (
build
,
buildWithCmdOptions
,
buildWithResources
,
copyFile
,
fixFile
,
moveFile
,
removeFile
,
copyDirectory
,
copyDirectoryContent
,
createDirectory
,
moveDirectory
,
removeDirectory
,
applyPatch
,
runBuilder
,
runBuilderWith
,
makeExecutable
,
renderProgram
,
renderLibrary
makeExecutable
,
renderProgram
,
renderLibrary
,
Exclude
(
..
),
ExcludeNot
(
..
)
)
where
import
qualified
System.Directory.Extra
as
IO
...
...
@@ -14,6 +14,7 @@ import CmdLineFlag
import
Context
import
Expression
import
Oracles.ArgsHash
import
Oracles.DirectoryContent
import
Oracles.WindowsPath
import
Settings
import
Settings.Args
...
...
@@ -127,17 +128,18 @@ copyDirectory source target = do
putProgressInfo
$
renderAction
"Copy directory"
source
target
quietly
$
cmd
cmdEcho
[
"cp"
,
"-r"
,
source
,
target
]
-- | Copy the content of the source directory into the target directory. Only
-- the files and directories for which the predicate returns True are copied.
copyDirectoryContent
::
(
FilePath
->
IO
Bool
)
->
FilePath
->
FilePath
->
Action
()
copyDirectoryContent
test
source
target
=
do
putProgressInfo
$
renderAction
"Copy directory"
source
target
liftIO
$
IO
.
listFilesInside
test'
source
>>=
mapM_
cp
-- | Copy the content of the source directory into the target directory.
-- 'Exclude' and 'ExcludeNot' are a list of file patterns matched with '?=='.
-- The copied content is tracked.
copyDirectoryContent
::
Exclude
->
ExcludeNot
->
FilePath
->
FilePath
->
Action
()
copyDirectoryContent
exclude
excludeNot
source
target
=
do
putProgressInfo
$
renderAction
"Copy directory content"
source
target
getDirectoryContent
exclude
excludeNot
source
>>=
mapM_
cp
where
cp
a
=
do
createDirectory
$
dropFileName
$
target'
a
copyFile
a
$
target'
a
target'
a
=
target
-/-
fromJust
(
stripPrefix
source
a
)
test'
a
=
ifM
(
test
a
)
(
mkdir
a
>>
return
True
)
(
return
False
)
mkdir
a
=
IO
.
createDirectoryIfMissing
True
$
target'
a
cp
a
=
whenM
(
test
a
)
$
IO
.
copyFile
a
$
target'
a
-- | Move a directory. The contents of the source directory is untracked.
moveDirectory
::
FilePath
->
FilePath
->
Action
()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment