Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/datastructure.jl
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ root node leading up to this file.
"""
function Path(d::Node)
parent(d) === nothing && return Path(d.name)
# Prevent that empty names become ".". Not 100 that this is always right, but at least is prevents mv from silently deleting them
isempty(d.name) && return Path(parent(d))
Path(parent(d)) / Path(d.name)
end

Expand Down
17 changes: 17 additions & 0 deletions test/basics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,23 @@ import FileTrees: attach
# Also test that we maintained the same order as the first encountered node
@test name.(children(tcombined)) == ["y", "x"]
end

@testset "Unusual filenames" begin
# Some of these are generally not allowed on filesystems, but FileTrees handles them in other contexts
t = maketree("root" => [(name="", value=1), (name=".", value=2), (name="..", value=3), (name="a", value=4)])

# All names are accepted at this stage
@test name.(files(t)) == ["", ".", "..", "a"]
@test reducevalues(vcat, t) == 1:4

# Should be a noop
tmv = mv(t, r"(.*)", s"\1")

# The file named "." gets swallowed due to normdots which might be surprising. Maybe worth fixing in the future
@test name.(files(tmv)) == ["", "..", "a"]
@test reducevalues(vcat, tmv) == [1, 3, 4]

end
end

@testset "values" begin
Expand Down
Loading