
cat.char <- function(char) {
  # arrays of strings are very annoying
  # cat.char converts an array of strings into one long string with line-feeds

  cum <- NULL
  
  for(i in 1:length(char)) {
    if(i==1) cum <- sprintf("%s\n", char[1])
    else cum <- sprintf("%s%s\n", cum, char[i])
  }
  
  return(cum)
}

cat.file <- function(file) {
  # cat.file returns the contents of a file as a string
  
  content <- NULL
  f1 <- file.info(file)
  
  if(!is.na(f1$size) & !f1$isdir & f1$size>0) {
    f1 <- file(file, open="r")

    if(isOpen(f1)) {
      content <- readLines(f1)

      close(f1)
    }
  }

  return(cat.char(content))
}

## open.file <- function(file) {
  
##   content <- NULL
##   f1 <- NULL
  
##   f1 <- file(file, open="r")

##   if(isOpen(f1)) {
##     content <- readLines(f1)

##     close(f1)
##   }

##   return(content)
## }

