diff --git a/RBBGCMuso/R/assistantFunctions.R b/RBBGCMuso/R/assistantFunctions.R index a86ce87..f7af06c 100644 --- a/RBBGCMuso/R/assistantFunctions.R +++ b/RBBGCMuso/R/assistantFunctions.R @@ -45,7 +45,7 @@ getOutFiles <- function(outputLoc, outputNames){ return(grep("out$", grep(paste(paste0(outputNames, "*"), collapse = "|"), list.files(outputLoc), value=TRUE), value = TRUE)) } -#' getOutFiles +#' stampAndCopy #' #'This function gives us the muso output files with their paths #' @@ -54,9 +54,22 @@ getOutFiles <- function(outputLoc, outputNames){ #'@return Output files with their paths #'@keywords internal -stampAndCopyDir <- function(outputLoc,names,stampDir, stampnum=NULL){ - if(!is.null(stampnum)){file.copy(file.path(outputLoc,names) - ,file.path(stampDir,paste0((stampnum+1),"-",possibleNames))) - } else{file.copy(file.path(outputLoc,names) - ,file.path(stampDir,paste0((stamp(stampDir)+1),"-",possibleNames)))} +stampAndDir <- function(outputLoc,names,stampDir, wrongDir, type="output", errorsign){ + + switch(type, + "output" = ( + file.copy(file.path(outputLoc,names) + ,file.path(stampDir,paste0((stamp(stampDir)+1),"-",names))) ), + "epc" = (function (){ + stampnum <- stamp(stampDir) + lapply(names,function (x) file.copy(from = x ,to=paste(stampDir,"/",(stampnum+1),"-", basename(x),sep=""))) + if(errorsign==1){ + lapply(names, function (x) file.copy(from = paste(stampDir,"/",(stampnum+1),"-",basename(x),sep=""), to=wrongDir))}})(), + "log" = ( + file.rename(names + ,file.path(stampDir,paste0((stamp(stampDir)+1),"-",basename(names)))) + ) + ) + } + diff --git a/RBBGCMuso/R/calibMuso.R b/RBBGCMuso/R/calibMuso.R index c278a7d..725dba6 100644 --- a/RBBGCMuso/R/calibMuso.R +++ b/RBBGCMuso/R/calibMuso.R @@ -179,8 +179,7 @@ calibMuso <- function(settings,parameters=NULL, timee="d", debugging=FALSE, logf if(keepBinary){ possibleNames <- getOutFiles(outputLoc = outputLoc,outputNames = outputNames) - file.copy(file.path(outputLoc,possibleNames) - ,file.path(binaryPlace,paste0((stamp(binaryPlace)+1),"-",possibleNames))) + stampAndDir(outputLoc = outputLoc,names = possibleNames,stampDir=binaryPlace,type="output") } } @@ -219,12 +218,7 @@ calibMuso <- function(settings,parameters=NULL, timee="d", debugging=FALSE, logf stop("Why are you playing with my nervs? Seriously? You hold your epc-s in different folders?") } else { - ## epcfiles <- list.files(epcdir)[grep("epc$",list.files( - stampnum<-stamp(EPCS) - lapply(epc,function (x) file.copy(from = x ,to=paste(EPCS,"/",(stampnum+1),"-", basename(x),sep=""))) - if(errorsign==1){ - lapply(epc, function (x) file.copy(from = paste(EPCS,"/",(stampnum+1),"-",basename(x),sep=""), to=WRONGEPC)) - } + stampAndDir(stampDir=EPCS,wrongDir=WRONGEPC,names=epc,type="epc",errorsig=errorsign) } } diff --git a/forarcheologists b/forarcheologists index e5bc2fa..f4d7932 100644 --- a/forarcheologists +++ b/forarcheologists @@ -295,4 +295,13 @@ getyearlyout<-function(settings){ ## } ## } - \ No newline at end of file + ## file.copy(file.path(outputLoc,possibleNames) + ## ,file.path(binaryPlace,paste0((stamp(binaryPlace)+1),"-",possibleNames))) + + + ## epcfiles <- list.files(epcdir)[grep("epc$",list.files( + ## stampnum<-stamp(EPCS) + ## lapply(epc,function (x) file.copy(from = x ,to=paste(EPCS,"/",(stampnum+1),"-", basename(x),sep=""))) + ## if(errorsign==1){ + ## lapply(epc, function (x) file.copy(from = paste(EPCS,"/",(stampnum+1),"-",basename(x),sep=""), to=WRONGEPC)) + ## } \ No newline at end of file