Browse code

first attempt to solve the Windows-specific issue with backslash

Christian Arnold authored on 21/03/2022 20:57:18
Showing1 changed files

  • R/core.R index f1302ed..47c8cbc 100755
... ...
@@ -24,6 +24,7 @@ initializeGRN <- function(objectMetadata = list(),
24 24
   if (!dir.exists(outputFolder)) {
25 25
     dir.create(outputFolder)
26 26
   }
27
+  
27 28
   # Create an absolute path out of the given outputFolder now that it exists
28 29
   outputFolder = tools::file_path_as_absolute(outputFolder)
29 30
   checkmate::assertDirectory(outputFolder, access = "w")
... ...
@@ -4132,6 +4133,13 @@ getGRNConnections <- function(GRN, type = "all.filtered",  permuted = FALSE, inc
4132 4133
     }
4133 4134
   } else {
4134 4135
     
4136
+    # TODO: Re-create the output folder here nd adjust to the OS-specific path separator, do not rely on what is stored in the object
4137
+    if (.Platform$OS.type == "windows") {
4138
+      GRN@config$directories$output_plots = gsub('/', ('\\'), GRN@config$directories$output_plots, fixed = TRUE)
4139
+    } else {
4140
+      GRN@config$directories$output_plots = gsub("\\", "/", GRN@config$directories$output_plots, fixed = TRUE)
4141
+    }
4142
+    
4135 4143
     if (!dir.exists(GRN@config$directories$output_plots)) {
4136 4144
       dir.create(GRN@config$directories$output_plots, recursive = TRUE)
4137 4145
     }
... ...
@@ -4371,8 +4379,8 @@ getBasic_metadata_visualization <- function(GRN, forceRerun = FALSE) {
4371 4379
 changeOutputDirectory <- function(GRN, outputDirectory = ".") {
4372 4380
   
4373 4381
   GRN@config$directories$outputRoot   =  outputDirectory
4374
-  GRN@config$directories$output_plots = paste0(outputDirectory, "/plots/")
4375
-  GRN@config$files$output_log         = paste0(outputDirectory, "GRN.log")
4382
+  GRN@config$directories$output_plots = paste0(outputDirectory, .Platform$file.sep, "plots", .Platform$file.sep)
4383
+  GRN@config$files$output_log         = paste0(outputDirectory, .Platform$file.sep, "GRN.log")
4376 4384
     
4377 4385
   futile.logger::flog.info(paste0("Output directory changed in the object to " , outputDirectory))
4378 4386