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

Comparing DecentralizedMedia/MediaFolder.cpp (file contents):
Revision 491 by douglas, 2005-06-17T02:19:32-07:00 vs.
Revision 500 by douglas, 2005-06-17T23:23:46-07:00

# Line 10 | Line 10
10  
11   MediaFolder::MediaFolder(_H<dbi::Connection>& connection, const api::Path& path) : connection(connection), path(path)
12   {
13 <        // XXX: implement
13 >        _H<dbi::ResultSet> root_(connection->Parse(_B("SELECT root FROM folders WHERE path = ?"))->Execute(path.GetPath()));
14 >
15 >        if (root_->MoveNext())
16 >                root = root_->GetString(_B("root"));
17 >        else
18 >                throw;
19 > }
20 >
21 > MediaFolder::MediaFolder(_H<dbi::Connection>& connection, const api::Path& path, const api::Path& root) : connection(connection), path(path), root(root)
22 > {
23 >        _H<dbi::ResultSet> path_(connection->Parse(_B("SELECT path FROM folders WHERE path = ?"))->Execute(path.GetPath()));
24 >
25 >        if (path_->MoveNext())
26 >                if (path.GetPath() != root.GetPath())
27 >                        connection->Parse(_B("UPDATE folders SET folder = ?, root = ? WHERE path = ?"))->Execute(path.GetParent().GetPath(), root.GetPath(), path.GetPath());
28 >                else
29 >                        connection->Parse(_B("UPDATE folders SET folder = NULL, root = ? WHERE path = ?"))->Execute(root.GetPath(), path.GetPath());
30 >        else
31 >                if (path.GetPath() != root.GetPath())
32 >                        connection->Parse(_B("INSERT INTO folders (path, folder, root) VALUES (?, ?, ?)"))->Execute(path.GetPath(), path.GetParent().GetPath(), root.GetPath());
33 >                else
34 >                        connection->Parse(_B("INSERT INTO folders (path, folder, root) VALUES (?, NULL, ?)"))->Execute(path.GetPath(), root.GetPath());
35   }
36  
37   _L<MediaFile> MediaFolder::GetFiles() const

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines