ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/DecentralizedMedia/MediaFile.cpp
(Generate patch)

Comparing DecentralizedMedia/MediaFile.cpp (file contents):
Revision 476 by douglas, 2005-06-08T13:41:10-07:00 vs.
Revision 534 by douglas, 2005-06-29T23:01:02-07:00

# Line 4 | Line 4
4   //
5   // $Id$
6  
7 + #include <menes/standard.hh>
8 +
9 + #include <menes-dbi/resultset.hpp>
10 +
11   #include "MediaFile.hpp"
12  
13 < bool MediaFile::operator<(const MediaFile& file) const
13 > MediaFile::MediaFile(_H<dbi::Connection>& connection, const api::Path& path) : connection(connection), path(path)
14 > {
15 >        _H<dbi::ResultSet> info(connection->Parse(_B("SELECT artist, title, album, genre FROM files WHERE path = ?"))->Execute(path.GetPath()));
16 >
17 >        if (info->MoveNext())
18 >        {
19 >                artist = info->GetString(_B("artist"));
20 >                title = info->GetString(_B("title"));
21 >                album = info->GetString(_B("album"));
22 >                genre = info->GetString(_B("genre"));
23 >        }
24 >        else
25 >                throw;
26 > }
27 >
28 > MediaFile::MediaFile(_H<dbi::Connection>& 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)
29   {
30 <        return ext::Compare(name.GetData().Begin(), file.name.GetData().Begin(), name.GetData().GetSize() < file.name.GetData().GetSize() ? name.GetData().GetSize() : file.name.GetData().GetSize()) < 0 || name.GetData().GetSize() < file.name.GetData().GetSize();
30 >        _H<dbi::ResultSet> path_(connection->Parse(_B("SELECT path FROM files WHERE path = ?"))->Execute(path.GetPath()));
31 >
32 >        if (path_->MoveNext())
33 >        {
34 >                connection->Parse(_B("UPDATE files SET live = TRUE WHERE path = ?"))->Execute(path.GetPath());
35 >
36 >                if (!artist.IsEmpty())
37 >                        connection->Parse(_B("UPDATE files SET artist = ? WHERE path = ?"))->Execute(artist, path.GetPath());
38 >
39 >                if (!title.IsEmpty())
40 >                        connection->Parse(_B("UPDATE files SET title = ? WHERE path = ?"))->Execute(title, path.GetPath());
41 >
42 >                if (!album.IsEmpty())
43 >                        connection->Parse(_B("UPDATE files SET album = ? WHERE path = ?"))->Execute(album, path.GetPath());
44 >
45 >                if (!genre.IsEmpty())
46 >                        connection->Parse(_B("UPDATE files SET genre = ? WHERE path = ?"))->Execute(genre, path.GetPath());
47 >
48 >                connection->Parse(_B("UPDATE files SET root = ? WHERE path = ?"))->Execute(root.GetPath(), path.GetPath());
49 >        }
50 >        else
51 >                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());
52   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines