ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/DecentralizedMedia/MediaFolder.cpp
Revision: 516
Committed: 2005-06-20T20:34:13-07:00 (20 years ago) by douglas
File size: 2092 byte(s)
Log Message:
Refactored includes to be the way they should, added a precompiled header for msp files to use.

File Contents

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

Properties

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