From e74fd33703df54e35936308b71f4da00a7f5d85f Mon Sep 17 00:00:00 2001 From: Elliot Saba Date: Tue, 16 Oct 2012 14:14:01 -0700 Subject: [PATCH 1/2] Replace multiple contiguous forward-slash characters with a single one, so that naive functions such as split_path don't end up with empty substrings in their pathnames --- base/file.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/file.jl b/base/file.jl index d9ca369d52056..578032c450fc1 100644 --- a/base/file.jl +++ b/base/file.jl @@ -68,7 +68,7 @@ function fileparts(filename::String) end function file_path(components...) - join(components, os_separator) + replace(join(components, os_separator), r"/+", "/") end function fullfile(pathname::String, basename::String, ext::String) From 07bd6bf2f995ea38b33f33714e2cb10901a5e8fa Mon Sep 17 00:00:00 2001 From: Elliot Saba Date: Tue, 16 Oct 2012 15:08:37 -0700 Subject: [PATCH 2/2] Switch up to using abs_path(), also incorporate in a few other functions --- base/file.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/base/file.jl b/base/file.jl index 578032c450fc1..4849ca6d7015e 100644 --- a/base/file.jl +++ b/base/file.jl @@ -59,7 +59,7 @@ function split_extension(path::String) end end -split_path(path::String) = split(path, os_separator_match) +split_path(path::String) = split(abs_path(path), os_separator_match) function fileparts(filename::String) pathname, filestr = dirname_basename(filename) @@ -68,14 +68,14 @@ function fileparts(filename::String) end function file_path(components...) - replace(join(components, os_separator), r"/+", "/") + abs_path(join(components, os_separator)) end function fullfile(pathname::String, basename::String, ext::String) if isempty(pathname) - return basename * ext + return abs_path(basename * ext) else - return pathname * os_separator * basename * ext + return abs_path(pathname * os_separator * basename * ext) end end