Skip to content

Commit bf11600

Browse files
committed
Fix for normalisation error spotted on CRAN Windows
* normalise the final output path as well as the inputs * error was -- 1. Failure: common_path works (@test-fsutils.r#79) ------------------------- common_path(c("/a", "/b"), normalise = T) not equal to np("/"). 1/1 mismatches x[1]: "d:/" y[1]: "D:/"
1 parent 7435f55 commit bf11600

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

R/fsutils.r

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,13 @@ common_path<-function(paths, normalise=FALSE, fsep=.Platform$file.sep) {
113113
diff_chunks=which(num_uniq_values!=1)
114114
first_diff_chunk=min(c(diff_chunks, maxlen+1))
115115
# paste the chunks upt to the first different fragment
116-
paste(m[seq_len(first_diff_chunk-1), 1], collapse="")
116+
outpath=paste(m[seq_len(first_diff_chunk-1), 1], collapse="")
117+
# renormalise path to overcome subtle issue on Windows
118+
# where normalisation gives different values for e.g. C:\
119+
# when it is part of a longer path than when it is on its own
120+
if(normalise)
121+
normalizePath(outpath, mustWork = F, winslash = fsep)
122+
else outpath
117123
}
118124

119125

0 commit comments

Comments
 (0)