Creating an extended file path concatenator function
This commit is contained in:
parent
ea8fac69e4
commit
0ecb54aaf7
@ -3,6 +3,7 @@
|
|||||||
export(calibMuso)
|
export(calibMuso)
|
||||||
export(cleanupMuso)
|
export(cleanupMuso)
|
||||||
export(corrigMuso)
|
export(corrigMuso)
|
||||||
|
export(file.path2)
|
||||||
export(getyearlycum)
|
export(getyearlycum)
|
||||||
export(getyearlymax)
|
export(getyearlymax)
|
||||||
export(musoDate)
|
export(musoDate)
|
||||||
|
|||||||
@ -11,59 +11,40 @@
|
|||||||
|
|
||||||
|
|
||||||
cleanupMuso <- function(location=NULL, simplicity=TRUE,deep=FALSE){
|
cleanupMuso <- function(location=NULL, simplicity=TRUE,deep=FALSE){
|
||||||
areThereAnyFolders <- FALSE
|
|
||||||
|
|
||||||
whereAmI <- getwd()
|
whereAmI <- getwd()
|
||||||
if(!is.null(location)){
|
if(!is.null(location)){
|
||||||
setwd(location)
|
setwd(location)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(deep){
|
if(deep){
|
||||||
if(dir.exists("LOG")){
|
|
||||||
setwd("LOG")
|
|
||||||
|
|
||||||
|
if(dir.exists(paste(location,"/LOG",sep=""))){
|
||||||
file.remove(
|
file.remove(
|
||||||
grep("(out$)|(endpoint$)|(log$)",
|
list.files("LOG/",pattern="(out$)|(endpoint$)|(log$)", full.names=TRUE)
|
||||||
list.files(), value = T))
|
)
|
||||||
areThereAnyFolders <- TRUE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(dir.exists("ERROR")){
|
||||||
if(dir.exists("../ERROR")){
|
|
||||||
setwd("../ERROR")
|
|
||||||
|
|
||||||
file.remove(
|
file.remove(
|
||||||
grep("(out$)|(endpoint$)|(log$)",
|
list.files("ERROR/",pattern="(out$)|(endpoint$)|(log$)", full.names=TRUE))
|
||||||
list.files(), value = T))
|
|
||||||
areThereAnyFolders <- TRUE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(dir.exists("EPCS")){
|
||||||
if(dir.exists("../EPCS")){
|
|
||||||
setwd("../EPCS")
|
|
||||||
|
|
||||||
file.remove(
|
file.remove(
|
||||||
grep("(out$)|(endpoint$)|(log$)|(epc$)",
|
list.files("EPCS/",pattern="(out$)|(endpoint$)|(log$)", full.names=TRUE))
|
||||||
list.files(), value = T))
|
|
||||||
areThereAnyFolder <- TRUE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(dir.exists("../WRONGEPC")){
|
if(dir.exists("WRONGEPC")){
|
||||||
setwd("../WRONGEPC")
|
|
||||||
file.remove(
|
file.remove(
|
||||||
grep("(out$)|(endpoint$)|(log$)|(epc$)",
|
list.files("WRONGEPC/",pattern="(out$)|(endpoint$)|(log$)", full.names=TRUE))
|
||||||
list.files(), value = T))
|
|
||||||
areThereAnyFolders <- TRUE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(areThereAnyFolders){
|
file.remove(list.files(pattern="(out$)|(endpoint$)|(log$)",full.names=TRUE))}
|
||||||
setwd("..")
|
|
||||||
file.remove(
|
|
||||||
grep("(out$)|(endpoint$)|(log$)",
|
|
||||||
list.files(), value = T))
|
|
||||||
} else {
|
|
||||||
file.remove(
|
|
||||||
grep("(out$)|(endpoint$)|(log$)",
|
|
||||||
list.files(), value = T))}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!simplicity){
|
if(!simplicity){
|
||||||
file.remove(
|
file.remove(
|
||||||
|
|||||||
@ -113,3 +113,23 @@ corrigMuso <- function(settings, data){
|
|||||||
}
|
}
|
||||||
return(data)
|
return(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#' file.path2
|
||||||
|
#'
|
||||||
|
#' It is an extended file.path function, it can concatenate path where the first ends and the second begins with "/", so
|
||||||
|
#' there wont be two slash nearby eachother
|
||||||
|
#' @author Roland Hollos
|
||||||
|
#' @param str1 This is the first path string
|
||||||
|
#' @param str2 This is the second path string
|
||||||
|
#' @return A concatenated path
|
||||||
|
#' @export
|
||||||
|
#' @usage file.path2(str1, str2)
|
||||||
|
|
||||||
|
file.path2<-function(str1, str2){
|
||||||
|
str1<-file.path(dirname(str1),basename(str1))
|
||||||
|
if(substring(str2,1,1)=="/"){
|
||||||
|
return(paste(str1,str2,sep=""))
|
||||||
|
} else{
|
||||||
|
return(file.path(str1,str2))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
23
RBBGCMuso/man/file.path2.Rd
Normal file
23
RBBGCMuso/man/file.path2.Rd
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
% Generated by roxygen2: do not edit by hand
|
||||||
|
% Please edit documentation in R/otherUsefullFunctions.R
|
||||||
|
\name{file.path2}
|
||||||
|
\alias{file.path2}
|
||||||
|
\title{file.path2}
|
||||||
|
\usage{
|
||||||
|
file.path2(str1, str2)
|
||||||
|
}
|
||||||
|
\arguments{
|
||||||
|
\item{str1}{This is the first path string}
|
||||||
|
|
||||||
|
\item{str2}{This is the second path string}
|
||||||
|
}
|
||||||
|
\value{
|
||||||
|
A concatenated path
|
||||||
|
}
|
||||||
|
\description{
|
||||||
|
It is an extended file.path function, it can concatenate path where the first ends and the second begins with "/", so
|
||||||
|
there wont be two slash nearby eachother
|
||||||
|
}
|
||||||
|
\author{
|
||||||
|
Roland Hollos
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user