Index: common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.951
diff -u -p -r1.951 common.inc
--- common.inc	31 Jul 2009 19:56:09 -0000	1.951
+++ common.inc	1 Aug 2009 11:36:46 -0000
@@ -4732,6 +4732,50 @@ function drupal_parse_info_file($filenam
 }
 
 /**
+ * Gernerates an info file that can be parsed by drupal_parse_info_file.
+ *
+ * @param array $info_array what is returned from drupal_parse_info_file()
+ * @return string
+ */
+function drupal_info_file_to_string($info_array) {
+  $output = "";
+  foreach ($info_array as $key => $value) {
+    if (is_array($value)) {
+      $output .= "\n";
+      $output .= drupal_info_block_to_string($value, $key);
+    }
+    else {
+      $output .= sprintf("%s = '%s'\n", $key, str_replace("'", "\'", $value));
+    }
+  }
+  return $output;
+}
+
+/**
+ * Helper function for drupal_info_file_to_string.
+ * @see drupal_info_file_to_string
+ *
+ * @param array $block Configuration block to write.
+ * @param string $prefix A string to prefix each entry with.
+ * @return string
+ */
+function drupal_info_block_to_string($block, $prefix) {
+  $output = '';
+  $is_assoc = array_keys($block) !== range(0, count($block) - 1);
+  foreach ($block as $key => $value) {
+    if (!$is_assoc) {
+      $key = ''; // Wipe out the key if this is an iterative array.
+    }
+    if (is_array($value)) {
+      $output .= drupal_info_block_to_string($value, $prefix . "[$key]");
+    }
+    else {
+      $output .= sprintf("%s[%s] = '%s'\n", $prefix, $key, str_replace("'", "\'", $value));
+    }
+  }
+  return $output;
+}
+/**
  * Severity levels, as defined in RFC 3164: http://www.ietf.org/rfc/rfc3164.txt.
  *
  * @return
