Skip to content

Commit

Permalink
Compat.mv and Compat.cp with force keyword argument (#512)
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikekre authored Mar 6, 2018
1 parent 0402d82 commit fd3b92a
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,8 @@ Currently, the `@compat` macro supports the following syntaxes:

* `Compat.trunc`, `Compat.floor`, `Compat.ceil`, `Compat.round`, `Compat.signif` take a keyword argument for `base` ([#26156]).

* `Compat.mv` and `Compat.cp` with `force` keyword argument ([#26069]).

## Renaming

* `Display` is now `AbstractDisplay` ([#24831]).
Expand Down Expand Up @@ -580,6 +582,8 @@ includes this fix. Find the minimum version from there.
[#25819]: https://github.com/JuliaLang/julia/issues/25819
[#25873]: https://github.com/JuliaLang/julia/issues/25873
[#25896]: https://github.com/JuliaLang/julia/issues/25896
[#25959]: https://github.com/JuliaLang/julia/issues/25959
[#25990]: https://github.com/JuliaLang/julia/issues/25990
[#26069]: https://github.com/JuliaLang/julia/issues/26069
[#26089]: https://github.com/JuliaLang/julia/issues/26089
[#26156]: https://github.com/JuliaLang/julia/issues/26156
7 changes: 7 additions & 0 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1658,6 +1658,13 @@ else
import Base: range, LinRange
end

@static if VERSION < v"0.7.0-DEV.3995"
cp(src::AbstractString, dst::AbstractString; force::Bool=false, follow_symlinks::Bool=false) =
Base.cp(src, dst; remove_destination = force, follow_symlinks = follow_symlinks)
mv(src::AbstractString, dst::AbstractString; force::Bool=false) =
Base.mv(src, dst; remove_destination = force)
end

include("deprecated.jl")

end # module Compat
20 changes: 20 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1467,4 +1467,24 @@ end
@test Compat.range(2, step=2, length=8) == 2:2:16
@test Compat.range(1.0, stop=2.0, length=3) == 1.0:0.5:2.0

# 0.7.0-DEV.3995
mktempdir(@__DIR__) do dir
src = joinpath(dir, "src.jl")
touch(src)
dest = joinpath(dir, "dest.jl")
touch(dest)
open(src, "w") do f
write(f, "Hello, world!")
end
Compat.cp(src, dest, force = true)
open(dest, "r") do f
@test read(f, String) == "Hello, world!"
end
Compat.mv(src, dest, force = true)
open(dest, "r") do f
@test read(f, String) == "Hello, world!"
end
@test readdir(dir) == ["dest.jl"]
end

nothing

0 comments on commit fd3b92a

Please sign in to comment.