--- DecentralizedMedia/MediaFile.cpp 2005/07/07 11:24:27 553 +++ DecentralizedMedia/MediaFile.cpp 2005/07/17 07:50:52 558 @@ -4,14 +4,15 @@ // // $Id$ -#include +#include #include #include "MediaFile.hpp" -MediaFile::MediaFile(const _R& connection, const api::Path& path) : connection(connection), path(path) +MediaFile::MediaFile(const _R& connector, const api::Path& path) : connector(connector), path(path) { + _R connection(connector->Connect()); _R info(connection->Parse(_B("SELECT artist, title, album, genre FROM files WHERE path = ?"))->Execute(path.GetPath())); if (info->MoveNext()) @@ -21,10 +22,13 @@ MediaFile::MediaFile(const _RGetString(_B("album")); genre = info->GetString(_B("genre")); } + + connector->Release(connection); } -MediaFile::MediaFile(const _R& connection, const api::Path& path, const cse::String& artist, const cse::String& title, const cse::String& album, const cse::String& genre, const api::Path& root) : connection(connection), path(path), artist(artist), title(title), album(album), genre(genre) +MediaFile::MediaFile(const _R& connector, const api::Path& path, const cse::String& artist, const cse::String& title, const cse::String& album, const cse::String& genre, const api::Path& root) : connector(connector), path(path), artist(artist), title(title), album(album), genre(genre) { + _R connection(connector->Connect()); _R path_(connection->Parse(_B("SELECT path FROM files WHERE path = ?"))->Execute(path.GetPath())); if (path_->MoveNext()) @@ -47,4 +51,6 @@ MediaFile::MediaFile(const _RParse(_B("INSERT INTO files (path, artist, title, album, genre, folder, root) VALUES (?, ?, ?, ?, ?, ?, ?)"))->Execute(path.GetPath(), artist, title, album, genre, path.GetParent().GetPath(), root.GetPath()); + + connector->Release(connection); }