ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/DecentralizedMedia/MediaFolder.cpp
Revision: 499
Committed: 2005-06-17T14:11:19-07:00 (20 years ago) by douglas
File size: 1675 byte(s)
Log Message:
Hmm?

File Contents

# User Rev Content
1 douglas 476 // Media Folder
2     //
3     // Douglas Thrift
4     //
5     // $Id$
6    
7     #include "MediaFolder.hpp"
8 douglas 478
9 douglas 489 #include <menes-dbi/resultset.hpp>
10    
11 douglas 485 MediaFolder::MediaFolder(_H<dbi::Connection>& connection, const api::Path& path) : connection(connection), path(path)
12 douglas 478 {
13     // XXX: implement
14     }
15    
16 douglas 499 MediaFolder::MediaFolder(_H<dbi::Connection>& connection, const api::Path& path, const api::Path& root) : connection(connection), path(path), root(root)
17 douglas 496 {
18 douglas 499 _H<dbi::ResultSet> path_(connection->Parse(_B("SELECT path FROM folders WHERE path = ? AND root = ?"))->Execute(path.GetPath(), root.GetPath()));
19 douglas 496
20     if (!path_->MoveNext())
21 douglas 499 {
22     connection->Parse(_B("DELETE FROM folders WHERE path = ?"))->Execute(path.GetPath());
23    
24 douglas 498 if (path.GetPath() != root.GetPath())
25     connection->Parse(_B("INSERT INTO folders (path, folder, root) VALUES (?, ?, ?)"))->Execute(path.GetPath(), path.GetParent().GetPath(), root.GetPath());
26     else
27     connection->Parse(_B("INSERT INTO folders (path, folder, root) VALUES (?, NULL, ?)"))->Execute(path.GetPath(), root.GetPath());
28 douglas 499 }
29 douglas 496 }
30    
31 douglas 478 _L<MediaFile> MediaFolder::GetFiles() const
32     {
33 douglas 491 _H<dbi::ResultSet> paths(connection->Parse(_B("SELECT path FROM files WHERE live = TRUE AND folder = ?"))->Execute(path.GetPath()));
34 douglas 478 _L<MediaFile> files;
35    
36 douglas 488 while (paths->MoveNext())
37     files.InsertLast(MediaFile(connection, paths->GetString(_B("path"))));
38 douglas 478
39     return files;
40     }
41    
42     _L<MediaFolder> MediaFolder::GetFolders() const
43     {
44 douglas 491 _H<dbi::ResultSet> paths(connection->Parse(_B("SELECT path FROM folders WHERE live = TRUE AND folder = ?"))->Execute(path.GetPath()));
45 douglas 478 _L<MediaFolder> folders;
46    
47 douglas 488 while (paths->MoveNext())
48     folders.InsertLast(MediaFolder(connection, paths->GetString(_B("path"))));
49 douglas 478
50     return folders;
51     }

Properties

Name Value
svn:eol-style native
svn:keywords Id