Skip to content

Commit

Permalink
correct winslash in base_path()
Browse files Browse the repository at this point in the history
  • Loading branch information
mjaeugster committed Jul 26, 2011
1 parent 662b3c6 commit 69006f9
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions R/roclet-collate.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ collate_roclet <- function() {
#' @S3method roc_process collate
roc_process.collate <- function(roclet, partita, base_path) {
topo <- topo_sort()

for (partitum in partita) {
file <- base_path(partitum$srcref$filename, base_path)
vertex <- topo$add(file)

includes <- partitum[names(partitum) == "include"]
if (length(includes) > 0) {
for (include in includes) {
Expand All @@ -48,24 +48,24 @@ roc_process.collate <- function(roclet, partita, base_path) {

unique(basename(topo$sort()))
}

#' @S3method roc_output collate
roc_output.collate <- function(roclet, results, base_path) {
DESCRIPTION <- file.path(base_path, "DESCRIPTION")
old <- read.description(DESCRIPTION)
new <- old
new$Collate <- str_c("'", results, "'", collapse = " ")
write.description(new, DESCRIPTION)

if (!identical(old, read.description(DESCRIPTION))) {
cat('Updating collate directive in ', DESCRIPTION, "\n")
}
}
}

base_path <- function(path, base) {
path <- normalizePath(path)
base <- normalizePath(base)
path <- normalizePath(path, winslash = "/")
base <- normalizePath(base, winslash = "/")

str_replace(path, fixed(str_c(base, "/")), "")
}

3 comments on commit 69006f9

@Sharpie
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this commit is the single change that breaks compatibility with R 2.12.0. Why is it needed?

@mjaeugster
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, because it simplifies the next line in the code, where we remove the base from the path---ie we don't have to check what is the separator of the path.

@hadley
Copy link
Member

@hadley hadley commented on 69006f9 Jan 27, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could use .Platform$file.sep in the following line instead?

Please sign in to comment.