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 |
496 |
MediaFolder::MediaFolder(_H<dbi::Connection>& connection, const api::Path& path, const api::Path& root) : connection(connection), path(path) |
17 |
|
|
{ |
18 |
|
|
_H<dbi::ResultSet> path_(connection->Parse(_B("SELECT path FROM folders WHERE path = ?"))-Execute(path.GetPath())); |
19 |
|
|
|
20 |
|
|
if (!path_->MoveNext()) |
21 |
|
|
connection->Parse(_B("INSERT INTO folders (path, folder, root) VALUES (?, ?, ?)"))->Execute(path.GetPath(), path.GetParent().GetPath(), root.GetPath()); |
22 |
|
|
} |
23 |
|
|
|
24 |
douglas |
478 |
_L<MediaFile> MediaFolder::GetFiles() const |
25 |
|
|
{ |
26 |
douglas |
491 |
_H<dbi::ResultSet> paths(connection->Parse(_B("SELECT path FROM files WHERE live = TRUE AND folder = ?"))->Execute(path.GetPath())); |
27 |
douglas |
478 |
_L<MediaFile> files; |
28 |
|
|
|
29 |
douglas |
488 |
while (paths->MoveNext()) |
30 |
|
|
files.InsertLast(MediaFile(connection, paths->GetString(_B("path")))); |
31 |
douglas |
478 |
|
32 |
|
|
return files; |
33 |
|
|
} |
34 |
|
|
|
35 |
|
|
_L<MediaFolder> MediaFolder::GetFolders() const |
36 |
|
|
{ |
37 |
douglas |
491 |
_H<dbi::ResultSet> paths(connection->Parse(_B("SELECT path FROM folders WHERE live = TRUE AND folder = ?"))->Execute(path.GetPath())); |
38 |
douglas |
478 |
_L<MediaFolder> folders; |
39 |
|
|
|
40 |
douglas |
488 |
while (paths->MoveNext()) |
41 |
|
|
folders.InsertLast(MediaFolder(connection, paths->GetString(_B("path")))); |
42 |
douglas |
478 |
|
43 |
|
|
return folders; |
44 |
|
|
} |