From 2e2542e2eec036d64ef01169c9ccd9f392599274 Mon Sep 17 00:00:00 2001 From: Carraro Date: Wed, 24 Apr 2024 14:05:04 +0200 Subject: [PATCH] disable non-ASCII paths --- DESCRIPTION | 2 +- NEWS.md | 4 ++++ R/aread8.R | 5 +++++ R/d8flowdir.R | 5 +++++ R/moveoutletstostrm.R | 6 ++++++ R/pitremove.R | 5 +++++ R/threshold.R | 5 +++++ 7 files changed, 31 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index d40788c..970c9d1 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: traudem Title: Use TauDEM -Version: 1.0.2 +Version: 1.0.3 Authors@R: c( person("Luca", "Carraro", , "Luca.Carraro@eawag.ch", role = c("cre", "aut")), person("University of Zurich", role = c("cph", "fnd")), diff --git a/NEWS.md b/NEWS.md index 5807f09..63dd54b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# traudem 1.0.3 + +* An error is thrown if path files containing non-ASCII characters are used. + # traudem 1.0.2 * Updated documentation on workflow to install `traudem` in macOS and Linux. diff --git a/R/aread8.R b/R/aread8.R index 58d9a8e..0e8f65b 100644 --- a/R/aread8.R +++ b/R/aread8.R @@ -62,6 +62,11 @@ taudem_aread8 <- function(input_d8flowdir_grid, rlang::abort("outlet_layer_name and outlet_layer_number must not both be specified.") } + if (grepl("[^ -~]", input_d8flowdir_grid) | grepl("[^ -~]", output_contributing_area_grid)){ + rlang::abort("The path file and/or the working directory contain(s) non-ASCII + characters, which are not supported by MPI.") + } + args <- c( "-p", input_d8flowdir_grid, "-ad8", output_contributing_area_grid diff --git a/R/d8flowdir.R b/R/d8flowdir.R index 66d0eba..edc33f3 100644 --- a/R/d8flowdir.R +++ b/R/d8flowdir.R @@ -45,6 +45,11 @@ taudem_d8flowdir <- function(input_elevation_grid, output_d8slopes_grid <- sprintf("%s.tif", output_d8slopes_grid_file) } + if (grepl("[^ -~]", input_elevation_grid) | grepl("[^ -~]", output_d8flowdir_grid)){ + rlang::abort("The path file and/or the working directory contain(s) non-ASCII + characters, which are not supported by MPI.") + } + args <- c( "-fel", input_elevation_grid, "-p", output_d8flowdir_grid, diff --git a/R/moveoutletstostrm.R b/R/moveoutletstostrm.R index 53b1b92..f81ccf0 100644 --- a/R/moveoutletstostrm.R +++ b/R/moveoutletstostrm.R @@ -58,6 +58,12 @@ taudem_moveoutletstostream <- function(input_d8flowdir_grid, "moveoutletstostrm" } + if (grepl("[^ -~]", input_d8flowdir_grid) | grepl("[^ -~]", input_stream_raster_grid) | + grepl("[^ -~]",output_moved_outlets_file)){ + rlang::abort("The path file and/or the working directory contain(s) non-ASCII + characters, which are not supported by MPI.") + } + args <- c( "-p", input_d8flowdir_grid, "-src", input_stream_raster_grid, diff --git a/R/pitremove.R b/R/pitremove.R index 799a911..8fc2881 100644 --- a/R/pitremove.R +++ b/R/pitremove.R @@ -42,6 +42,11 @@ taudem_pitremove <- function(input_elevation_grid, rlang::abort(sprintf("Can't find file %s (depmask)", depmask)) } + if (grepl("[^ -~]", input_elevation_grid) | grepl("[^ -~]", output_elevation_grid)){ + rlang::abort("The path file and/or the working directory contain(s) non-ASCII + characters, which are not supported by MPI.") + } + args <- c( "-z", input_elevation_grid, "-fel", output_elevation_grid diff --git a/R/threshold.R b/R/threshold.R index 7489bea..f614289 100644 --- a/R/threshold.R +++ b/R/threshold.R @@ -48,6 +48,11 @@ taudem_threshold <- function(input_area_grid, rlang::abort(sprintf("Can't find file %s (mask_file)", mask_file)) } + if (grepl("[^ -~]", input_area_grid) | grepl("[^ -~]", output_stream_raster_grid)){ + rlang::abort("The path file and/or the working directory contain(s) non-ASCII + characters, which are not supported by MPI.") + } + args <- c( "-ssa", input_area_grid, "-src", output_stream_raster_grid,