ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/DecentralizedMedia/MediaFolder.cpp
Revision: 498
Committed: 2005-06-17T13:57:51-07:00 (20 years ago) by douglas
File size: 1539 byte(s)
Log Message:
Nullify!

File Contents

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

Properties

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