Index: devel_themer.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/devel/devel_themer.module,v
retrieving revision 1.32.2.23
diff -u -r1.32.2.23 devel_themer.module
--- devel_themer.module	22 Apr 2009 19:22:49 -0000	1.32.2.23
+++ devel_themer.module	30 May 2009 19:56:26 -0000
@@ -486,6 +486,38 @@
   return array($output, $meta);
 }
 
+/**
+ * Clean up the files we dropped in the temp dir in devel_themer_exit().
+ *
+ * Limitation: one more devel_themer_exit() will run after this function is
+ * called and drop one more file, since hook_exit() is called after the normal
+ * page cycle.
+ *
+ * @return
+ *   void.
+ */
+function devel_themer_cleanup() {
+  $tmp_dir = file_directory_temp();
+  foreach (new DirectoryIterator($tmp_dir) as $file_info) {
+    if ($file_info->isDot()) {
+      continue;
+    }
+    if (strpos($file_info->getFilename(), 'devel_themer_') === 0) {
+      file_delete($tmp_dir .'/'. $file_info->getFilename());
+    }
+  }
+}
+
+/**
+ * Implement hook_cron() for periodic cleanup.
+ * 
+ * @return
+ *   void.
+ */
+function devel_cron() {
+  devel_themer_cleanup();
+}
+
 // We save the huge js array here instead of hook_footer so we can catch theme('page')
 function devel_themer_exit() {
   if (!empty($GLOBALS['devel_theme_calls']) && $_SERVER['REQUEST_METHOD'] != 'POST') {

