Skip to content

Commit

Permalink
Merge pull request #19291 from stevengj/casesense
Browse files Browse the repository at this point in the history
make isfile_casesensitive only check case of the basename on Windows
  • Loading branch information
vtjnash authored Nov 10, 2016
2 parents d925311 + 9db40bd commit 9c181c1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
2 changes: 1 addition & 1 deletion base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ elseif is_windows()
# GetLongPathName Win32 function returns the case-preserved filename on NTFS.
function isfile_casesensitive(path)
isfile(path) || return false # Fail fast
Filesystem.longpath(path) == path
basename(Filesystem.longpath(path)) == basename(path)
end
elseif is_apple()
# HFS+ filesystem is case-preserving. The getattrlist API returns
Expand Down
32 changes: 21 additions & 11 deletions test/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,28 @@ thefname = "the fname!//\\&\1*"
@test @__DIR__() == dirname(@__FILE__)

# Issue #5789 and PR #13542:
let true_filename = "cAsEtEsT.jl", lowered_filename="casetest.jl"
touch(true_filename)
@test Base.isfile_casesensitive(true_filename)
@test !Base.isfile_casesensitive(lowered_filename)
rm(true_filename)
end
mktempdir() do dir
cd(dir) do
let true_filename = "cAsEtEsT.jl", lowered_filename="casetest.jl"
touch(true_filename)
@test Base.isfile_casesensitive(true_filename)
@test !Base.isfile_casesensitive(lowered_filename)

# check that case-sensitivity only applies to basename of a path:
if isfile(lowered_filename) # case-insensitive filesystem
mkdir("cAsEtEsT")
touch(joinpath("cAsEtEsT", true_filename))
@test Base.isfile_casesensitive(joinpath("casetest", true_filename))
@test !Base.isfile_casesensitive(joinpath("casetest", lowered_filename))
end
end

# Test Unicode normalization; pertinent for OS X
let nfc_name = "\U00F4.jl"
touch(nfc_name)
@test Base.isfile_casesensitive(nfc_name)
rm(nfc_name)
# Test Unicode normalization; pertinent for OS X
let nfc_name = "\U00F4.jl"
touch(nfc_name)
@test Base.isfile_casesensitive(nfc_name)
end
end
end

let paddedname = "Ztest_sourcepath.jl"
Expand Down

0 comments on commit 9c181c1

Please sign in to comment.