diff -urN api.admin.inc api.admin.inc
--- api.admin.inc	2009-01-28 22:24:01.000000000 +0100
+++ api.admin.inc	2009-05-05 01:14:39.000000000 +0200
@@ -75,6 +75,7 @@
     $branch->branch_name = '';
     $branch->title = '';
     $branch->directory = '';
+    $branch->exclude_dirs = '';
   }
   else {
     $branch = $branches[$branch_name];
@@ -101,6 +102,13 @@
     '#description' => t('Absolute paths to index, one per line.'),
     '#required' => TRUE,
   );
+  $form['exclude_dirs'] = array(
+    '#title' => t('Excluded directories'),
+    '#type' => 'textarea',
+    '#default_value' => $branch->exclude_dirs,
+    '#rows' => 3,
+    '#description' => t('Absolute paths to exclude from the index, one per line.'),
+  );
   $form['submit'] = array(
     '#type' => 'submit',
     '#value' => t('Save branch'),
@@ -132,11 +140,25 @@
   // Check for valid directories.
   foreach (explode("\n", $form_state['values']['directory']) as $directory) {
     $directory = trim($directory);
-    if (!is_dir($directory)) {
-      form_set_error('directory', t('%directory is not a directory.', array('%directory' => $directory)));
+    if (!empty($directory)) {
+      if (!is_dir($directory)) {
+        form_set_error('directory', t('%directory is not a directory.', array('%directory' => $directory)));
+      }
+      elseif (!is_readable($directory)) {
+        form_set_error('directory', t('%directory is not readable by PHP.', array('%directory' => $directory)));
+      }
     }
-    elseif (!is_readable($directory)) {
-      form_set_error('directory', t('%directory is not readable by PHP.', array('%directory' => $directory)));
+  }
+  // Check for valid excluded directories.
+  foreach (explode("\n", $form_state['values']['exclude_dirs']) as $directory) {
+    $directory = trim($directory);
+    if (!empty($directory)) {
+      if (!is_dir($directory)) {
+        form_set_error('exclude_dirs', t('%directory is not a directory.', array('%directory' => $directory)));
+      }
+      elseif (!is_readable($directory)) {
+        form_set_error('exclude_dirs', t('%directory is not readable by PHP.', array('%directory' => $directory)));
+      }
     }
   }
 }
@@ -144,7 +166,24 @@
 function api_branch_edit_form_submit($form, &$form_state) {
   $branch->branch_name = $form_state['values']['branch_name'];
   $branch->title = $form_state['values']['title'];
-  $branch->directory = $form_state['values']['directory'];
+
+  $directory_array = explode("\n", $form_state['values']['directory']);
+  foreach ($directory_array as $key => $directory) {
+    $directory_array[$key] = rtrim(trim($directory), '/');
+    if (empty($directory_array[$key])) {
+      unset($directory_array[$key]);
+    }
+  }
+  $branch->directory = implode("\n", $directory_array);
+  
+  $excluded_array = explode("\n", $form_state['values']['exclude_dirs']);
+  foreach ($excluded_array as $key => $directory) {
+    $excluded_array[$key] = rtrim(trim($directory), '/');
+    if (empty($excluded_array[$key])) {
+      unset($excluded_array[$key]);
+    }
+  }
+  $branch->exclude_dirs = implode("\n", $excluded_array);
 
   api_save_branch($branch, $form['branch_name']['#default_value']);
 
diff -urN api.install api.install
--- api.install	2009-01-28 21:52:26.000000000 +0100
+++ api.install	2009-05-05 00:44:18.000000000 +0200
@@ -8,6 +8,7 @@
       'title' => array('type' => 'varchar', 'length' => '255', 'not null' => TRUE, 'default' => ''),
       'directory' => array('type' => 'varchar', 'length' => '255', 'not null' => TRUE, 'default' => ''),
       'weight' => array('type' => 'int', 'unsigned' => TRUE, 'size' => 'tiny', 'not null' => TRUE, 'default' => 0),
+      'exclude_dirs' => array('type' => 'varchar', 'length' => '255', 'not null' => TRUE, 'default' => ''),
     ),
     'primary key' => array('branch_name'),
     'indexes' => array(
@@ -262,6 +263,22 @@
 
   return $return;
 }
+
+/**
+ * Add exclude_dirs column.
+ */
+function api_update_14() {
+  $return = array();
+
+  db_add_field($return, 'api_branch', 'exclude_dirs', array(
+    'type' => 'varchar',
+    'length' => '255',
+    'not null' => TRUE,
+    'default' => '',
+  ));
+
+  return $return;
+}
 
 function api_uninstall() {
   drupal_uninstall_schema('api');
diff -urN api.module api.module
--- api.module	2009-01-28 22:05:03.000000000 +0100
+++ api.module	2009-05-05 00:44:18.000000000 +0200
@@ -93,7 +93,7 @@
   static $branches;
 
   if (!isset($branches) || $_reset) {
-    $result = db_query('SELECT branch_name, title, directory FROM {api_branch} ORDER BY weight');
+    $result = db_query('SELECT branch_name, title, directory, exclude_dirs FROM {api_branch} ORDER BY weight');
     $branches = array();
     while ($branch = db_fetch_object($result)) {
       $branches[$branch->branch_name] = $branch;
diff -urN parser.inc parser.inc
--- parser.inc	2009-01-28 22:35:50.000000000 +0100
+++ parser.inc	2009-05-05 01:03:42.000000000 +0200
@@ -763,7 +763,7 @@
     $files[$file->object_name] = $file; 
   }
 
-  foreach (api_scan_directories($branch->directory) as $path => $file_name) {
+  foreach (api_scan_directories($branch->directory, $branch->exclude_dirs) as $path => $file_name) {
     preg_match('!\.([a-z]*)$!', $file_name, $matches);
     if (isset($parse_functions[$matches[1]])) {
       if (isset($files[$file_name])) {
@@ -796,11 +796,9 @@
 /**
  * Find all the files in the directories specified for a branch.
  */
-function api_scan_directories($directories) {
+function api_scan_directories($directories, $exclude_dirs) {
   $directory_array = explode("\n", $directories);
-  foreach ($directory_array as $key => $directory) {
-    $directory_array[$key] = trim($directory);
-  }
+  $excluded_array = explode("\n", $exclude_dirs);
 
   if (count($directory_array) > 1) {
     $directories_components = array();
@@ -829,9 +827,18 @@
       if (strpos($path, '/.') !== FALSE) {
         continue;
       }
-      $file_name = substr($path, strlen($common_ancestor) + 1);
+      $excluded = FALSE;
+      // If the file is in an excluded path, ignore it
+      foreach ($excluded_array as $excluded_path) {
+        if (!empty($excluded_path) && (strpos($path, $excluded_path) === 0)) {
+          $excluded = TRUE;
+        }
+      }
+      if (!$excluded) {
+        $file_name = substr($path, strlen($common_ancestor) + 1);
 
-      $source_files[$path] = $file_name;
+        $source_files[$path] = $file_name;
+      }
     }
   }
   return $source_files;
