#' Convert a Windows path to a forward-slash path
#'
#' Replaces backslashes with forward slashes so that Windows-style paths can be
#' used consistently across platforms.
#'
#' @param path A character vector of file paths.
#'
#' @return A character vector of the same length with backslashes replaced by
#'   forward slashes.
#'
#' @examples
#' windows_to_linux_path("C:\\data\\EXP99\\raw.txt")
#'
#' @export
windows_to_linux_path <- function(path) {
  gsub("\\\\", "/", path)
}

#' Sanitise a string for use as a file name
#'
#' Removes newlines and characters that are illegal in file names on common
#' operating systems, so that drug names or plate labels can be turned into safe
#' output file names.
#'
#' @param filename_str A character vector of candidate file names.
#'
#' @return A character vector with newlines removed, `/` and `:` replaced by
#'   `_` and `-` respectively, and the characters `* ? " < > |` stripped.
#'
#' @examples
#' clean_filename("Drug A/B: 10\u00b5M?")
#'
#' @export
clean_filename <- function(filename_str) {
  filename_str <- gsub("\n", "", filename_str)
  filename_str <- gsub("/", "_", filename_str)
  filename_str <- gsub(":", "-", filename_str)
  gsub("[*?\"<>|]", "", filename_str)
}
