--- DecentralizedMedia/MediaFile.cpp 2005/06/21 03:34:13 516 +++ DecentralizedMedia/MediaFile.cpp 2005/07/11 04:18:35 555 @@ -4,15 +4,16 @@ // // $Id$ -#include +#include -#include +#include #include "MediaFile.hpp" -MediaFile::MediaFile(_H& connection, const api::Path& path) : connection(connection), path(path) +MediaFile::MediaFile(const _R& connector, const api::Path& path) : connector(connector), path(path) { - _H info(connection->Parse(_B("SELECT artist, title, album, genre FROM files WHERE path = ?"))->Execute(path.GetPath())); + _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,13 +22,14 @@ MediaFile::MediaFile(_H album = info->GetString(_B("album")); genre = info->GetString(_B("genre")); } - else - throw; + + connector->Release(connection); } -MediaFile::MediaFile(_H& connection, const api::Path& path, const ext::String& artist, const ext::String& title, const ext::String& album, const ext::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) { - _H path_(connection->Parse(_B("SELECT path FROM files WHERE path = ?"))->Execute(path.GetPath())); + _R connection(connector->Connect()); + _R path_(connection->Parse(_B("SELECT path FROM files WHERE path = ?"))->Execute(path.GetPath())); if (path_->MoveNext()) { @@ -49,4 +51,6 @@ MediaFile::MediaFile(_H } else connection->Parse(_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); }