1 |
// Share |
2 |
// |
3 |
// Douglas Thrift |
4 |
// |
5 |
// $Id$ |
6 |
|
7 |
#include <menes/c++/standard.hh> |
8 |
|
9 |
#include "Share.hpp" |
10 |
|
11 |
Share::Share(const _R<Connector>& connector, const api::Address& host, const cse::String& share) : connector(connector), host(host), share(share) |
12 |
{ |
13 |
cse::String address, port; |
14 |
|
15 |
host.ToString(address, port); |
16 |
|
17 |
api::Path host_(shares.GetChild(address)); |
18 |
|
19 |
if (!host_.Exists()) |
20 |
host_.CreateDirectory(); |
21 |
|
22 |
path = host_.GetChild(share); |
23 |
|
24 |
if (!path.Exists()) |
25 |
path.CreateDirectory(); |
26 |
} |
27 |
|
28 |
Share::~Share() |
29 |
{ |
30 |
_R<dbi::Connection> connection(connector->Connect()); |
31 |
|
32 |
connection->Parse(_B("UPDATE files SET live = FALSE WHERE root = ?"))->Execute(path.GetPath()); |
33 |
connector->Release(connection); |
34 |
} |
35 |
|
36 |
api::Path Share::shares(_B("Shares")); |