Skip to content

Commit 3c95d0a

Browse files
committed
fix #420
1 parent 53745ae commit 3c95d0a

3 files changed

Lines changed: 52 additions & 1 deletion

File tree

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export(geoflow_validator_entity_Type)
6363
export(geoflow_vocabulary)
6464
export(getDBTableColumnComment)
6565
export(getDBTableComment)
66+
export(get_absolute_path)
6667
export(get_config_resource_path)
6768
export(get_epsg_code)
6869
export(get_line_separator)

R/geoflow_utils.R

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ dotenv_parse_dot_line <- function (line) {
585585
#' @export
586586
unload_workflow_environment <- function(config){
587587
env_vars_workflow <- as.list(Sys.getenv())
588-
envfile <- config$profile_config$environment$file
588+
envfile <- get_absolute_path(config$profile_config$environment$file, base = config$wd)
589589
if(!is.null(envfile)){
590590
tmp <- readLines(envfile)
591591
tmp <- dotenv_ignore_comments(tmp)
@@ -622,6 +622,32 @@ is_absolute_path <- function(path) {
622622
grepl("^(/|[A-Za-z]:|\\\\|~)", path)
623623
}
624624

625+
#' @name get_absolute_path
626+
#' @aliases get_absolute_path
627+
#' @title get_absolute_path
628+
#' @description \code{get_absolute_path} allows to get the absolute path of a resource
629+
#' given a base directory
630+
#'
631+
#' @usage get_absolute_path(path, base, mustWork, expand_tilde)
632+
#'
633+
#' @param path a path in character string
634+
#' @param base a base direcotry
635+
#' @param mustWork must work?
636+
#' @param expand_tilde expand tilde?
637+
#'
638+
#' @author Emmanuel Blondel, \email{emmanuel.blondel1@@gmail.com}
639+
#' @export
640+
get_absolute_path <- function(path, base = getwd(), mustWork = FALSE, expand_tilde = TRUE) {
641+
path <- as.character(path)
642+
base <- as.character(base)[1L]
643+
if (expand_tilde) {
644+
path <- ifelse(startsWith(path, "~"), path.expand(path), path)
645+
base <- path.expand(base)
646+
}
647+
combined <- ifelse(is_absolute_path(path), path, file.path(base, path))
648+
normalizePath(combined, winslash = "/", mustWork = mustWork)
649+
}
650+
625651
#'@name get_union_bbox
626652
#'@aliases get_union_bbox
627653
#'@title get_union_bbox

man/get_absolute_path.Rd

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)