Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isfile_casesensitive fixes on Windows #55220

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions base/path.jl
Original file line number Diff line number Diff line change
Expand Up @@ -470,13 +470,13 @@ abspath(a::AbstractString, b::AbstractString...) = abspath(joinpath(a,b...))
if Sys.iswindows()

function longpath(path::AbstractString)
p = cwstring(path)
p = cwstring(abspath(path)) # GetLongPathNameW requires absolute paths
buf = zeros(UInt16, length(p))
while true
n = ccall((:GetLongPathNameW, "kernel32"), stdcall,
UInt32, (Ptr{UInt16}, Ptr{UInt16}, UInt32),
p, buf, length(buf))
windowserror(:longpath, n == 0)
windowserror(:longpath, n == 0, extrainfo=path)
x = n < length(buf) # is the buffer big enough?
resize!(buf, n) # shrink if x, grow if !x
x && return transcode(String, buf)
Expand Down
9 changes: 9 additions & 0 deletions test/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@ mktempdir() do dir
@test Base.isfile_casesensitive(true_filename)
@test !Base.isfile_casesensitive(lowered_filename)

# check that case-sensitivity is preserved for relative paths with ghost directories:
@test Base.isfile_casesensitive(joinpath("nonexistent", "..", true_filename))
@test !Base.isfile_casesensitive(joinpath("nonexistent", "..", lowered_filename))

# check that case-sensitivity is preserved for relative paths with real directories:
mkdir("realdir")
@test Base.isfile_casesensitive(joinpath("realdir", "..", true_filename))
@test !Base.isfile_casesensitive(joinpath("realdir", "..", lowered_filename))

# check that case-sensitivity only applies to basename of a path:
if isfile(lowered_filename) # case-insensitive filesystem
mkdir("cAsEtEsT")
Expand Down