#include <libxml/uri.h>
#include <lrdf.h>
+#include <glibmm/miscutils.h>
#include <pbd/compose.h>
using namespace std;
using namespace ARDOUR;
-static char* TAG = "http://ardour.org/ontology/Tag";
+static const char* TAG = "http://ardour.org/ontology/Tag";
AudioLibrary::AudioLibrary ()
{
- src = "file:" + get_user_ardour_path() + "sfdb";
+ /* XXX URL - '/' is always the separator */
+
+ src = "file:" + get_user_ardour_path() + "/sfdb";
// workaround for possible bug in raptor that crashes when saving to a
// non-existant file.
- touch_file(get_user_ardour_path() + "sfdb");
+
+ touch_file(Glib::build_filename (get_user_ardour_path(), "sfdb"));
lrdf_read_file(src.c_str());
}
return uri.str();
}
+string
+AudioLibrary::uri2path (string uri)
+{
+ string path = xmlURIUnescapeString(uri.c_str(), 0, 0);
+ return path.substr(5);
+}
+
void
AudioLibrary::set_tags (string member, vector<string> tags)
{
lrdf_statement pattern;
pattern.subject = strdup(path2uri(member).c_str());
- pattern.predicate = TAG;
+ pattern.predicate = (char*)TAG;
pattern.object = 0;
pattern.object_type = lrdf_literal;
vector<string>::const_iterator i;
for (i = tags.begin(); i != tags.end(); ++i){
pattern = new lrdf_statement;
- pattern->subject = "?";
- pattern->predicate = TAG;
+ pattern->subject = (char*)"?";
+ pattern->predicate = (char*)TAG;
pattern->object = strdup((*i).c_str());
pattern->next = old;
if (*head != 0) {
lrdf_uris* ulist = lrdf_match_multi(*head);
for (uint32_t j = 0; ulist && j < ulist->count; ++j) {
-// printf("AND: %s\n", ulist->items[j]);
- members.push_back(ulist->items[j]);
+// cerr << "AND: " << uri2path(ulist->items[j]) << endl;
+ members.push_back(uri2path(ulist->items[j]));
}
lrdf_free_uris(ulist);
// memory clean up
pattern = *head;
while(pattern){
- free(pattern->predicate);
free(pattern->object);
old = pattern;
pattern = pattern->next;
delete old;
}
}
-
-bool
-AudioLibrary::safe_file_extension(string file)
-{
- return !(file.rfind(".wav") == string::npos &&
- file.rfind(".aiff")== string::npos &&
- file.rfind(".aif") == string::npos &&
- file.rfind(".snd") == string::npos &&
- file.rfind(".au") == string::npos &&
- file.rfind(".raw") == string::npos &&
- file.rfind(".sf") == string::npos &&
- file.rfind(".cdr") == string::npos &&
- file.rfind(".smp") == string::npos &&
- file.rfind(".maud")== string::npos &&
- file.rfind(".vwe") == string::npos &&
- file.rfind(".paf") == string::npos &&
-#ifdef HAVE_COREAUDIO
- file.rfind(".mp3") == string::npos &&
- file.rfind(".aac") == string::npos &&
- file.rfind(".mp4") == string::npos &&
-#endif // HAVE_COREAUDIO
- file.rfind(".voc") == string::npos);
-}