@@ -248,16 +248,15 @@ function splitpath(p::String)
248
248
return out
249
249
end
250
250
251
- joinpath (path:: AbstractString ):: String = path
252
-
253
251
if Sys. iswindows ()
254
252
255
- function joinpath (path:: AbstractString , paths:: AbstractString... ):: String
256
- result_drive, result_path = splitdrive (path)
253
+ function joinpath (paths:: Union{NTuple{n,<:AbstractString} where n, AbstractVector{<:AbstractString}} ):: String
254
+ isempty (paths) && return path_separator
255
+ result_drive, result_path = splitdrive (paths[1 ])
257
256
258
- local p_drive, p_path
259
- for p in paths
260
- p_drive, p_path = splitdrive (p )
257
+ p_path = " "
258
+ for i in firstindex ( paths) + 1 : lastindex (paths)
259
+ p_drive, p_path = splitdrive (paths[i] )
261
260
262
261
if startswith (p_path, (' \\ ' , ' /' ))
263
262
# second path is absolute
293
292
294
293
else
295
294
296
- function joinpath (path:: AbstractString , paths:: AbstractString... ):: String
297
- for p in paths
295
+ function joinpath (paths:: Union{NTuple{n,<:AbstractString} where n, AbstractVector{<:AbstractString}} ):: String
296
+ isempty (paths) && return path_separator
297
+ path = paths[1 ]
298
+ for i in firstindex (paths)+ 1 : lastindex (paths)
299
+ p = paths[i]
298
300
if isabspath (p)
299
301
path = p
300
302
elseif isempty (path) || path[end ] == ' /'
308
310
309
311
end # os-test
310
312
313
+ """
314
+ joinpath(parts) -> String
315
+
316
+ Join collection of path components into a full path. If some argument is an absolute path or
317
+ (on Windows) has a drive specification that doesn't match the drive computed for
318
+ the join of the preceding paths, then prior components are dropped.
319
+
320
+ Note on Windows since there is a current directory for each drive, `joinpath("c:", "foo")`
321
+ represents a path relative to the current directory on drive "c:" so this is equal to "c:foo",
322
+ not "c:\\ foo". Furthermore, `joinpath` treats this as a non-absolute path and ignores the drive
323
+ letter casing, hence `joinpath("C:\\ A","c:b") = "C:\\ A\\ b"`.
324
+
325
+ # Examples
326
+ ```jldoctest
327
+ julia> joinpath(["/home/myuser", "example.jl"])
328
+ "/home/myuser/example.jl"
329
+ julia> joinpath(())
330
+ "$(path_separator) "
331
+ ```
332
+ """
333
+ joinpath
334
+
311
335
"""
312
336
joinpath(parts::AbstractString...) -> String
313
337
@@ -326,7 +350,8 @@ julia> joinpath("/home/myuser", "example.jl")
326
350
"/home/myuser/example.jl"
327
351
```
328
352
"""
329
- joinpath
353
+ joinpath (path:: AbstractString ):: String = path
354
+ joinpath (path:: AbstractString , paths:: AbstractString... ):: String = joinpath ((path, paths... ))
330
355
331
356
"""
332
357
normpath(path::AbstractString) -> String
0 commit comments