Skip to content

Commit

Permalink
Merge pull request #78 from leoschwarz/normalize-paths
Browse files Browse the repository at this point in the history
Consistently normalize paths
  • Loading branch information
cpanse authored Oct 22, 2024
2 parents 484f00f + 9b4200a commit ea4b2e4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
13 changes: 8 additions & 5 deletions R/rawrr.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
system2("mono", "-V", stdout = TRUE)
}

.checkReaderFunctions <- function(rawfile = sampleFilePath()){
.checkReaderFunctions <- function(rawfile = sampleFilePath()){

message("checkings rawrr::readFileHeader ...")
start_time <- Sys.time()
Expand Down Expand Up @@ -53,10 +53,8 @@
}

.checkRawFile <- function(rawfile){
rawfile <- normalizePath(rawfile)

if (!file.exists(rawfile)){
msg <- sprintf("File '%s' is not available.", rawfile)
msg <- sprintf("File '%s' does not exist.", rawfile)
stop(msg)
}

Expand Down Expand Up @@ -87,7 +85,6 @@
function(rawfile, input, rawrrArgs="scans", tmpdir=tempdir(),
removeTempfile=TRUE){


mono <- if(Sys.info()['sysname'] %in% c("Darwin", "Linux")) TRUE else FALSE
exe <- .rawrrAssembly()

Expand Down Expand Up @@ -220,6 +217,7 @@ is.rawrrSpectrumSet <- function(x){
#' rawrr::sampleFilePath() |> readFileHeader()
readFileHeader <- function(rawfile){
.isAssemblyWorking()
rawfile <- normalizePath(rawfile)
.checkRawFile(rawfile)

e <- .rawrrSystem2Source(rawfile, input = NULL, rawrrArgs="headerR")
Expand Down Expand Up @@ -248,6 +246,7 @@ readFileHeader <- function(rawfile){
readIndex <- function (rawfile)
{
.isAssemblyWorking()
rawfile <- normalizePath(rawfile)
.checkRawFile(rawfile)
mono <- if (Sys.info()["sysname"] %in% c("Darwin", "Linux"))
TRUE
Expand Down Expand Up @@ -280,6 +279,7 @@ readIndex <- function (rawfile)
#' @return a vecntor of integer values.
filter <- function(rawfile, filter = "ms", precision = 10, tmpdir=tempdir()){
.isAssemblyWorking()
rawfile <- normalizePath(rawfile)
.checkRawFile(rawfile)
mono <- if(Sys.info()['sysname'] %in% c("Darwin", "Linux")) TRUE else FALSE
exe <- .rawrrAssembly()
Expand Down Expand Up @@ -578,6 +578,7 @@ sampleFilePath <- function(){
readSpectrum <- function(rawfile, scan = NULL, tmpdir = tempdir(),
validate = FALSE, mode = ''){
.isAssemblyWorking()
rawfile <- normalizePath(rawfile)
.checkRawFile(rawfile)

if (is.null(scan)){
Expand Down Expand Up @@ -772,6 +773,7 @@ readChromatogram <- function(rawfile,
tmpdir = tempdir()){

.isAssemblyWorking()
rawfile <- normalizePath(rawfile)
.checkRawFile(rawfile)

stopifnot(type %in% c('xic', 'bpc', 'tic'))
Expand Down Expand Up @@ -1582,6 +1584,7 @@ auc.rawrrChromatogram <- function(x){
#' rawrr::sampleFilePath() |> rawrr:::readTrailer("AGC:") |> head()
readTrailer <- function(rawfile, label = NULL) {
.isAssemblyWorking()
rawfile <- normalizePath(rawfile)
.checkRawFile(rawfile)

mono <- if(Sys.info()['sysname'] %in% c("Darwin", "Linux")) TRUE else FALSE
Expand Down
6 changes: 6 additions & 0 deletions inst/NEWS.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@

\newcommand{\ghit}{\href{https://github.com/fgcz/rawrr/issues/#1}{##1}}

\section{Changes in version 1.10.2 (Unreleased)}{
\itemize{
\item Consistently normalize paths \ghit{76}.
}
}

\section{Changes in version 1.10.1 (2023-11-02)}{
\itemize{
\item Fix index error \ghit{67}.
Expand Down

0 comments on commit ea4b2e4

Please sign in to comment.