diff -aurN quercus.orig/src/com/caucho/quercus/lib/file/FileModule.java quercus/src/com/caucho/quercus/lib/file/FileModule.java
--- quercus.orig/src/com/caucho/quercus/lib/file/FileModule.java	2008-06-09 16:35:36.000000000 +0200
+++ quercus/src/com/caucho/quercus/lib/file/FileModule.java	2008-07-03 00:04:26.000000000 +0200
@@ -1729,6 +1729,10 @@
       return null;
     }
 
+    if (prefix.length() > 0  &&  prefix.charAt(prefix.length()-1) != '/') {
+      prefix = prefix + "/";
+    }
+
     for (String entry : list) {
       Matcher matcher = compiledGlobRegex.matcher(entry);
 
@@ -1736,10 +1740,6 @@
         StringValue sb = env.createUnicodeBuilder();
 
         sb.append(prefix);
-
-        if (prefix.length() > 0)
-          sb.append("/");
-
         sb.append(entry);
 
         Path entryPath = path.lookup(entry);
@@ -1782,8 +1782,11 @@
     Path path = env.getPwd();
 
     String trimmedPattern = pattern.toString();
+    String prefix = "";
 
     if (pattern.length() > 0 && pattern.charAt(0) == '/') {
+      prefix = "/";
+
       int i;
 
       // strip off any leading slashes
@@ -1799,7 +1802,7 @@
 
     ArrayValue result = new ArrayValueImpl();
     
-    result = globImpl(env, trimmedPattern, flags, path, "", result);
+    result = globImpl(env, trimmedPattern, flags, path, prefix, result);
 
     if (result == null)
       return BooleanValue.FALSE;
