aboutsummaryrefslogtreecommitdiff
path: root/util.R
diff options
context:
space:
mode:
Diffstat (limited to 'util.R')
-rw-r--r--util.R15
1 files changed, 15 insertions, 0 deletions
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)
+ }
+}