From efa744c5840e8ea7521aa0955956411dfe30120f Mon Sep 17 00:00:00 2001 From: Samuel Fadel Date: Mon, 22 Aug 2016 02:02:36 -0300 Subject: Added util.R. --- util.R | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 util.R (limited to 'util.R') diff --git a/util.R b/util.R new file mode 100644 index 0000000..0a87079 --- /dev/null +++ b/util.R @@ -0,0 +1,15 @@ +# util.R +# +# Assorted utilities. + +# Creates a directory at given path, optionally logging the action. +# If it already exists, the directory is not created. +dir.create.safe <- function(path, log=T) { + if (!dir.exists(path)) { + if (log) { + loginfo("Creating directory: %s", path) + } + + dir.create(path) + } +} -- cgit v1.2.3