Index: libraries.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/libraries/libraries.module,v
retrieving revision 1.2
diff -u -p -r1.2 libraries.module
--- libraries.module	4 Jun 2009 00:01:55 -0000	1.2
+++ libraries.module	23 Feb 2010 12:21:08 -0000
@@ -19,7 +54,7 @@
  *
  * @ingroup libraries
  */
-function libraries_get_path($library, $base_path = FALSE) {
+function libraries_get_path($library, $version, $base_path = FALSE) {
   static $libraries;
 
   if (!isset($libraries)) {
@@ -33,7 +68,7 @@ function libraries_get_path($library, $b
     $path .= 'sites/all/libraries/' . $library;
   }
   else {
-    $path .= $libraries[$library];
+    $path .= $libraries[$library][$version];
   }
 
   return $path;
@@ -86,24 +123,44 @@ function libraries_get_libraries() {
   if (file_exists("$config/$directory")) {
     $searchdir[] = "$config/$directory";
   }
-
   // Retrieve list of directories.
   // @todo Core: Allow to scan for directories.
   $directories = array();
-  $nomask = array('CVS');
   foreach ($searchdir as $dir) {
-    if (is_dir($dir) && $handle = opendir($dir)) {
-      while (FALSE !== ($file = readdir($handle))) {
-        if (!in_array($file, $nomask) && $file[0] != '.') {
-          if (is_dir("$dir/$file")) {
-            $directories[$file] = "$dir/$file";
+    $names = _libraries_searchdir($dir);
+    foreach($names as $name) {
+      if (is_dir("$dir/$name")) {
+        $versions = _libraries_searchdir("$dir/$name");
+        foreach ($versions as $version) {
+          if (is_dir("$dir/$name/$version")) {
+            $directories[$name][$version] = "$dir/$name/$version";
           }
         }
       }
-      closedir($handle);
     }
   }
-
   return $directories;
 }
 
+/*
+ * Returns the contents of a directory
+ *
+ * @param $dir
+ *   The directory to search
+ *
+ * @return
+ *   An array of files and directories
+ */
+function _libraries_searchdir($dir) {
+  $nomask = array('CVS');
+  if (is_dir($dir) && $handle = opendir($dir)) {
+    $return = array();
+    while (FALSE !== ($file = readdir($handle))) {
+      if (!in_array($file, $nomask) && $file[0] != '.') {
+        $return[] = $file;
+      }
+    }
+    closedir($handle);
+  }
+  return $return;
+}
