Browse code

Remove temporary file on exit

Peter Hickey authored on 04/07/2018 13:36:07
Showing1 changed files

... ...
@@ -99,10 +99,8 @@
99 99
         message(
100 100
             "[.readBismarkAsDT] Gunzipping file '", file, "' to tempfile().")
101 101
 
102
-        file <- gunzip(
103
-            filename = file,
104
-            destname = tempfile(),
105
-            remove = FALSE)
102
+        file <- gunzip(filename = file, destname = tempfile(), remove = FALSE)
103
+        on.exit(unlink(file), add = TRUE)
106 104
     }
107 105
     # sysname <- Sys.info()[["sysname"]]
108 106
     # if (sysname == "Linux") {