R/getConquestVersion.R

getConquestVersion <- function ( path.conquest, path.temp = NULL, asDate = TRUE ) {
    if( is.null (path.temp) ) {path.temp <- getwd()}
		wd <- path.temp
		f <- file.path ( wd , "delete.cqc" )
		if ( file.create ( f, showWarnings = TRUE ) ) {
		
				write ( "quit;" , f )
				
				f <- normalizePath ( f )
				path.conquest <- normalizePath ( path.conquest )
				cmd <- paste ( '"' , path.conquest , '"' , " " , '"' , f , '"' , sep = "" )
				r <- NULL
				ow <- getOption ( "warn" )
				options ( warn = -1 )
				try ( r <- system ( command = cmd , intern = TRUE ) , silent = TRUE )
				options ( warn = ow )
				
				file.remove ( f )
				
				if ( !is.null ( r ) ) {
				
						r <- r[1]

						r <- sub ( "ConQuest build: " , "" , r )

						r <- gsub ( "\\s+" , "-" , r )
						
						if ( asDate ) {
								r <- as.date(r)
								if ( is.na ( r ) ) r <- NULL
						}
						
				}

		} else {
				r <- NULL
		}
		
		return (r)

}

Try the eatRest package in your browser

Any scripts or data that you put into this service are public.

eatRest documentation built on May 2, 2019, 6:25 p.m.