[redland-dev] File storage

Dave Beckett dave at dajobe.org
Sun Sep 23 17:41:37 BST 2007


Sebastian Faubel wrote:
> Hi people,
> 
> i want to use a file store, but the store may not be in existence when
> the program is started. The documentation tells me that the file is
> expected to exist upon opening the store. So my question is, what
> problems will occur -- or what am i supposed to do in that case?

Having gone to look at the code, it seems it only opens the file if it
exists when the storage is constructed.  It'll save it on close.

$ rm -f foo.rdf
$ utils/rdfproc -s file foo.rdf add http://a.org/ http://a.org/b http://a.org/
rdfproc: added triple to the graph
$ cat foo.rdf
<?xml version="1.0" encoding="utf-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xml:base="file:///Users/dajobe/dev/redland/librdf/foo.rdf">
  <rdf:Description rdf:about="http://a.org/">
    <ns0:b xmlns:ns0="http://a.org/" rdf:resource="http://a.org/"/>
  </rdf:Description>
</rdf:RDF>


If it really doesn't work for you, I suggest you create the file first with
an empty store.  Something like the following:

FILE *fh=fopen("file.rdf, "w");
fprintf(fh,
"<RDF xmlns=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"></RDF>\n");
fclose(fh);

then open file.rdf as a file storage.


Aside: I've been meaning to separate the 'create' and 'truncate' flags in
opening a storage.  Right now both are done with the same storage
option "new='yes'".

Dave


More information about the redland-dev mailing list