Make Slurp_File return a Blob
Project: http://git-wip-us.apache.org/repos/asf/lucy/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/4e18b58a Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/4e18b58a Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/4e18b58a Branch: refs/heads/master Commit: 4e18b58a911b495e61a5311610efa035344e8a1d Parents: c6ccfdb Author: Nick Wellnhofer <[email protected]> Authored: Tue May 5 11:07:05 2015 +0200 Committer: Nick Wellnhofer <[email protected]> Committed: Tue May 5 11:24:53 2015 +0200 ---------------------------------------------------------------------- core/Lucy/Store/Folder.c | 7 ++++--- core/Lucy/Store/Folder.cfh | 2 +- core/Lucy/Test/Store/TestFolder.c | 5 +++-- 3 files changed, 8 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy/blob/4e18b58a/core/Lucy/Store/Folder.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Store/Folder.c b/core/Lucy/Store/Folder.c index d724da0..244446a 100644 --- a/core/Lucy/Store/Folder.c +++ b/core/Lucy/Store/Folder.c @@ -21,6 +21,7 @@ #include "charmony.h" +#include "Clownfish/Blob.h" #include "Lucy/Store/Folder.h" #include "Lucy/Store/CompoundFileReader.h" #include "Lucy/Store/CompoundFileWriter.h" @@ -363,10 +364,10 @@ Folder_List_R_IMP(Folder *self, String *path) { return list; } -ByteBuf* +Blob* Folder_Slurp_File_IMP(Folder *self, String *path) { InStream *instream = Folder_Open_In(self, path); - ByteBuf *retval = NULL; + Blob *retval = NULL; if (!instream) { RETHROW(INCREF(Err_get_error())); @@ -385,7 +386,7 @@ Folder_Slurp_File_IMP(Folder *self, String *path) { char *ptr = (char*)MALLOCATE((size_t)size + 1); InStream_Read_Bytes(instream, ptr, size); ptr[size] = '\0'; - retval = BB_new_steal_bytes(ptr, size, size + 1); + retval = Blob_new_steal(ptr, size); InStream_Close(instream); DECREF(instream); } http://git-wip-us.apache.org/repos/asf/lucy/blob/4e18b58a/core/Lucy/Store/Folder.cfh ---------------------------------------------------------------------- diff --git a/core/Lucy/Store/Folder.cfh b/core/Lucy/Store/Folder.cfh index a2c1bf0..778b12d 100644 --- a/core/Lucy/Store/Folder.cfh +++ b/core/Lucy/Store/Folder.cfh @@ -170,7 +170,7 @@ public abstract class Lucy::Store::Folder inherits Clownfish::Obj { * @param path A relative filepath. * @param return the file's contents. */ - public incremented ByteBuf* + public incremented Blob* Slurp_File(Folder *self, String *path); /** Collapse the contents of the directory into a compound file. http://git-wip-us.apache.org/repos/asf/lucy/blob/4e18b58a/core/Lucy/Test/Store/TestFolder.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Store/TestFolder.c b/core/Lucy/Test/Store/TestFolder.c index 34d683d..f5b0464 100644 --- a/core/Lucy/Test/Store/TestFolder.c +++ b/core/Lucy/Test/Store/TestFolder.c @@ -18,6 +18,7 @@ #define TESTLUCY_USE_SHORT_NAMES #include "Lucy/Util/ToolSet.h" +#include "Clownfish/Blob.h" #include "Clownfish/TestHarness/TestBatchRunner.h" #include "Lucy/Test.h" #include "Lucy/Test/Store/TestFolder.h" @@ -506,13 +507,13 @@ test_Slurp_File(TestBatchRunner *runner) { Folder *folder = (Folder*)RAMFolder_new(NULL); FileHandle *fh = Folder_Open_FileHandle(folder, foo, FH_CREATE | FH_WRITE_ONLY); - ByteBuf *contents; + Blob *contents; FH_Write(fh, "stuff", 5); FH_Close(fh); DECREF(fh); contents = Folder_Slurp_File(folder, foo); - TEST_TRUE(runner, BB_Equals_Bytes(contents, "stuff", 5), "Slurp_File"); + TEST_TRUE(runner, Blob_Equals_Bytes(contents, "stuff", 5), "Slurp_File"); DECREF(contents); DECREF(folder);
