1 |
// Share |
2 |
// |
3 |
// Douglas Thrift |
4 |
// |
5 |
// $Id$ |
6 |
|
7 |
#include "Share.hpp" |
8 |
|
9 |
#include <menes-api/console.hpp> |
10 |
#include <menes-api/realpath.hpp> |
11 |
|
12 |
Share::Share(const _H<dbi::Connection>& connection, const ext::String& host, const ext::String& share) : connection(connection), host(host), share(share) |
13 |
{ |
14 |
api::Path shares(api::RealPath(_B("Shares"))); |
15 |
|
16 |
if (!shares.Exists()) |
17 |
api::Posix::CheckError(::mkdir(shares.GetPath().NullTerminate(), 0755)); |
18 |
|
19 |
api::Path host_(shares.GetChild(host)); |
20 |
|
21 |
if (!host_.Exists()) |
22 |
api::Posix::CheckError(::mkdir(host_.GetPath().NullTerminate(), 0755)); |
23 |
|
24 |
path = host_.GetChild(share); |
25 |
|
26 |
if (!path.Exists()) |
27 |
api::Posix::CheckError(::mkdir(path.GetPath().NullTerminate(), 0755)); |
28 |
} |
29 |
|
30 |
void Share::Mount() const |
31 |
{ |
32 |
api::Cout << "MOUNT: //" << host << "/" << share << " TO " << path.GetPath() << ios::NewLine; |
33 |
|
34 |
// XXX: implement |
35 |
} |
36 |
|
37 |
void Share::Unmount() const |
38 |
{ |
39 |
connection->Parse(_B("UPDATE files SET live = FALSE WHERE root = ?"))->Execute(path.GetPath()); |
40 |
|
41 |
api::Cout << "UNMOUNT: //" << path.GetPath() << ios::NewLine; |
42 |
|
43 |
// XXX: implement |
44 |
} |