fully working and more elegant cleanupMuso

This commit is contained in:
hollorol 2017-09-02 01:21:40 +02:00
parent 0ecb54aaf7
commit b6f1ae16b1

View File

@ -12,48 +12,44 @@
cleanupMuso <- function(location=NULL, simplicity=TRUE,deep=FALSE){ cleanupMuso <- function(location=NULL, simplicity=TRUE,deep=FALSE){
if(is.null(location)){
whereAmI <- getwd() location<-"./"
if(!is.null(location)){
setwd(location)
} }
logDir<-file.path2(location,"LOG")
errDir<-file.path2(location,"ERROR")
epcDir<-file.path2(location,"EPCS")
wroDir<-file.path2(location,"WRONGEPC")
if(deep){ if(deep){
if(dir.exists(logDir)){
if(dir.exists(paste(location,"/LOG",sep=""))){
file.remove( file.remove(
list.files("LOG/",pattern="(out$)|(endpoint$)|(log$)", full.names=TRUE) list.files(logDir,pattern="(out$)|(endpoint$)|(log$)", full.names=TRUE)
) )
} }
if(dir.exists("ERROR")){ if(dir.exists(errDir)){
file.remove( file.remove(
list.files("ERROR/",pattern="(out$)|(endpoint$)|(log$)", full.names=TRUE)) list.files(errDir,pattern="(out$)|(endpoint$)|(log$)", full.names=TRUE))
} }
if(dir.exists("EPCS")){ if(dir.exists(epcDir)){
file.remove( file.remove(
list.files("EPCS/",pattern="(out$)|(endpoint$)|(log$)", full.names=TRUE)) list.files(epcDir,pattern="(out$)|(endpoint$)|(log$)", full.names=TRUE))
} }
if(dir.exists("WRONGEPC")){ if(dir.exists(wroDir)){
file.remove( file.remove(
list.files("WRONGEPC/",pattern="(out$)|(endpoint$)|(log$)", full.names=TRUE)) list.files(wroDir,pattern="(out$)|(endpoint$)|(log$)", full.names=TRUE))
} }
file.remove(list.files(pattern="(out$)|(endpoint$)|(log$)",full.names=TRUE))} file.remove(list.files(location, pattern="(out$)|(endpoint$)|(log$)",full.names=TRUE))}
if(!simplicity){ if(!simplicity){
file.remove( file.remove(list.files(location, pattern="(out$)|(endpoint$)|(log$)",full.names=TRUE))
grep("(out$)|(endpoint$)|(log$)", } else {
list.files(), value = T) file.remove(list.files(location, pattern="log$",full.names=TRUE))}
)} else {
file.remove(grep("log$",list.files(),value = T))
}
setwd(whereAmI)
} }