lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject svn commit: r930403 - in /lucene/lucy/trunk/core/Lucy: Store/Folder.bp Store/Folder.c Test/Store/TestFSFolder.c
Date Fri, 02 Apr 2010 21:55:35 GMT
Author: marvin
Date: Fri Apr  2 21:55:35 2010
New Revision: 930403

URL: http://svn.apache.org/viewvc?rev=930403&view=rev
Log:
Add an extra argument to Folder_List_R() specifying an optional subdirectory.

Modified:
    lucene/lucy/trunk/core/Lucy/Store/Folder.bp
    lucene/lucy/trunk/core/Lucy/Store/Folder.c
    lucene/lucy/trunk/core/Lucy/Test/Store/TestFSFolder.c

Modified: lucene/lucy/trunk/core/Lucy/Store/Folder.bp
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/core/Lucy/Store/Folder.bp?rev=930403&r1=930402&r2=930403&view=diff
==============================================================================
--- lucene/lucy/trunk/core/Lucy/Store/Folder.bp (original)
+++ lucene/lucy/trunk/core/Lucy/Store/Folder.bp Fri Apr  2 21:55:35 2010
@@ -84,10 +84,11 @@ abstract class Lucy::Store::Folder exten
 
     /** Recursively list all files and directories in the Folder.
      *
+     * @param path A relative filepath optionally specifying a subdirectory.
      * @return an unsorted array of relative filepaths.
      */
     incremented VArray*
-    List_R(Folder *self);
+    List_R(Folder *self, const CharBuf *path = NULL);
 
     /** Indicate whether an entity exists at <code>path</code>.
      *

Modified: lucene/lucy/trunk/core/Lucy/Store/Folder.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/core/Lucy/Store/Folder.c?rev=930403&r1=930402&r2=930403&view=diff
==============================================================================
--- lucene/lucy/trunk/core/Lucy/Store/Folder.c (original)
+++ lucene/lucy/trunk/core/Lucy/Store/Folder.c Fri Apr  2 21:55:35 2010
@@ -330,14 +330,20 @@ Folder_list(Folder *self, const CharBuf 
 }
 
 VArray*
-Folder_list_r(Folder *self)
+Folder_list_r(Folder *self, const CharBuf *path)
 {
-    CharBuf *prefix = CB_new(20);
-    CharBuf *dir    = CB_new(20);
-    VArray *list    =  VA_new(32);
-    S_add_to_file_list(self, list, dir, prefix);
-    DECREF(prefix);
-    DECREF(dir);
+    Folder *local_folder = Folder_Find_Folder(self, path);
+    VArray *list =  VA_new(0);
+    if (local_folder) {
+        CharBuf *dir    = CB_new(20);
+        CharBuf *prefix = CB_new(20);
+        if (path && CB_Get_Size(path)) {
+            CB_setf(prefix, "%o/", path);
+        }
+        S_add_to_file_list(local_folder, list, dir, prefix);
+        DECREF(prefix);
+        DECREF(dir);
+    }
     return list;
 }
 

Modified: lucene/lucy/trunk/core/Lucy/Test/Store/TestFSFolder.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/core/Lucy/Test/Store/TestFSFolder.c?rev=930403&r1=930402&r2=930403&view=diff
==============================================================================
--- lucene/lucy/trunk/core/Lucy/Test/Store/TestFSFolder.c (original)
+++ lucene/lucy/trunk/core/Lucy/Test/Store/TestFSFolder.c Fri Apr  2 21:55:35 2010
@@ -84,7 +84,7 @@ test_protect_symlinks(TestBatch *batch) 
         FAIL(batch, "symlink() failed");
     }
     else {
-        VArray *list = FSFolder_List_R(folder);
+        VArray *list = FSFolder_List_R(folder, NULL);
         bool_t saw_bazooka_boffo = false;
         for (uint32_t i = 0, max = VA_Get_Size(list); i < max; i++) {
             CharBuf *entry = (CharBuf*)VA_Fetch(list, i);
@@ -94,6 +94,7 @@ test_protect_symlinks(TestBatch *batch) 
         }
         ASSERT_FALSE(batch, saw_bazooka_boffo, 
             "List_R() shouldn't follow symlinks");
+        DECREF(list);
 
         ASSERT_TRUE(batch, FSFolder_Delete_Tree(folder, bar), 
             "Delete_Tree() returns true"), 



Mime
View raw message